Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
| ... | ... |
@@ -1390,3 +1390,27 @@ func TestCopyVolumeUidGid(t *testing.T) {
|
| 1390 | 1390 |
|
| 1391 | 1391 |
logDone("run - copy uid/gid for volume")
|
| 1392 | 1392 |
} |
| 1393 |
+ |
|
| 1394 |
+// Test for #1582 |
|
| 1395 |
+func TestCopyVolumeContent(t *testing.T) {
|
|
| 1396 |
+ name := "testruncopyvolumecontent" |
|
| 1397 |
+ defer deleteImages(name) |
|
| 1398 |
+ defer deleteAllContainers() |
|
| 1399 |
+ _, err := buildImage(name, |
|
| 1400 |
+ `FROM busybox |
|
| 1401 |
+ RUN mkdir -p /hello/local && echo hello > /hello/local/world`, |
|
| 1402 |
+ true) |
|
| 1403 |
+ if err != nil {
|
|
| 1404 |
+ t.Fatal(err) |
|
| 1405 |
+ } |
|
| 1406 |
+ |
|
| 1407 |
+ // Test that the content is copied from the image to the volume |
|
| 1408 |
+ cmd := exec.Command(dockerBinary, "run", "--rm", "-v", "/hello", name, "sh", "-c", "find", "/hello") |
|
| 1409 |
+ out, _, err := runCommandWithOutput(cmd) |
|
| 1410 |
+ if err != nil {
|
|
| 1411 |
+ t.Fatal(err, out) |
|
| 1412 |
+ } |
|
| 1413 |
+ if !(strings.Contains(out, "/hello/local/world") && strings.Contains(out, "/hello/local")) {
|
|
| 1414 |
+ t.Fatal("Container failed to transfer content to volume")
|
|
| 1415 |
+ } |
|
| 1416 |
+} |
| ... | ... |
@@ -370,40 +370,6 @@ func tempDir(t *testing.T) string {
|
| 370 | 370 |
return tmpDir |
| 371 | 371 |
} |
| 372 | 372 |
|
| 373 |
-// Test for #1582 |
|
| 374 |
-func TestCopyVolumeContent(t *testing.T) {
|
|
| 375 |
- eng := NewTestEngine(t) |
|
| 376 |
- r := mkDaemonFromEngine(eng, t) |
|
| 377 |
- defer r.Nuke() |
|
| 378 |
- |
|
| 379 |
- // Put some content in a directory of a container and commit it |
|
| 380 |
- container1, _, _ := mkContainer(r, []string{"_", "/bin/sh", "-c", "mkdir -p /hello/local && echo hello > /hello/local/world"}, t)
|
|
| 381 |
- defer r.Destroy(container1) |
|
| 382 |
- |
|
| 383 |
- if container1.State.IsRunning() {
|
|
| 384 |
- t.Errorf("Container shouldn't be running")
|
|
| 385 |
- } |
|
| 386 |
- if err := container1.Run(); err != nil {
|
|
| 387 |
- t.Fatal(err) |
|
| 388 |
- } |
|
| 389 |
- if container1.State.IsRunning() {
|
|
| 390 |
- t.Errorf("Container shouldn't be running")
|
|
| 391 |
- } |
|
| 392 |
- |
|
| 393 |
- img, err := r.Commit(container1, "", "", "unit test commited image", "", true, nil) |
|
| 394 |
- if err != nil {
|
|
| 395 |
- t.Error(err) |
|
| 396 |
- } |
|
| 397 |
- |
|
| 398 |
- // Test that the content is copied from the image to the volume |
|
| 399 |
- tmpDir1 := tempDir(t) |
|
| 400 |
- defer os.RemoveAll(tmpDir1) |
|
| 401 |
- stdout1, _ := runContainer(eng, r, []string{"-v", "/hello", img.ID, "find", "/hello"}, t)
|
|
| 402 |
- if !(strings.Contains(stdout1, "/hello/local/world") && strings.Contains(stdout1, "/hello/local")) {
|
|
| 403 |
- t.Fatal("Container failed to transfer content to volume")
|
|
| 404 |
- } |
|
| 405 |
-} |
|
| 406 |
- |
|
| 407 | 373 |
func TestBindMounts(t *testing.T) {
|
| 408 | 374 |
eng := NewTestEngine(t) |
| 409 | 375 |
r := mkDaemonFromEngine(eng, t) |