| ... | ... |
@@ -339,7 +339,7 @@ func TestAttachDisconnect(t *testing.T) {
|
| 339 | 339 |
|
| 340 | 340 |
srv := &Server{runtime: runtime}
|
| 341 | 341 |
|
| 342 |
- container, err := runtime.Create( |
|
| 342 |
+ container, err := NewBuilder(runtime).Create( |
|
| 343 | 343 |
&Config{
|
| 344 | 344 |
Image: GetTestImage(runtime).Id, |
| 345 | 345 |
Memory: 33554432, |
| ... | ... |
@@ -20,7 +20,7 @@ func TestIdFormat(t *testing.T) {
|
| 20 | 20 |
t.Fatal(err) |
| 21 | 21 |
} |
| 22 | 22 |
defer nuke(runtime) |
| 23 |
- container1, err := runtime.Create( |
|
| 23 |
+ container1, err := NewBuilder(runtime).Create( |
|
| 24 | 24 |
&Config{
|
| 25 | 25 |
Image: GetTestImage(runtime).Id, |
| 26 | 26 |
Cmd: []string{"/bin/sh", "-c", "echo hello world"},
|
| ... | ... |
@@ -45,7 +45,7 @@ func TestMultipleAttachRestart(t *testing.T) {
|
| 45 | 45 |
t.Fatal(err) |
| 46 | 46 |
} |
| 47 | 47 |
defer nuke(runtime) |
| 48 |
- container, err := runtime.Create( |
|
| 48 |
+ container, err := NewBuilder(runtime).Create( |
|
| 49 | 49 |
&Config{
|
| 50 | 50 |
Image: GetTestImage(runtime).Id, |
| 51 | 51 |
Cmd: []string{"/bin/sh", "-c",
|
| ... | ... |
@@ -157,8 +157,10 @@ func TestDiff(t *testing.T) {
|
| 157 | 157 |
} |
| 158 | 158 |
defer nuke(runtime) |
| 159 | 159 |
|
| 160 |
+ builder := NewBuilder(runtime) |
|
| 161 |
+ |
|
| 160 | 162 |
// Create a container and remove a file |
| 161 |
- container1, err := runtime.Create( |
|
| 163 |
+ container1, err := builder.Create( |
|
| 162 | 164 |
&Config{
|
| 163 | 165 |
Image: GetTestImage(runtime).Id, |
| 164 | 166 |
Cmd: []string{"/bin/rm", "/etc/passwd"},
|
| ... | ... |
@@ -199,7 +201,7 @@ func TestDiff(t *testing.T) {
|
| 199 | 199 |
} |
| 200 | 200 |
|
| 201 | 201 |
// Create a new container from the commited image |
| 202 |
- container2, err := runtime.Create( |
|
| 202 |
+ container2, err := builder.Create( |
|
| 203 | 203 |
&Config{
|
| 204 | 204 |
Image: img.Id, |
| 205 | 205 |
Cmd: []string{"cat", "/etc/passwd"},
|
| ... | ... |
@@ -232,7 +234,10 @@ func TestCommitRun(t *testing.T) {
|
| 232 | 232 |
t.Fatal(err) |
| 233 | 233 |
} |
| 234 | 234 |
defer nuke(runtime) |
| 235 |
- container1, err := runtime.Create( |
|
| 235 |
+ |
|
| 236 |
+ builder := NewBuilder(runtime) |
|
| 237 |
+ |
|
| 238 |
+ container1, err := builder.Create( |
|
| 236 | 239 |
&Config{
|
| 237 | 240 |
Image: GetTestImage(runtime).Id, |
| 238 | 241 |
Cmd: []string{"/bin/sh", "-c", "echo hello > /world"},
|
| ... | ... |
@@ -265,7 +270,7 @@ func TestCommitRun(t *testing.T) {
|
| 265 | 265 |
|
| 266 | 266 |
// FIXME: Make a TestCommit that stops here and check docker.root/layers/img.id/world |
| 267 | 267 |
|
| 268 |
- container2, err := runtime.Create( |
|
| 268 |
+ container2, err := builder.Create( |
|
| 269 | 269 |
&Config{
|
| 270 | 270 |
Image: img.Id, |
| 271 | 271 |
Memory: 33554432, |
| ... | ... |
@@ -313,7 +318,7 @@ func TestStart(t *testing.T) {
|
| 313 | 313 |
t.Fatal(err) |
| 314 | 314 |
} |
| 315 | 315 |
defer nuke(runtime) |
| 316 |
- container, err := runtime.Create( |
|
| 316 |
+ container, err := NewBuilder(runtime).Create( |
|
| 317 | 317 |
&Config{
|
| 318 | 318 |
Image: GetTestImage(runtime).Id, |
| 319 | 319 |
Memory: 33554432, |
| ... | ... |
@@ -352,7 +357,7 @@ func TestRun(t *testing.T) {
|
| 352 | 352 |
t.Fatal(err) |
| 353 | 353 |
} |
| 354 | 354 |
defer nuke(runtime) |
| 355 |
- container, err := runtime.Create( |
|
| 355 |
+ container, err := NewBuilder(runtime).Create( |
|
| 356 | 356 |
&Config{
|
| 357 | 357 |
Image: GetTestImage(runtime).Id, |
| 358 | 358 |
Memory: 33554432, |
| ... | ... |
@@ -381,7 +386,7 @@ func TestOutput(t *testing.T) {
|
| 381 | 381 |
t.Fatal(err) |
| 382 | 382 |
} |
| 383 | 383 |
defer nuke(runtime) |
| 384 |
- container, err := runtime.Create( |
|
| 384 |
+ container, err := NewBuilder(runtime).Create( |
|
| 385 | 385 |
&Config{
|
| 386 | 386 |
Image: GetTestImage(runtime).Id, |
| 387 | 387 |
Cmd: []string{"echo", "-n", "foobar"},
|
| ... | ... |
@@ -406,7 +411,7 @@ func TestKillDifferentUser(t *testing.T) {
|
| 406 | 406 |
t.Fatal(err) |
| 407 | 407 |
} |
| 408 | 408 |
defer nuke(runtime) |
| 409 |
- container, err := runtime.Create(&Config{
|
|
| 409 |
+ container, err := NewBuilder(runtime).Create(&Config{
|
|
| 410 | 410 |
Image: GetTestImage(runtime).Id, |
| 411 | 411 |
Cmd: []string{"tail", "-f", "/etc/resolv.conf"},
|
| 412 | 412 |
User: "daemon", |
| ... | ... |
@@ -454,7 +459,7 @@ func TestKill(t *testing.T) {
|
| 454 | 454 |
t.Fatal(err) |
| 455 | 455 |
} |
| 456 | 456 |
defer nuke(runtime) |
| 457 |
- container, err := runtime.Create(&Config{
|
|
| 457 |
+ container, err := NewBuilder(runtime).Create(&Config{
|
|
| 458 | 458 |
Image: GetTestImage(runtime).Id, |
| 459 | 459 |
Cmd: []string{"cat", "/dev/zero"},
|
| 460 | 460 |
}, |
| ... | ... |
@@ -500,7 +505,9 @@ func TestExitCode(t *testing.T) {
|
| 500 | 500 |
} |
| 501 | 501 |
defer nuke(runtime) |
| 502 | 502 |
|
| 503 |
- trueContainer, err := runtime.Create(&Config{
|
|
| 503 |
+ builder := NewBuilder(runtime) |
|
| 504 |
+ |
|
| 505 |
+ trueContainer, err := builder.Create(&Config{
|
|
| 504 | 506 |
Image: GetTestImage(runtime).Id, |
| 505 | 507 |
Cmd: []string{"/bin/true", ""},
|
| 506 | 508 |
}) |
| ... | ... |
@@ -515,7 +522,7 @@ func TestExitCode(t *testing.T) {
|
| 515 | 515 |
t.Errorf("Unexpected exit code %d (expected 0)", trueContainer.State.ExitCode)
|
| 516 | 516 |
} |
| 517 | 517 |
|
| 518 |
- falseContainer, err := runtime.Create(&Config{
|
|
| 518 |
+ falseContainer, err := builder.Create(&Config{
|
|
| 519 | 519 |
Image: GetTestImage(runtime).Id, |
| 520 | 520 |
Cmd: []string{"/bin/false", ""},
|
| 521 | 521 |
}) |
| ... | ... |
@@ -537,7 +544,7 @@ func TestRestart(t *testing.T) {
|
| 537 | 537 |
t.Fatal(err) |
| 538 | 538 |
} |
| 539 | 539 |
defer nuke(runtime) |
| 540 |
- container, err := runtime.Create(&Config{
|
|
| 540 |
+ container, err := NewBuilder(runtime).Create(&Config{
|
|
| 541 | 541 |
Image: GetTestImage(runtime).Id, |
| 542 | 542 |
Cmd: []string{"echo", "-n", "foobar"},
|
| 543 | 543 |
}, |
| ... | ... |
@@ -570,7 +577,7 @@ func TestRestartStdin(t *testing.T) {
|
| 570 | 570 |
t.Fatal(err) |
| 571 | 571 |
} |
| 572 | 572 |
defer nuke(runtime) |
| 573 |
- container, err := runtime.Create(&Config{
|
|
| 573 |
+ container, err := NewBuilder(runtime).Create(&Config{
|
|
| 574 | 574 |
Image: GetTestImage(runtime).Id, |
| 575 | 575 |
Cmd: []string{"cat"},
|
| 576 | 576 |
|
| ... | ... |
@@ -649,8 +656,10 @@ func TestUser(t *testing.T) {
|
| 649 | 649 |
} |
| 650 | 650 |
defer nuke(runtime) |
| 651 | 651 |
|
| 652 |
+ builder := NewBuilder(runtime) |
|
| 653 |
+ |
|
| 652 | 654 |
// Default user must be root |
| 653 |
- container, err := runtime.Create(&Config{
|
|
| 655 |
+ container, err := builder.Create(&Config{
|
|
| 654 | 656 |
Image: GetTestImage(runtime).Id, |
| 655 | 657 |
Cmd: []string{"id"},
|
| 656 | 658 |
}, |
| ... | ... |
@@ -668,7 +677,7 @@ func TestUser(t *testing.T) {
|
| 668 | 668 |
} |
| 669 | 669 |
|
| 670 | 670 |
// Set a username |
| 671 |
- container, err = runtime.Create(&Config{
|
|
| 671 |
+ container, err = builder.Create(&Config{
|
|
| 672 | 672 |
Image: GetTestImage(runtime).Id, |
| 673 | 673 |
Cmd: []string{"id"},
|
| 674 | 674 |
|
| ... | ... |
@@ -688,7 +697,7 @@ func TestUser(t *testing.T) {
|
| 688 | 688 |
} |
| 689 | 689 |
|
| 690 | 690 |
// Set a UID |
| 691 |
- container, err = runtime.Create(&Config{
|
|
| 691 |
+ container, err = builder.Create(&Config{
|
|
| 692 | 692 |
Image: GetTestImage(runtime).Id, |
| 693 | 693 |
Cmd: []string{"id"},
|
| 694 | 694 |
|
| ... | ... |
@@ -708,7 +717,7 @@ func TestUser(t *testing.T) {
|
| 708 | 708 |
} |
| 709 | 709 |
|
| 710 | 710 |
// Set a different user by uid |
| 711 |
- container, err = runtime.Create(&Config{
|
|
| 711 |
+ container, err = builder.Create(&Config{
|
|
| 712 | 712 |
Image: GetTestImage(runtime).Id, |
| 713 | 713 |
Cmd: []string{"id"},
|
| 714 | 714 |
|
| ... | ... |
@@ -730,7 +739,7 @@ func TestUser(t *testing.T) {
|
| 730 | 730 |
} |
| 731 | 731 |
|
| 732 | 732 |
// Set a different user by username |
| 733 |
- container, err = runtime.Create(&Config{
|
|
| 733 |
+ container, err = builder.Create(&Config{
|
|
| 734 | 734 |
Image: GetTestImage(runtime).Id, |
| 735 | 735 |
Cmd: []string{"id"},
|
| 736 | 736 |
|
| ... | ... |
@@ -757,7 +766,9 @@ func TestMultipleContainers(t *testing.T) {
|
| 757 | 757 |
} |
| 758 | 758 |
defer nuke(runtime) |
| 759 | 759 |
|
| 760 |
- container1, err := runtime.Create(&Config{
|
|
| 760 |
+ builder := NewBuilder(runtime) |
|
| 761 |
+ |
|
| 762 |
+ container1, err := builder.Create(&Config{
|
|
| 761 | 763 |
Image: GetTestImage(runtime).Id, |
| 762 | 764 |
Cmd: []string{"cat", "/dev/zero"},
|
| 763 | 765 |
}, |
| ... | ... |
@@ -767,7 +778,7 @@ func TestMultipleContainers(t *testing.T) {
|
| 767 | 767 |
} |
| 768 | 768 |
defer runtime.Destroy(container1) |
| 769 | 769 |
|
| 770 |
- container2, err := runtime.Create(&Config{
|
|
| 770 |
+ container2, err := builder.Create(&Config{
|
|
| 771 | 771 |
Image: GetTestImage(runtime).Id, |
| 772 | 772 |
Cmd: []string{"cat", "/dev/zero"},
|
| 773 | 773 |
}, |
| ... | ... |
@@ -813,7 +824,7 @@ func TestStdin(t *testing.T) {
|
| 813 | 813 |
t.Fatal(err) |
| 814 | 814 |
} |
| 815 | 815 |
defer nuke(runtime) |
| 816 |
- container, err := runtime.Create(&Config{
|
|
| 816 |
+ container, err := NewBuilder(runtime).Create(&Config{
|
|
| 817 | 817 |
Image: GetTestImage(runtime).Id, |
| 818 | 818 |
Cmd: []string{"cat"},
|
| 819 | 819 |
|
| ... | ... |
@@ -860,7 +871,7 @@ func TestTty(t *testing.T) {
|
| 860 | 860 |
t.Fatal(err) |
| 861 | 861 |
} |
| 862 | 862 |
defer nuke(runtime) |
| 863 |
- container, err := runtime.Create(&Config{
|
|
| 863 |
+ container, err := NewBuilder(runtime).Create(&Config{
|
|
| 864 | 864 |
Image: GetTestImage(runtime).Id, |
| 865 | 865 |
Cmd: []string{"cat"},
|
| 866 | 866 |
|
| ... | ... |
@@ -907,7 +918,7 @@ func TestEnv(t *testing.T) {
|
| 907 | 907 |
t.Fatal(err) |
| 908 | 908 |
} |
| 909 | 909 |
defer nuke(runtime) |
| 910 |
- container, err := runtime.Create(&Config{
|
|
| 910 |
+ container, err := NewBuilder(runtime).Create(&Config{
|
|
| 911 | 911 |
Image: GetTestImage(runtime).Id, |
| 912 | 912 |
Cmd: []string{"/usr/bin/env"},
|
| 913 | 913 |
}, |
| ... | ... |
@@ -981,7 +992,7 @@ func TestLXCConfig(t *testing.T) {
|
| 981 | 981 |
memMin := 33554432 |
| 982 | 982 |
memMax := 536870912 |
| 983 | 983 |
mem := memMin + rand.Intn(memMax-memMin) |
| 984 |
- container, err := runtime.Create(&Config{
|
|
| 984 |
+ container, err := NewBuilder(runtime).Create(&Config{
|
|
| 985 | 985 |
Image: GetTestImage(runtime).Id, |
| 986 | 986 |
Cmd: []string{"/bin/true"},
|
| 987 | 987 |
|
| ... | ... |
@@ -1008,7 +1019,7 @@ func BenchmarkRunSequencial(b *testing.B) {
|
| 1008 | 1008 |
} |
| 1009 | 1009 |
defer nuke(runtime) |
| 1010 | 1010 |
for i := 0; i < b.N; i++ {
|
| 1011 |
- container, err := runtime.Create(&Config{
|
|
| 1011 |
+ container, err := NewBuilder(runtime).Create(&Config{
|
|
| 1012 | 1012 |
Image: GetTestImage(runtime).Id, |
| 1013 | 1013 |
Cmd: []string{"echo", "-n", "foo"},
|
| 1014 | 1014 |
}, |
| ... | ... |
@@ -1043,7 +1054,7 @@ func BenchmarkRunParallel(b *testing.B) {
|
| 1043 | 1043 |
complete := make(chan error) |
| 1044 | 1044 |
tasks = append(tasks, complete) |
| 1045 | 1045 |
go func(i int, complete chan error) {
|
| 1046 |
- container, err := runtime.Create(&Config{
|
|
| 1046 |
+ container, err := NewBuilder(runtime).Create(&Config{
|
|
| 1047 | 1047 |
Image: GetTestImage(runtime).Id, |
| 1048 | 1048 |
Cmd: []string{"echo", "-n", "foo"},
|
| 1049 | 1049 |
}, |
| ... | ... |
@@ -116,7 +116,7 @@ func TestRuntimeCreate(t *testing.T) {
|
| 116 | 116 |
if len(runtime.List()) != 0 {
|
| 117 | 117 |
t.Errorf("Expected 0 containers, %v found", len(runtime.List()))
|
| 118 | 118 |
} |
| 119 |
- container, err := runtime.Create(&Config{
|
|
| 119 |
+ container, err := NewBuilder(runtime).Create(&Config{
|
|
| 120 | 120 |
Image: GetTestImage(runtime).Id, |
| 121 | 121 |
Cmd: []string{"ls", "-al"},
|
| 122 | 122 |
}, |
| ... | ... |
@@ -163,7 +163,7 @@ func TestDestroy(t *testing.T) {
|
| 163 | 163 |
t.Fatal(err) |
| 164 | 164 |
} |
| 165 | 165 |
defer nuke(runtime) |
| 166 |
- container, err := runtime.Create(&Config{
|
|
| 166 |
+ container, err := NewBuilder(runtime).Create(&Config{
|
|
| 167 | 167 |
Image: GetTestImage(runtime).Id, |
| 168 | 168 |
Cmd: []string{"ls", "-al"},
|
| 169 | 169 |
}, |
| ... | ... |
@@ -210,7 +210,10 @@ func TestGet(t *testing.T) {
|
| 210 | 210 |
t.Fatal(err) |
| 211 | 211 |
} |
| 212 | 212 |
defer nuke(runtime) |
| 213 |
- container1, err := runtime.Create(&Config{
|
|
| 213 |
+ |
|
| 214 |
+ builder := NewBuilder(runtime) |
|
| 215 |
+ |
|
| 216 |
+ container1, err := builder.Create(&Config{
|
|
| 214 | 217 |
Image: GetTestImage(runtime).Id, |
| 215 | 218 |
Cmd: []string{"ls", "-al"},
|
| 216 | 219 |
}, |
| ... | ... |
@@ -220,7 +223,7 @@ func TestGet(t *testing.T) {
|
| 220 | 220 |
} |
| 221 | 221 |
defer runtime.Destroy(container1) |
| 222 | 222 |
|
| 223 |
- container2, err := runtime.Create(&Config{
|
|
| 223 |
+ container2, err := builder.Create(&Config{
|
|
| 224 | 224 |
Image: GetTestImage(runtime).Id, |
| 225 | 225 |
Cmd: []string{"ls", "-al"},
|
| 226 | 226 |
}, |
| ... | ... |
@@ -230,7 +233,7 @@ func TestGet(t *testing.T) {
|
| 230 | 230 |
} |
| 231 | 231 |
defer runtime.Destroy(container2) |
| 232 | 232 |
|
| 233 |
- container3, err := runtime.Create(&Config{
|
|
| 233 |
+ container3, err := builder.Create(&Config{
|
|
| 234 | 234 |
Image: GetTestImage(runtime).Id, |
| 235 | 235 |
Cmd: []string{"ls", "-al"},
|
| 236 | 236 |
}, |
| ... | ... |
@@ -260,7 +263,7 @@ func TestAllocatePortLocalhost(t *testing.T) {
|
| 260 | 260 |
if err != nil {
|
| 261 | 261 |
t.Fatal(err) |
| 262 | 262 |
} |
| 263 |
- container, err := runtime.Create(&Config{
|
|
| 263 |
+ container, err := NewBuilder(runtime).Create(&Config{
|
|
| 264 | 264 |
Image: GetTestImage(runtime).Id, |
| 265 | 265 |
Cmd: []string{"sh", "-c", "echo well hello there | nc -l -p 5555"},
|
| 266 | 266 |
PortSpecs: []string{"5555"},
|
| ... | ... |
@@ -313,8 +316,10 @@ func TestRestore(t *testing.T) {
|
| 313 | 313 |
t.Fatal(err) |
| 314 | 314 |
} |
| 315 | 315 |
|
| 316 |
+ builder := NewBuilder(runtime1) |
|
| 317 |
+ |
|
| 316 | 318 |
// Create a container with one instance of docker |
| 317 |
- container1, err := runtime1.Create(&Config{
|
|
| 319 |
+ container1, err := builder.Create(&Config{
|
|
| 318 | 320 |
Image: GetTestImage(runtime1).Id, |
| 319 | 321 |
Cmd: []string{"ls", "-al"},
|
| 320 | 322 |
}, |
| ... | ... |
@@ -325,7 +330,7 @@ func TestRestore(t *testing.T) {
|
| 325 | 325 |
defer runtime1.Destroy(container1) |
| 326 | 326 |
|
| 327 | 327 |
// Create a second container meant to be killed |
| 328 |
- container2, err := runtime1.Create(&Config{
|
|
| 328 |
+ container2, err := builder.Create(&Config{
|
|
| 329 | 329 |
Image: GetTestImage(runtime1).Id, |
| 330 | 330 |
Cmd: []string{"/bin/cat"},
|
| 331 | 331 |
OpenStdin: true, |