|
@@ -18,7 +18,7 @@ import (
|
|
func TestIDFormat(t *testing.T) {
|
|
func TestIDFormat(t *testing.T) {
|
|
runtime := mkRuntime(t)
|
|
runtime := mkRuntime(t)
|
|
defer nuke(runtime)
|
|
defer nuke(runtime)
|
|
- container1, err := NewBuilder(runtime).Create(
|
|
|
|
|
|
+ container1, err := runtime.Create(
|
|
&Config{
|
|
&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"/bin/sh", "-c", "echo hello world"},
|
|
Cmd: []string{"/bin/sh", "-c", "echo hello world"},
|
|
@@ -388,7 +388,7 @@ func TestRun(t *testing.T) {
|
|
func TestOutput(t *testing.T) {
|
|
func TestOutput(t *testing.T) {
|
|
runtime := mkRuntime(t)
|
|
runtime := mkRuntime(t)
|
|
defer nuke(runtime)
|
|
defer nuke(runtime)
|
|
- container, err := NewBuilder(runtime).Create(
|
|
|
|
|
|
+ container, err := runtime.Create(
|
|
&Config{
|
|
&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"echo", "-n", "foobar"},
|
|
Cmd: []string{"echo", "-n", "foobar"},
|
|
@@ -411,7 +411,7 @@ func TestKillDifferentUser(t *testing.T) {
|
|
runtime := mkRuntime(t)
|
|
runtime := mkRuntime(t)
|
|
defer nuke(runtime)
|
|
defer nuke(runtime)
|
|
|
|
|
|
- container, err := NewBuilder(runtime).Create(&Config{
|
|
|
|
|
|
+ container, err := runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"cat"},
|
|
Cmd: []string{"cat"},
|
|
OpenStdin: true,
|
|
OpenStdin: true,
|
|
@@ -471,7 +471,7 @@ func TestCreateVolume(t *testing.T) {
|
|
if err != nil {
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
- c, err := NewBuilder(runtime).Create(config)
|
|
|
|
|
|
+ c, err := runtime.Create(config)
|
|
if err != nil {
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
@@ -486,7 +486,7 @@ func TestCreateVolume(t *testing.T) {
|
|
func TestKill(t *testing.T) {
|
|
func TestKill(t *testing.T) {
|
|
runtime := mkRuntime(t)
|
|
runtime := mkRuntime(t)
|
|
defer nuke(runtime)
|
|
defer nuke(runtime)
|
|
- container, err := NewBuilder(runtime).Create(&Config{
|
|
|
|
|
|
+ container, err := runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"sleep", "2"},
|
|
Cmd: []string{"sleep", "2"},
|
|
},
|
|
},
|
|
@@ -530,9 +530,7 @@ func TestExitCode(t *testing.T) {
|
|
runtime := mkRuntime(t)
|
|
runtime := mkRuntime(t)
|
|
defer nuke(runtime)
|
|
defer nuke(runtime)
|
|
|
|
|
|
- builder := NewBuilder(runtime)
|
|
|
|
-
|
|
|
|
- trueContainer, err := builder.Create(&Config{
|
|
|
|
|
|
+ trueContainer, err := runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"/bin/true", ""},
|
|
Cmd: []string{"/bin/true", ""},
|
|
})
|
|
})
|
|
@@ -547,7 +545,7 @@ func TestExitCode(t *testing.T) {
|
|
t.Errorf("Unexpected exit code %d (expected 0)", trueContainer.State.ExitCode)
|
|
t.Errorf("Unexpected exit code %d (expected 0)", trueContainer.State.ExitCode)
|
|
}
|
|
}
|
|
|
|
|
|
- falseContainer, err := builder.Create(&Config{
|
|
|
|
|
|
+ falseContainer, err := runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"/bin/false", ""},
|
|
Cmd: []string{"/bin/false", ""},
|
|
})
|
|
})
|
|
@@ -566,7 +564,7 @@ func TestExitCode(t *testing.T) {
|
|
func TestRestart(t *testing.T) {
|
|
func TestRestart(t *testing.T) {
|
|
runtime := mkRuntime(t)
|
|
runtime := mkRuntime(t)
|
|
defer nuke(runtime)
|
|
defer nuke(runtime)
|
|
- container, err := NewBuilder(runtime).Create(&Config{
|
|
|
|
|
|
+ container, err := runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"echo", "-n", "foobar"},
|
|
Cmd: []string{"echo", "-n", "foobar"},
|
|
},
|
|
},
|
|
@@ -596,7 +594,7 @@ func TestRestart(t *testing.T) {
|
|
func TestRestartStdin(t *testing.T) {
|
|
func TestRestartStdin(t *testing.T) {
|
|
runtime := mkRuntime(t)
|
|
runtime := mkRuntime(t)
|
|
defer nuke(runtime)
|
|
defer nuke(runtime)
|
|
- container, err := NewBuilder(runtime).Create(&Config{
|
|
|
|
|
|
+ container, err := runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"cat"},
|
|
Cmd: []string{"cat"},
|
|
|
|
|
|
@@ -673,10 +671,8 @@ func TestUser(t *testing.T) {
|
|
runtime := mkRuntime(t)
|
|
runtime := mkRuntime(t)
|
|
defer nuke(runtime)
|
|
defer nuke(runtime)
|
|
|
|
|
|
- builder := NewBuilder(runtime)
|
|
|
|
-
|
|
|
|
// Default user must be root
|
|
// Default user must be root
|
|
- container, err := builder.Create(&Config{
|
|
|
|
|
|
+ container, err := runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"id"},
|
|
Cmd: []string{"id"},
|
|
},
|
|
},
|
|
@@ -694,7 +690,7 @@ func TestUser(t *testing.T) {
|
|
}
|
|
}
|
|
|
|
|
|
// Set a username
|
|
// Set a username
|
|
- container, err = builder.Create(&Config{
|
|
|
|
|
|
+ container, err = runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"id"},
|
|
Cmd: []string{"id"},
|
|
|
|
|
|
@@ -714,7 +710,7 @@ func TestUser(t *testing.T) {
|
|
}
|
|
}
|
|
|
|
|
|
// Set a UID
|
|
// Set a UID
|
|
- container, err = builder.Create(&Config{
|
|
|
|
|
|
+ container, err = runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"id"},
|
|
Cmd: []string{"id"},
|
|
|
|
|
|
@@ -734,7 +730,7 @@ func TestUser(t *testing.T) {
|
|
}
|
|
}
|
|
|
|
|
|
// Set a different user by uid
|
|
// Set a different user by uid
|
|
- container, err = builder.Create(&Config{
|
|
|
|
|
|
+ container, err = runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"id"},
|
|
Cmd: []string{"id"},
|
|
|
|
|
|
@@ -756,7 +752,7 @@ func TestUser(t *testing.T) {
|
|
}
|
|
}
|
|
|
|
|
|
// Set a different user by username
|
|
// Set a different user by username
|
|
- container, err = builder.Create(&Config{
|
|
|
|
|
|
+ container, err = runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"id"},
|
|
Cmd: []string{"id"},
|
|
|
|
|
|
@@ -776,7 +772,7 @@ func TestUser(t *testing.T) {
|
|
}
|
|
}
|
|
|
|
|
|
// Test an wrong username
|
|
// Test an wrong username
|
|
- container, err = builder.Create(&Config{
|
|
|
|
|
|
+ container, err = runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"id"},
|
|
Cmd: []string{"id"},
|
|
|
|
|
|
@@ -797,9 +793,7 @@ func TestMultipleContainers(t *testing.T) {
|
|
runtime := mkRuntime(t)
|
|
runtime := mkRuntime(t)
|
|
defer nuke(runtime)
|
|
defer nuke(runtime)
|
|
|
|
|
|
- builder := NewBuilder(runtime)
|
|
|
|
-
|
|
|
|
- container1, err := builder.Create(&Config{
|
|
|
|
|
|
+ container1, err := runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"sleep", "2"},
|
|
Cmd: []string{"sleep", "2"},
|
|
},
|
|
},
|
|
@@ -809,7 +803,7 @@ func TestMultipleContainers(t *testing.T) {
|
|
}
|
|
}
|
|
defer runtime.Destroy(container1)
|
|
defer runtime.Destroy(container1)
|
|
|
|
|
|
- container2, err := builder.Create(&Config{
|
|
|
|
|
|
+ container2, err := runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"sleep", "2"},
|
|
Cmd: []string{"sleep", "2"},
|
|
},
|
|
},
|
|
@@ -853,7 +847,7 @@ func TestMultipleContainers(t *testing.T) {
|
|
func TestStdin(t *testing.T) {
|
|
func TestStdin(t *testing.T) {
|
|
runtime := mkRuntime(t)
|
|
runtime := mkRuntime(t)
|
|
defer nuke(runtime)
|
|
defer nuke(runtime)
|
|
- container, err := NewBuilder(runtime).Create(&Config{
|
|
|
|
|
|
+ container, err := runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"cat"},
|
|
Cmd: []string{"cat"},
|
|
|
|
|
|
@@ -898,7 +892,7 @@ func TestStdin(t *testing.T) {
|
|
func TestTty(t *testing.T) {
|
|
func TestTty(t *testing.T) {
|
|
runtime := mkRuntime(t)
|
|
runtime := mkRuntime(t)
|
|
defer nuke(runtime)
|
|
defer nuke(runtime)
|
|
- container, err := NewBuilder(runtime).Create(&Config{
|
|
|
|
|
|
+ container, err := runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"cat"},
|
|
Cmd: []string{"cat"},
|
|
|
|
|
|
@@ -943,7 +937,7 @@ func TestTty(t *testing.T) {
|
|
func TestEnv(t *testing.T) {
|
|
func TestEnv(t *testing.T) {
|
|
runtime := mkRuntime(t)
|
|
runtime := mkRuntime(t)
|
|
defer nuke(runtime)
|
|
defer nuke(runtime)
|
|
- container, err := NewBuilder(runtime).Create(&Config{
|
|
|
|
|
|
+ container, err := runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"env"},
|
|
Cmd: []string{"env"},
|
|
},
|
|
},
|
|
@@ -992,7 +986,7 @@ func TestEnv(t *testing.T) {
|
|
func TestEntrypoint(t *testing.T) {
|
|
func TestEntrypoint(t *testing.T) {
|
|
runtime := mkRuntime(t)
|
|
runtime := mkRuntime(t)
|
|
defer nuke(runtime)
|
|
defer nuke(runtime)
|
|
- container, err := NewBuilder(runtime).Create(
|
|
|
|
|
|
+ container, err := runtime.Create(
|
|
&Config{
|
|
&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Entrypoint: []string{"/bin/echo"},
|
|
Entrypoint: []string{"/bin/echo"},
|
|
@@ -1015,7 +1009,7 @@ func TestEntrypoint(t *testing.T) {
|
|
func TestEntrypointNoCmd(t *testing.T) {
|
|
func TestEntrypointNoCmd(t *testing.T) {
|
|
runtime := mkRuntime(t)
|
|
runtime := mkRuntime(t)
|
|
defer nuke(runtime)
|
|
defer nuke(runtime)
|
|
- container, err := NewBuilder(runtime).Create(
|
|
|
|
|
|
+ container, err := runtime.Create(
|
|
&Config{
|
|
&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Entrypoint: []string{"/bin/echo", "foobar"},
|
|
Entrypoint: []string{"/bin/echo", "foobar"},
|
|
@@ -1066,7 +1060,7 @@ func TestLXCConfig(t *testing.T) {
|
|
cpuMin := 100
|
|
cpuMin := 100
|
|
cpuMax := 10000
|
|
cpuMax := 10000
|
|
cpu := cpuMin + rand.Intn(cpuMax-cpuMin)
|
|
cpu := cpuMin + rand.Intn(cpuMax-cpuMin)
|
|
- container, err := NewBuilder(runtime).Create(&Config{
|
|
|
|
|
|
+ container, err := runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"/bin/true"},
|
|
Cmd: []string{"/bin/true"},
|
|
|
|
|
|
@@ -1090,7 +1084,7 @@ func TestLXCConfig(t *testing.T) {
|
|
func TestCustomLxcConfig(t *testing.T) {
|
|
func TestCustomLxcConfig(t *testing.T) {
|
|
runtime := mkRuntime(t)
|
|
runtime := mkRuntime(t)
|
|
defer nuke(runtime)
|
|
defer nuke(runtime)
|
|
- container, err := NewBuilder(runtime).Create(&Config{
|
|
|
|
|
|
+ container, err := runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"/bin/true"},
|
|
Cmd: []string{"/bin/true"},
|
|
|
|
|
|
@@ -1121,7 +1115,7 @@ func BenchmarkRunSequencial(b *testing.B) {
|
|
runtime := mkRuntime(b)
|
|
runtime := mkRuntime(b)
|
|
defer nuke(runtime)
|
|
defer nuke(runtime)
|
|
for i := 0; i < b.N; i++ {
|
|
for i := 0; i < b.N; i++ {
|
|
- container, err := NewBuilder(runtime).Create(&Config{
|
|
|
|
|
|
+ container, err := runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"echo", "-n", "foo"},
|
|
Cmd: []string{"echo", "-n", "foo"},
|
|
},
|
|
},
|
|
@@ -1153,7 +1147,7 @@ func BenchmarkRunParallel(b *testing.B) {
|
|
complete := make(chan error)
|
|
complete := make(chan error)
|
|
tasks = append(tasks, complete)
|
|
tasks = append(tasks, complete)
|
|
go func(i int, complete chan error) {
|
|
go func(i int, complete chan error) {
|
|
- container, err := NewBuilder(runtime).Create(&Config{
|
|
|
|
|
|
+ container, err := runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"echo", "-n", "foo"},
|
|
Cmd: []string{"echo", "-n", "foo"},
|
|
},
|
|
},
|
|
@@ -1229,7 +1223,7 @@ func TestBindMounts(t *testing.T) {
|
|
func TestVolumesFromReadonlyMount(t *testing.T) {
|
|
func TestVolumesFromReadonlyMount(t *testing.T) {
|
|
runtime := mkRuntime(t)
|
|
runtime := mkRuntime(t)
|
|
defer nuke(runtime)
|
|
defer nuke(runtime)
|
|
- container, err := NewBuilder(runtime).Create(
|
|
|
|
|
|
+ container, err := runtime.Create(
|
|
&Config{
|
|
&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"/bin/echo", "-n", "foobar"},
|
|
Cmd: []string{"/bin/echo", "-n", "foobar"},
|
|
@@ -1248,7 +1242,7 @@ func TestVolumesFromReadonlyMount(t *testing.T) {
|
|
t.Fail()
|
|
t.Fail()
|
|
}
|
|
}
|
|
|
|
|
|
- container2, err := NewBuilder(runtime).Create(
|
|
|
|
|
|
+ container2, err := runtime.Create(
|
|
&Config{
|
|
&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"/bin/echo", "-n", "foobar"},
|
|
Cmd: []string{"/bin/echo", "-n", "foobar"},
|
|
@@ -1284,7 +1278,7 @@ func TestRestartWithVolumes(t *testing.T) {
|
|
runtime := mkRuntime(t)
|
|
runtime := mkRuntime(t)
|
|
defer nuke(runtime)
|
|
defer nuke(runtime)
|
|
|
|
|
|
- container, err := NewBuilder(runtime).Create(&Config{
|
|
|
|
|
|
+ container, err := runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"echo", "-n", "foobar"},
|
|
Cmd: []string{"echo", "-n", "foobar"},
|
|
Volumes: map[string]struct{}{"/test": {}},
|
|
Volumes: map[string]struct{}{"/test": {}},
|
|
@@ -1327,7 +1321,7 @@ func TestVolumesFromWithVolumes(t *testing.T) {
|
|
runtime := mkRuntime(t)
|
|
runtime := mkRuntime(t)
|
|
defer nuke(runtime)
|
|
defer nuke(runtime)
|
|
|
|
|
|
- container, err := NewBuilder(runtime).Create(&Config{
|
|
|
|
|
|
+ container, err := runtime.Create(&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"sh", "-c", "echo -n bar > /test/foo"},
|
|
Cmd: []string{"sh", "-c", "echo -n bar > /test/foo"},
|
|
Volumes: map[string]struct{}{"/test": {}},
|
|
Volumes: map[string]struct{}{"/test": {}},
|
|
@@ -1354,7 +1348,7 @@ func TestVolumesFromWithVolumes(t *testing.T) {
|
|
t.Fail()
|
|
t.Fail()
|
|
}
|
|
}
|
|
|
|
|
|
- container2, err := NewBuilder(runtime).Create(
|
|
|
|
|
|
+ container2, err := runtime.Create(
|
|
&Config{
|
|
&Config{
|
|
Image: GetTestImage(runtime).ID,
|
|
Image: GetTestImage(runtime).ID,
|
|
Cmd: []string{"cat", "/test/foo"},
|
|
Cmd: []string{"cat", "/test/foo"},
|
|
@@ -1395,7 +1389,7 @@ func TestOnlyLoopbackExistsWhenUsingDisableNetworkOption(t *testing.T) {
|
|
if err != nil {
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
- c, err := NewBuilder(runtime).Create(config)
|
|
|
|
|
|
+ c, err := runtime.Create(config)
|
|
if err != nil {
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
t.Fatal(err)
|
|
}
|
|
}
|