Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
Alexandr Morozov authored on 2014/06/17 15:50:51... | ... |
@@ -1215,3 +1215,44 @@ func TestBuildADDFileNotFound(t *testing.T) { |
1215 | 1215 |
} |
1216 | 1216 |
logDone("build - add file not found") |
1217 | 1217 |
} |
1218 |
+ |
|
1219 |
+func TestBuildInheritance(t *testing.T) { |
|
1220 |
+ name := "testbuildinheritance" |
|
1221 |
+ defer deleteImages(name) |
|
1222 |
+ |
|
1223 |
+ _, err := buildImage(name, |
|
1224 |
+ `FROM scratch |
|
1225 |
+ EXPOSE 2375`, |
|
1226 |
+ true) |
|
1227 |
+ if err != nil { |
|
1228 |
+ t.Fatal(err) |
|
1229 |
+ } |
|
1230 |
+ ports1, err := inspectField(name, "Config.ExposedPorts") |
|
1231 |
+ if err != nil { |
|
1232 |
+ t.Fatal(err) |
|
1233 |
+ } |
|
1234 |
+ |
|
1235 |
+ _, err = buildImage(name, |
|
1236 |
+ fmt.Sprintf(`FROM %s |
|
1237 |
+ ENTRYPOINT ["/bin/echo"]`, name), |
|
1238 |
+ true) |
|
1239 |
+ if err != nil { |
|
1240 |
+ t.Fatal(err) |
|
1241 |
+ } |
|
1242 |
+ |
|
1243 |
+ res, err := inspectField(name, "Config.Entrypoint") |
|
1244 |
+ if err != nil { |
|
1245 |
+ t.Fatal(err) |
|
1246 |
+ } |
|
1247 |
+ if expected := "[/bin/echo]"; res != expected { |
|
1248 |
+ t.Fatalf("Entrypoint %s, expected %s", res, expected) |
|
1249 |
+ } |
|
1250 |
+ ports2, err := inspectField(name, "Config.ExposedPorts") |
|
1251 |
+ if err != nil { |
|
1252 |
+ t.Fatal(err) |
|
1253 |
+ } |
|
1254 |
+ if ports1 != ports2 { |
|
1255 |
+ t.Fatalf("Ports must be same: %s != %s", ports1, ports2) |
|
1256 |
+ } |
|
1257 |
+ logDone("build - inheritance") |
|
1258 |
+} |
... | ... |
@@ -14,7 +14,6 @@ import ( |
14 | 14 |
"github.com/dotcloud/docker/archive" |
15 | 15 |
"github.com/dotcloud/docker/engine" |
16 | 16 |
"github.com/dotcloud/docker/image" |
17 |
- "github.com/dotcloud/docker/nat" |
|
18 | 17 |
"github.com/dotcloud/docker/server" |
19 | 18 |
"github.com/dotcloud/docker/utils" |
20 | 19 |
) |
... | ... |
@@ -414,41 +413,6 @@ func buildImage(context testContextTemplate, t *testing.T, eng *engine.Engine, u |
414 | 414 |
return image, err |
415 | 415 |
} |
416 | 416 |
|
417 |
-func TestBuildInheritance(t *testing.T) { |
|
418 |
- eng := NewTestEngine(t) |
|
419 |
- defer nuke(mkDaemonFromEngine(eng, t)) |
|
420 |
- |
|
421 |
- img, err := buildImage(testContextTemplate{` |
|
422 |
- from {IMAGE} |
|
423 |
- expose 2375 |
|
424 |
- `, |
|
425 |
- nil, nil}, t, eng, true) |
|
426 |
- |
|
427 |
- if err != nil { |
|
428 |
- t.Fatal(err) |
|
429 |
- } |
|
430 |
- |
|
431 |
- img2, _ := buildImage(testContextTemplate{fmt.Sprintf(` |
|
432 |
- from %s |
|
433 |
- entrypoint ["/bin/echo"] |
|
434 |
- `, img.ID), |
|
435 |
- nil, nil}, t, eng, true) |
|
436 |
- |
|
437 |
- if err != nil { |
|
438 |
- t.Fatal(err) |
|
439 |
- } |
|
440 |
- |
|
441 |
- // from child |
|
442 |
- if img2.Config.Entrypoint[0] != "/bin/echo" { |
|
443 |
- t.Fail() |
|
444 |
- } |
|
445 |
- |
|
446 |
- // from parent |
|
447 |
- if _, exists := img.Config.ExposedPorts[nat.NewPort("tcp", "2375")]; !exists { |
|
448 |
- t.Fail() |
|
449 |
- } |
|
450 |
-} |
|
451 |
- |
|
452 | 417 |
func TestBuildFails(t *testing.T) { |
453 | 418 |
_, err := buildImage(testContextTemplate{` |
454 | 419 |
from {IMAGE} |