drivers: implement streaming exec for executor based drivers

These simply delegate call to backend executor.
This commit is contained in:
Mahmood Ali
2019-04-28 17:31:02 -04:00
parent 976bfbc41a
commit 74e5e20c0b
6 changed files with 150 additions and 0 deletions

View File

@@ -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) {

View File

@@ -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()