Commit 503b91cc authored by Mahmood Ali's avatar Mahmood Ali
Browse files

docker minor changes

parent fe57454f
Showing with 49 additions and 36 deletions
+49 -36
......@@ -1209,8 +1209,6 @@ func (d *Driver) ExecTaskStreaming(ctx context.Context, taskID string, opts driv
done := make(chan interface{})
defer close(done)
d.logger.Warn("exectask is called", "opts", fmt.Sprintf("%#v", opts))
h, ok := d.tasks.Get(taskID)
if !ok {
return nil, drivers.ErrTaskNotFound
......
......@@ -2077,32 +2077,3 @@ func waitForExist(t *testing.T, client *docker.Client, containerID string) {
require.NoError(t, err)
})
}
func TestDockerExecTaskStreaming(t *testing.T) {
if !tu.IsCI() {
t.Parallel()
}
testutil.DockerCompatible(t)
taskCfg := newTaskConfig("", []string{"/bin/sleep", "1000"})
task := &drivers.TaskConfig{
ID: uuid.Generate(),
Name: "nc-demo",
AllocID: uuid.Generate(),
Resources: basicResources,
}
require.NoError(t, task.EncodeConcreteDriverConfig(&taskCfg))
d := dockerDriverHarness(t, nil)
cleanup := d.MkAllocDir(task, true)
defer cleanup()
copyImage(t, task.TaskDir(), "busybox.tar")
_, _, err := d.StartTask(task)
require.NoError(t, err)
defer d.DestroyTask(task.ID, true)
dtestutil.ExecTaskStreamingConformanceTests(t, d, task.ID)
}
......@@ -761,3 +761,32 @@ func copyFile(src, dst string, t *testing.T) {
t.Fatalf("copying %v -> %v failed: %v", src, dst, err)
}
}
func TestDockerExecTaskStreaming(t *testing.T) {
if !tu.IsCI() {
t.Parallel()
}
testutil.DockerCompatible(t)
taskCfg := newTaskConfig("", []string{"/bin/sleep", "1000"})
task := &drivers.TaskConfig{
ID: uuid.Generate(),
Name: "nc-demo",
AllocID: uuid.Generate(),
Resources: basicResources,
}
require.NoError(t, task.EncodeConcreteDriverConfig(&taskCfg))
d := dockerDriverHarness(t, nil)
cleanup := d.MkAllocDir(task, true)
defer cleanup()
copyImage(t, task.TaskDir(), "busybox.tar")
_, _, err := d.StartTask(task)
require.NoError(t, err)
defer d.DestroyTask(task.ID, true)
dtestutils.ExecTaskStreamingConformanceTests(t, d, task.ID)
}
......@@ -35,7 +35,7 @@ func ExecTaskStreamingBasicResponses(t *testing.T, driver *DriverHarness, taskID
customizeFn func(*drivers.ExecOptions, chan drivers.TerminalSize)
}{
{
name: "basic non tty",
name: "notty: basic",
command: "echo hello stdout; echo hello stderr >&2; exit 43",
tty: false,
stdout: "hello stdout\n",
......@@ -43,27 +43,42 @@ func ExecTaskStreamingBasicResponses(t *testing.T, driver *DriverHarness, taskID
exitCode: 43,
},
{
name: "streaming non tty",
name: "notty: streaming",
command: "for n in 1 2 3; do echo $n; sleep 1; done",
tty: false,
stdout: "1\n2\n3\n",
exitCode: 0,
},
{
name: "stty check non tty",
command: "sleep 0.1; stty size",
name: "ntty: stty check",
command: "stty size",
tty: false,
stderr: "stty: standard input: Inappropriate ioctl for device\n",
exitCode: 1,
},
{
name: "stdin passing non tty",
name: "notty: stdin passing",
command: "echo hello from command; cat",
tty: false,
stdin: "hello from stdin\n",
stdout: "hello from command\nhello from stdin\n",
exitCode: 0,
},
{
name: "notty: stdin passing",
command: "echo hello from command; cat",
tty: false,
stdin: "hello from stdin\n",
stdout: "hello from command\nhello from stdin\n",
exitCode: 0,
},
{
name: "notty: children processes",
command: "(( sleep 6; echo from background ) & ); echo from main; exec sleep 1",
tty: false,
stdout: "hello from command\nhello from stdin\n",
exitCode: 0,
},
}
for _, c := range cases {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment