mirror of
https://github.com/kemko/nomad.git
synced 2026-01-05 18:05:42 +03:00
drivers: implement streaming exec for executor based drivers
These simply delegate call to backend executor.
This commit is contained in:
@@ -554,6 +554,25 @@ func (d *Driver) ExecTask(taskID string, cmd []string, timeout time.Duration) (*
|
||||
}, nil
|
||||
}
|
||||
|
||||
var _ drivers.ExecTaskStreamingRawDriver = (*Driver)(nil)
|
||||
|
||||
func (d *Driver) ExecTaskStreamingRaw(ctx context.Context,
|
||||
taskID string,
|
||||
command []string,
|
||||
tty bool,
|
||||
stream drivers.ExecTaskStream) error {
|
||||
|
||||
if len(command) == 0 {
|
||||
return fmt.Errorf("error cmd must have atleast one value")
|
||||
}
|
||||
handle, ok := d.tasks.Get(taskID)
|
||||
if !ok {
|
||||
return drivers.ErrTaskNotFound
|
||||
}
|
||||
|
||||
return handle.exec.ExecStreaming(ctx, command, tty, stream)
|
||||
}
|
||||
|
||||
// GetAbsolutePath returns the absolute path of the passed binary by resolving
|
||||
// it in the path and following symlinks.
|
||||
func GetAbsolutePath(bin string) (string, error) {
|
||||
|
||||
@@ -243,6 +243,35 @@ func TestJavaCmdArgs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestJavaDriver_ExecTaskStreaming(t *testing.T) {
|
||||
javaCompatible(t)
|
||||
if !testutil.IsCI() {
|
||||
t.Parallel()
|
||||
}
|
||||
|
||||
require := require.New(t)
|
||||
d := NewDriver(testlog.HCLogger(t))
|
||||
harness := dtestutil.NewDriverHarness(t, d)
|
||||
defer harness.Kill()
|
||||
|
||||
tc := &TaskConfig{
|
||||
Class: "Hello",
|
||||
Args: []string{"900"},
|
||||
}
|
||||
task := basicTask(t, "demo-app", tc)
|
||||
|
||||
cleanup := harness.MkAllocDir(task, true)
|
||||
defer cleanup()
|
||||
|
||||
copyFile("./test-resources/Hello.class", filepath.Join(task.TaskDir().Dir, "Hello.class"), t)
|
||||
|
||||
_, _, err := harness.StartTask(task)
|
||||
require.NoError(err)
|
||||
defer d.DestroyTask(task.ID, true)
|
||||
|
||||
dtestutil.ExecTaskStreamingConformanceTests(t, harness, task.ID)
|
||||
|
||||
}
|
||||
func basicTask(t *testing.T, name string, taskConfig *TaskConfig) *drivers.TaskConfig {
|
||||
t.Helper()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user