|
@@ -40,7 +40,7 @@ func TestIDFormat(t *testing.T) {
|
|
|
func TestMultipleAttachRestart(t *testing.T) {
|
|
|
runtime := mkRuntime(t)
|
|
|
defer nuke(runtime)
|
|
|
- container, hostConfig, _ := mkContainer(
|
|
|
+ container, _ := mkContainer(
|
|
|
runtime,
|
|
|
[]string{"_", "/bin/sh", "-c", "i=1; while [ $i -le 5 ]; do i=`expr $i + 1`; echo hello; done"},
|
|
|
t,
|
|
@@ -61,7 +61,7 @@ func TestMultipleAttachRestart(t *testing.T) {
|
|
|
if err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
- if err := container.Start(hostConfig); err != nil {
|
|
|
+ if err := container.Start(); err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
l1, err := bufio.NewReader(stdout1).ReadString('\n')
|
|
@@ -102,7 +102,7 @@ func TestMultipleAttachRestart(t *testing.T) {
|
|
|
if err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
- if err := container.Start(hostConfig); err != nil {
|
|
|
+ if err := container.Start(); err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
|
|
@@ -136,7 +136,7 @@ func TestDiff(t *testing.T) {
|
|
|
runtime := mkRuntime(t)
|
|
|
defer nuke(runtime)
|
|
|
// Create a container and remove a file
|
|
|
- container1, _, _ := mkContainer(runtime, []string{"_", "/bin/rm", "/etc/passwd"}, t)
|
|
|
+ container1, _ := mkContainer(runtime, []string{"_", "/bin/rm", "/etc/passwd"}, t)
|
|
|
defer runtime.Destroy(container1)
|
|
|
|
|
|
// The changelog should be empty and not fail before run. See #1705
|
|
@@ -178,7 +178,7 @@ func TestDiff(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
// Create a new container from the commited image
|
|
|
- container2, _, _ := mkContainer(runtime, []string{img.ID, "cat", "/etc/passwd"}, t)
|
|
|
+ container2, _ := mkContainer(runtime, []string{img.ID, "cat", "/etc/passwd"}, t)
|
|
|
defer runtime.Destroy(container2)
|
|
|
|
|
|
if err := container2.Run(); err != nil {
|
|
@@ -197,7 +197,7 @@ func TestDiff(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
// Create a new container
|
|
|
- container3, _, _ := mkContainer(runtime, []string{"_", "rm", "/bin/httpd"}, t)
|
|
|
+ container3, _ := mkContainer(runtime, []string{"_", "rm", "/bin/httpd"}, t)
|
|
|
defer runtime.Destroy(container3)
|
|
|
|
|
|
if err := container3.Run(); err != nil {
|
|
@@ -223,7 +223,7 @@ func TestDiff(t *testing.T) {
|
|
|
func TestCommitAutoRun(t *testing.T) {
|
|
|
runtime := mkRuntime(t)
|
|
|
defer nuke(runtime)
|
|
|
- container1, _, _ := mkContainer(runtime, []string{"_", "/bin/sh", "-c", "echo hello > /world"}, t)
|
|
|
+ container1, _ := mkContainer(runtime, []string{"_", "/bin/sh", "-c", "echo hello > /world"}, t)
|
|
|
defer runtime.Destroy(container1)
|
|
|
|
|
|
if container1.State.Running {
|
|
@@ -246,7 +246,7 @@ func TestCommitAutoRun(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
// FIXME: Make a TestCommit that stops here and check docker.root/layers/img.id/world
|
|
|
- container2, hostConfig, _ := mkContainer(runtime, []string{img.ID}, t)
|
|
|
+ container2, _ := mkContainer(runtime, []string{img.ID}, t)
|
|
|
defer runtime.Destroy(container2)
|
|
|
stdout, err := container2.StdoutPipe()
|
|
|
if err != nil {
|
|
@@ -256,7 +256,7 @@ func TestCommitAutoRun(t *testing.T) {
|
|
|
if err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
- if err := container2.Start(hostConfig); err != nil {
|
|
|
+ if err := container2.Start(); err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
container2.Wait()
|
|
@@ -283,7 +283,7 @@ func TestCommitRun(t *testing.T) {
|
|
|
runtime := mkRuntime(t)
|
|
|
defer nuke(runtime)
|
|
|
|
|
|
- container1, hostConfig, _ := mkContainer(runtime, []string{"_", "/bin/sh", "-c", "echo hello > /world"}, t)
|
|
|
+ container1, _ := mkContainer(runtime, []string{"_", "/bin/sh", "-c", "echo hello > /world"}, t)
|
|
|
defer runtime.Destroy(container1)
|
|
|
|
|
|
if container1.State.Running {
|
|
@@ -306,7 +306,7 @@ func TestCommitRun(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
// FIXME: Make a TestCommit that stops here and check docker.root/layers/img.id/world
|
|
|
- container2, hostConfig, _ := mkContainer(runtime, []string{img.ID, "cat", "/world"}, t)
|
|
|
+ container2, _ := mkContainer(runtime, []string{img.ID, "cat", "/world"}, t)
|
|
|
defer runtime.Destroy(container2)
|
|
|
stdout, err := container2.StdoutPipe()
|
|
|
if err != nil {
|
|
@@ -316,7 +316,7 @@ func TestCommitRun(t *testing.T) {
|
|
|
if err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
- if err := container2.Start(hostConfig); err != nil {
|
|
|
+ if err := container2.Start(); err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
container2.Wait()
|
|
@@ -342,7 +342,7 @@ func TestCommitRun(t *testing.T) {
|
|
|
func TestStart(t *testing.T) {
|
|
|
runtime := mkRuntime(t)
|
|
|
defer nuke(runtime)
|
|
|
- container, hostConfig, _ := mkContainer(runtime, []string{"-m", "33554432", "-c", "1000", "-i", "_", "/bin/cat"}, t)
|
|
|
+ container, _ := mkContainer(runtime, []string{"-m", "33554432", "-c", "1000", "-i", "_", "/bin/cat"}, t)
|
|
|
defer runtime.Destroy(container)
|
|
|
|
|
|
cStdin, err := container.StdinPipe()
|
|
@@ -350,7 +350,7 @@ func TestStart(t *testing.T) {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
|
|
|
- if err := container.Start(hostConfig); err != nil {
|
|
|
+ if err := container.Start(); err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
|
|
@@ -360,7 +360,7 @@ func TestStart(t *testing.T) {
|
|
|
if !container.State.Running {
|
|
|
t.Errorf("Container should be running")
|
|
|
}
|
|
|
- if err := container.Start(hostConfig); err == nil {
|
|
|
+ if err := container.Start(); err == nil {
|
|
|
t.Fatalf("A running container should be able to be started")
|
|
|
}
|
|
|
|
|
@@ -372,7 +372,7 @@ func TestStart(t *testing.T) {
|
|
|
func TestRun(t *testing.T) {
|
|
|
runtime := mkRuntime(t)
|
|
|
defer nuke(runtime)
|
|
|
- container, _, _ := mkContainer(runtime, []string{"_", "ls", "-al"}, t)
|
|
|
+ container, _ := mkContainer(runtime, []string{"_", "ls", "-al"}, t)
|
|
|
defer runtime.Destroy(container)
|
|
|
|
|
|
if container.State.Running {
|
|
@@ -452,7 +452,7 @@ func TestKillDifferentUser(t *testing.T) {
|
|
|
if container.State.Running {
|
|
|
t.Errorf("Container shouldn't be running")
|
|
|
}
|
|
|
- if err := container.Start(&HostConfig{}); err != nil {
|
|
|
+ if err := container.Start(); err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
|
|
@@ -501,7 +501,8 @@ func TestCreateVolume(t *testing.T) {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
defer runtime.Destroy(c)
|
|
|
- if err := c.Start(hc); err != nil {
|
|
|
+ c.hostConfig = hc
|
|
|
+ if err := c.Start(); err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
c.WaitTimeout(500 * time.Millisecond)
|
|
@@ -525,8 +526,7 @@ func TestKill(t *testing.T) {
|
|
|
if container.State.Running {
|
|
|
t.Errorf("Container shouldn't be running")
|
|
|
}
|
|
|
- hostConfig := &HostConfig{}
|
|
|
- if err := container.Start(hostConfig); err != nil {
|
|
|
+ if err := container.Start(); err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
|
|
@@ -642,8 +642,7 @@ func TestRestartStdin(t *testing.T) {
|
|
|
if err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
- hostConfig := &HostConfig{}
|
|
|
- if err := container.Start(hostConfig); err != nil {
|
|
|
+ if err := container.Start(); err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
if _, err := io.WriteString(stdin, "hello world"); err != nil {
|
|
@@ -673,7 +672,7 @@ func TestRestartStdin(t *testing.T) {
|
|
|
if err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
- if err := container.Start(hostConfig); err != nil {
|
|
|
+ if err := container.Start(); err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
if _, err := io.WriteString(stdin, "hello world #2"); err != nil {
|
|
@@ -850,11 +849,10 @@ func TestMultipleContainers(t *testing.T) {
|
|
|
defer runtime.Destroy(container2)
|
|
|
|
|
|
// Start both containers
|
|
|
- hostConfig := &HostConfig{}
|
|
|
- if err := container1.Start(hostConfig); err != nil {
|
|
|
+ if err := container1.Start(); err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
- if err := container2.Start(hostConfig); err != nil {
|
|
|
+ if err := container2.Start(); err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
|
|
@@ -904,8 +902,7 @@ func TestStdin(t *testing.T) {
|
|
|
if err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
- hostConfig := &HostConfig{}
|
|
|
- if err := container.Start(hostConfig); err != nil {
|
|
|
+ if err := container.Start(); err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
defer stdin.Close()
|
|
@@ -950,8 +947,7 @@ func TestTty(t *testing.T) {
|
|
|
if err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
- hostConfig := &HostConfig{}
|
|
|
- if err := container.Start(hostConfig); err != nil {
|
|
|
+ if err := container.Start(); err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
defer stdin.Close()
|
|
@@ -992,8 +988,7 @@ func TestEnv(t *testing.T) {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
defer stdout.Close()
|
|
|
- hostConfig := &HostConfig{}
|
|
|
- if err := container.Start(hostConfig); err != nil {
|
|
|
+ if err := container.Start(); err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
container.Wait()
|
|
@@ -1121,7 +1116,7 @@ func TestLXCConfig(t *testing.T) {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
defer runtime.Destroy(container)
|
|
|
- container.generateLXCConfig(nil)
|
|
|
+ container.generateLXCConfig()
|
|
|
grepFile(t, container.lxcConfigPath(), "lxc.utsname = foobar")
|
|
|
grepFile(t, container.lxcConfigPath(),
|
|
|
fmt.Sprintf("lxc.cgroup.memory.limit_in_bytes = %d", mem))
|
|
@@ -1144,7 +1139,7 @@ func TestCustomLxcConfig(t *testing.T) {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
defer runtime.Destroy(container)
|
|
|
- hostConfig := &HostConfig{LxcConf: []KeyValuePair{
|
|
|
+ container.hostConfig = &HostConfig{LxcConf: []KeyValuePair{
|
|
|
{
|
|
|
Key: "lxc.utsname",
|
|
|
Value: "docker",
|
|
@@ -1155,7 +1150,7 @@ func TestCustomLxcConfig(t *testing.T) {
|
|
|
},
|
|
|
}}
|
|
|
|
|
|
- container.generateLXCConfig(hostConfig)
|
|
|
+ container.generateLXCConfig()
|
|
|
grepFile(t, container.lxcConfigPath(), "lxc.utsname = docker")
|
|
|
grepFile(t, container.lxcConfigPath(), "lxc.cgroup.cpuset.cpus = 0,1")
|
|
|
}
|
|
@@ -1208,8 +1203,7 @@ func BenchmarkRunParallel(b *testing.B) {
|
|
|
return
|
|
|
}
|
|
|
defer runtime.Destroy(container)
|
|
|
- hostConfig := &HostConfig{}
|
|
|
- if err := container.Start(hostConfig); err != nil {
|
|
|
+ if err := container.Start(); err != nil {
|
|
|
complete <- err
|
|
|
return
|
|
|
}
|
|
@@ -1253,7 +1247,7 @@ func TestCopyVolumeUidGid(t *testing.T) {
|
|
|
defer nuke(r)
|
|
|
|
|
|
// Add directory not owned by root
|
|
|
- container1, _, _ := mkContainer(r, []string{"_", "/bin/sh", "-c", "mkdir -p /hello && touch /hello/test.txt && chown daemon.daemon /hello"}, t)
|
|
|
+ container1, _ := mkContainer(r, []string{"_", "/bin/sh", "-c", "mkdir -p /hello && touch /hello/test.txt && chown daemon.daemon /hello"}, t)
|
|
|
defer r.Destroy(container1)
|
|
|
|
|
|
if container1.State.Running {
|
|
@@ -1290,7 +1284,7 @@ func TestCopyVolumeContent(t *testing.T) {
|
|
|
defer nuke(r)
|
|
|
|
|
|
// Put some content in a directory of a container and commit it
|
|
|
- container1, _, _ := mkContainer(r, []string{"_", "/bin/sh", "-c", "mkdir -p /hello/local && echo hello > /hello/local/world"}, t)
|
|
|
+ container1, _ := mkContainer(r, []string{"_", "/bin/sh", "-c", "mkdir -p /hello/local && echo hello > /hello/local/world"}, t)
|
|
|
defer r.Destroy(container1)
|
|
|
|
|
|
if container1.State.Running {
|
|
@@ -1527,9 +1521,9 @@ func TestOnlyLoopbackExistsWhenUsingDisableNetworkOption(t *testing.T) {
|
|
|
if err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
-
|
|
|
defer runtime.Destroy(c)
|
|
|
- if err := c.Start(hc); err != nil {
|
|
|
+ c.hostConfig = hc
|
|
|
+ if err := c.Start(); err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
c.WaitTimeout(500 * time.Millisecond)
|