- Fix TestGetImagesJSON when there is more than one image in the test
repository;
- Remove an hardcoded constant use in TestGetImagesByName;
- Wait in a loop in TestKillDifferentUser;
- Use env instead of /usr/bin/env in TestEnv;
- Create a daemon user in contrib/mkimage-unittest.sh.
... | ... |
@@ -142,12 +142,13 @@ func TestGetImagesJSON(t *testing.T) { |
142 | 142 |
|
143 | 143 |
srv := &Server{runtime: runtime} |
144 | 144 |
|
145 |
- initialImages, err := srv.Images(true, "") |
|
145 |
+ // all=0 |
|
146 |
+ |
|
147 |
+ initialImages, err := srv.Images(false, "") |
|
146 | 148 |
if err != nil { |
147 | 149 |
t.Fatal(err) |
148 | 150 |
} |
149 | 151 |
|
150 |
- // all=0 |
|
151 | 152 |
req, err := http.NewRequest("GET", "/images/json?all=0", nil) |
152 | 153 |
if err != nil { |
153 | 154 |
t.Fatal(err) |
... | ... |
@@ -182,6 +183,12 @@ func TestGetImagesJSON(t *testing.T) { |
182 | 182 |
r2 := httptest.NewRecorder() |
183 | 183 |
|
184 | 184 |
// all=1 |
185 |
+ |
|
186 |
+ initialImages, err = srv.Images(true, "") |
|
187 |
+ if err != nil { |
|
188 |
+ t.Fatal(err) |
|
189 |
+ } |
|
190 |
+ |
|
185 | 191 |
req2, err := http.NewRequest("GET", "/images/json?all=true", nil) |
186 | 192 |
if err != nil { |
187 | 193 |
t.Fatal(err) |
... | ... |
@@ -352,7 +359,7 @@ func TestGetImagesByName(t *testing.T) { |
352 | 352 |
if err := json.Unmarshal(r.Body.Bytes(), img); err != nil { |
353 | 353 |
t.Fatal(err) |
354 | 354 |
} |
355 |
- if img.ID != GetTestImage(runtime).ID || img.Comment != "Imported from http://get.docker.io/images/busybox" { |
|
355 |
+ if img.ID != unitTestImageId { |
|
356 | 356 |
t.Errorf("Error inspecting image") |
357 | 357 |
} |
358 | 358 |
} |
... | ... |
@@ -511,12 +511,11 @@ func TestKillDifferentUser(t *testing.T) { |
511 | 511 |
t.Fatal(err) |
512 | 512 |
} |
513 | 513 |
|
514 |
- // Give some time to lxc to spawn the process (setuid might take some time) |
|
515 |
- container.WaitTimeout(500 * time.Millisecond) |
|
516 |
- |
|
517 |
- if !container.State.Running { |
|
518 |
- t.Errorf("Container should be running") |
|
519 |
- } |
|
514 |
+ setTimeout(t, "Waiting for the container to be started timed out", 2 * time.Second, func() { |
|
515 |
+ for !container.State.Running { |
|
516 |
+ time.Sleep(10 * time.Millisecond) |
|
517 |
+ } |
|
518 |
+ }) |
|
520 | 519 |
|
521 | 520 |
if err := container.Kill(); err != nil { |
522 | 521 |
t.Fatal(err) |
... | ... |
@@ -1001,7 +1000,7 @@ func TestEnv(t *testing.T) { |
1001 | 1001 |
defer nuke(runtime) |
1002 | 1002 |
container, err := NewBuilder(runtime).Create(&Config{ |
1003 | 1003 |
Image: GetTestImage(runtime).ID, |
1004 |
- Cmd: []string{"/usr/bin/env"}, |
|
1004 |
+ Cmd: []string{"env"}, |
|
1005 | 1005 |
}, |
1006 | 1006 |
) |
1007 | 1007 |
if err != nil { |
... | ... |
@@ -23,7 +23,9 @@ mkdir bin etc dev dev/pts lib proc sys tmp |
23 | 23 |
touch etc/resolv.conf |
24 | 24 |
cp /etc/nsswitch.conf etc/nsswitch.conf |
25 | 25 |
echo root:x:0:0:root:/:/bin/sh > etc/passwd |
26 |
+echo daemon:x:1:1:daemon:/usr/sbin:/bin/sh >> etc/passwd |
|
26 | 27 |
echo root:x:0: > etc/group |
28 |
+echo daemon:x:1: >> etc/group |
|
27 | 29 |
ln -s lib lib64 |
28 | 30 |
ln -s bin sbin |
29 | 31 |
cp $BUSYBOX $SOCAT bin |
... | ... |
@@ -41,6 +43,7 @@ do |
41 | 41 |
cp -a /dev/$X dev |
42 | 42 |
done |
43 | 43 |
|
44 |
+chmod 0755 $ROOTFS # See #486 |
|
44 | 45 |
tar -cf- . | docker import - docker-ut |
45 | 46 |
docker run -i -u root docker-ut /bin/echo Success. |
46 | 47 |
rm -rf $ROOTFS |