mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
drivers: plumb grpc client logger
This commit is contained in:
@@ -78,8 +78,6 @@ func TestExecutor_Start_Invalid(pt *testing.T) {
|
||||
pt.Parallel()
|
||||
invalid := "/bin/foobar"
|
||||
for name, factory := range executorFactories {
|
||||
name := name
|
||||
factory := factory
|
||||
pt.Run(name, func(t *testing.T) {
|
||||
require := require.New(t)
|
||||
execCmd, allocDir := testExecutorCommand(t)
|
||||
@@ -98,8 +96,6 @@ func TestExecutor_Start_Invalid(pt *testing.T) {
|
||||
func TestExecutor_Start_Wait_Failure_Code(pt *testing.T) {
|
||||
pt.Parallel()
|
||||
for name, factory := range executorFactories {
|
||||
name := name
|
||||
factory := factory
|
||||
pt.Run(name, func(t *testing.T) {
|
||||
require := require.New(t)
|
||||
execCmd, allocDir := testExecutorCommand(t)
|
||||
@@ -122,8 +118,6 @@ func TestExecutor_Start_Wait_Failure_Code(pt *testing.T) {
|
||||
func TestExecutor_Start_Wait(pt *testing.T) {
|
||||
pt.Parallel()
|
||||
for name, factory := range executorFactories {
|
||||
name := name
|
||||
factory := factory
|
||||
pt.Run(name, func(t *testing.T) {
|
||||
require := require.New(t)
|
||||
execCmd, allocDir := testExecutorCommand(t)
|
||||
@@ -161,13 +155,12 @@ func TestExecutor_Start_Wait(pt *testing.T) {
|
||||
func TestExecutor_WaitExitSignal(pt *testing.T) {
|
||||
pt.Parallel()
|
||||
for name, factory := range executorFactories {
|
||||
name := name
|
||||
factory := factory
|
||||
pt.Run(name, func(t *testing.T) {
|
||||
require := require.New(t)
|
||||
execCmd, allocDir := testExecutorCommand(t)
|
||||
execCmd.Cmd = "/bin/sleep"
|
||||
execCmd.Args = []string{"10000"}
|
||||
execCmd.ResourceLimits = true
|
||||
defer allocDir.Destroy()
|
||||
executor := factory(testlog.HCLogger(t))
|
||||
defer executor.Shutdown("", 0)
|
||||
@@ -176,8 +169,6 @@ func TestExecutor_WaitExitSignal(pt *testing.T) {
|
||||
require.NoError(err)
|
||||
|
||||
go func() {
|
||||
// Give process time to start
|
||||
time.Sleep(time.Second)
|
||||
tu.WaitForResult(func() (bool, error) {
|
||||
ch, err := executor.Stats(context.Background(), time.Second)
|
||||
if err != nil {
|
||||
@@ -201,8 +192,8 @@ func TestExecutor_WaitExitSignal(pt *testing.T) {
|
||||
}
|
||||
return true, nil
|
||||
}, func(err error) {
|
||||
assert.NoError(t, executor.Signal(os.Kill))
|
||||
assert.NoError(t, err)
|
||||
executor.Shutdown("SIGINT", 0)
|
||||
})
|
||||
}()
|
||||
|
||||
@@ -216,8 +207,6 @@ func TestExecutor_WaitExitSignal(pt *testing.T) {
|
||||
func TestExecutor_Start_Kill(pt *testing.T) {
|
||||
pt.Parallel()
|
||||
for name, factory := range executorFactories {
|
||||
name := name
|
||||
factory := factory
|
||||
pt.Run(name, func(t *testing.T) {
|
||||
require := require.New(t)
|
||||
execCmd, allocDir := testExecutorCommand(t)
|
||||
@@ -320,7 +309,7 @@ func TestUniversalExecutor_LookupPath(t *testing.T) {
|
||||
// than mounting the underlying host filesystem
|
||||
func setupRootfs(t *testing.T, rootfs string) {
|
||||
paths := []string{
|
||||
// "/bin/sh",
|
||||
"/bin/sh",
|
||||
"/bin/sleep",
|
||||
"/bin/echo",
|
||||
"/bin/date",
|
||||
|
||||
@@ -97,7 +97,7 @@ func (s *grpcExecutorServer) Stats(req *proto.StatsRequest, stream proto.Executo
|
||||
interval = time.Second
|
||||
}
|
||||
|
||||
outCh, err := s.impl.Stats(stream.Context(), time.Duration(req.Interval))
|
||||
outCh, err := s.impl.Stats(stream.Context(), interval)
|
||||
if err != nil {
|
||||
if rec, ok := err.(structs.Recoverable); ok {
|
||||
st := status.New(codes.FailedPrecondition, rec.Error())
|
||||
|
||||
@@ -15,12 +15,14 @@ import (
|
||||
// interface to expose the the interface over gRPC
|
||||
type PluginDriver struct {
|
||||
plugin.NetRPCUnsupportedPlugin
|
||||
impl DriverPlugin
|
||||
impl DriverPlugin
|
||||
logger hclog.Logger
|
||||
}
|
||||
|
||||
func NewDriverPlugin(d DriverPlugin) plugin.GRPCPlugin {
|
||||
func NewDriverPlugin(d DriverPlugin, logger hclog.Logger) plugin.GRPCPlugin {
|
||||
return &PluginDriver{
|
||||
impl: d,
|
||||
impl: d,
|
||||
logger: logger,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +42,7 @@ func (p *PluginDriver) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker
|
||||
},
|
||||
client: proto.NewDriverClient(c),
|
||||
doneCtx: ctx,
|
||||
logger: p.logger,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -49,7 +52,7 @@ func Serve(d DriverPlugin, logger hclog.Logger) {
|
||||
HandshakeConfig: base.Handshake,
|
||||
Plugins: map[string]plugin.Plugin{
|
||||
base.PluginTypeBase: &base.PluginBase{Impl: d},
|
||||
base.PluginTypeDriver: &PluginDriver{impl: d},
|
||||
base.PluginTypeDriver: &PluginDriver{impl: d, logger: logger},
|
||||
},
|
||||
GRPCServer: plugin.DefaultGRPCServer,
|
||||
Logger: logger,
|
||||
|
||||
@@ -42,7 +42,7 @@ func (d *DriverHarness) Impl() drivers.DriverPlugin {
|
||||
func NewDriverHarness(t testing.T, d drivers.DriverPlugin) *DriverHarness {
|
||||
logger := testlog.HCLogger(t).Named("driver_harness")
|
||||
|
||||
pd := drivers.NewDriverPlugin(d).(*drivers.PluginDriver)
|
||||
pd := drivers.NewDriverPlugin(d, logger).(*drivers.PluginDriver)
|
||||
|
||||
client, server := plugin.TestPluginGRPCConn(t,
|
||||
map[string]plugin.Plugin{
|
||||
|
||||
Reference in New Issue
Block a user