Docker-DCO-1.1-Signed-off-by: Bryan Murphy <bmurphy1976@gmail.com> (github: bmurphy1976)
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,28 @@ |
| 0 |
+FROM busybox |
|
| 1 |
+ |
|
| 2 |
+RUN echo "A" |
|
| 3 |
+RUN echo "B" |
|
| 4 |
+RUN echo "C" |
|
| 5 |
+RUN echo "D" |
|
| 6 |
+RUN echo "E" |
|
| 7 |
+RUN echo "F" |
|
| 8 |
+RUN echo "G" |
|
| 9 |
+RUN echo "H" |
|
| 10 |
+RUN echo "I" |
|
| 11 |
+RUN echo "J" |
|
| 12 |
+RUN echo "K" |
|
| 13 |
+RUN echo "L" |
|
| 14 |
+RUN echo "M" |
|
| 15 |
+RUN echo "N" |
|
| 16 |
+RUN echo "O" |
|
| 17 |
+RUN echo "P" |
|
| 18 |
+RUN echo "Q" |
|
| 19 |
+RUN echo "R" |
|
| 20 |
+RUN echo "S" |
|
| 21 |
+RUN echo "T" |
|
| 22 |
+RUN echo "U" |
|
| 23 |
+RUN echo "V" |
|
| 24 |
+RUN echo "W" |
|
| 25 |
+RUN echo "X" |
|
| 26 |
+RUN echo "Y" |
|
| 27 |
+RUN echo "Z" |
| 0 | 28 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,43 @@ |
| 0 |
+package main |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "fmt" |
|
| 4 |
+ "os/exec" |
|
| 5 |
+ "path/filepath" |
|
| 6 |
+ "strings" |
|
| 7 |
+ "testing" |
|
| 8 |
+) |
|
| 9 |
+ |
|
| 10 |
+// This is a heisen-test. Because the created timestamp of images and the behavior of |
|
| 11 |
+// sort is not predictable it doesn't always fail. |
|
| 12 |
+func TestBuildHistory(t *testing.T) {
|
|
| 13 |
+ buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestBuildHistory") |
|
| 14 |
+ buildCmd := exec.Command(dockerBinary, "build", "-t", "testbuildhistory", ".") |
|
| 15 |
+ |
|
| 16 |
+ buildCmd.Dir = buildDirectory |
|
| 17 |
+ out, exitCode, err := runCommandWithOutput(buildCmd) |
|
| 18 |
+ errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
|
|
| 19 |
+ if err != nil || exitCode != 0 {
|
|
| 20 |
+ t.Fatal("failed to build the image")
|
|
| 21 |
+ } |
|
| 22 |
+ |
|
| 23 |
+ out, exitCode, err = runCommandWithOutput(exec.Command(dockerBinary, "history", "testbuildhistory")) |
|
| 24 |
+ errorOut(err, t, fmt.Sprintf("image history failed: %v %v", out, err))
|
|
| 25 |
+ if err != nil || exitCode != 0 {
|
|
| 26 |
+ t.Fatal("failed to get image history")
|
|
| 27 |
+ } |
|
| 28 |
+ |
|
| 29 |
+ actual_values := strings.Split(out, "\n")[1:27] |
|
| 30 |
+ expected_values := [26]string{"Z", "Y", "X", "W", "V", "U", "T", "S", "R", "Q", "P", "O", "N", "M", "L", "K", "J", "I", "H", "G", "F", "E", "D", "C", "B", "A"}
|
|
| 31 |
+ |
|
| 32 |
+ for i := 0; i < 26; i++ {
|
|
| 33 |
+ echo_value := fmt.Sprintf("echo \"%s\"", expected_values[i])
|
|
| 34 |
+ actual_value := actual_values[i] |
|
| 35 |
+ |
|
| 36 |
+ if !strings.Contains(actual_value, echo_value) {
|
|
| 37 |
+ t.Fatalf("Expected layer \"%s\", but was: %s", expected_values[i], actual_value)
|
|
| 38 |
+ } |
|
| 39 |
+ } |
|
| 40 |
+ |
|
| 41 |
+ deleteImages("testbuildhistory")
|
|
| 42 |
+} |