Преглед изворни кода

integration: make TestSaveRepoWithMultipleImages less flaky

Shutting down containers on Windows can take a long time (with hyper-v),
causing this test to be flaky; seen failing on windows 2022;

    === FAIL: github.com/docker/docker/integration/image TestSaveRepoWithMultipleImages (23.16s)
        save_test.go:104: timeout waiting for container to exit

Looking at the test, we run a container only to commit it, and the test
does not make changes to the container's filesystem; it only runs a container
with a custom command (`true`).

Instead of running the container, we can _create_ a container and commit it;
this simplifies the tests, and prevents having to wait for the container to
exit (before committing).

To verify:

    make BIND_DIR=. DOCKER_GRAPHDRIVER=vfs TEST_FILTER=TestSaveRepoWithMultipleImages test-integration

    INFO: Testing against a local daemon
    === RUN   TestSaveRepoWithMultipleImages
    --- PASS: TestSaveRepoWithMultipleImages (1.20s)
    PASS

    DONE 1 tests in 2.668s

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn пре 1 година
родитељ
комит
30cd8b8fca
1 измењених фајлова са 1 додато и 15 уклоњено
  1. 1 15
      integration/image/save_test.go

+ 1 - 15
integration/image/save_test.go

@@ -2,7 +2,6 @@ package image
 
 import (
 	"archive/tar"
-	"context"
 	"encoding/json"
 	"io"
 	"io/fs"
@@ -86,24 +85,11 @@ func TestSaveRepoWithMultipleImages(t *testing.T) {
 	client := testEnv.APIClient()
 
 	makeImage := func(from string, tag string) string {
-		id := container.Run(ctx, t, client, func(cfg *container.TestContainerConfig) {
+		id := container.Create(ctx, t, client, func(cfg *container.TestContainerConfig) {
 			cfg.Config.Image = from
 			cfg.Config.Cmd = []string{"true"}
 		})
 
-		chW, chErr := client.ContainerWait(ctx, id, containertypes.WaitConditionNotRunning)
-
-		ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
-		defer cancel()
-
-		select {
-		case <-chW:
-		case err := <-chErr:
-			assert.NilError(t, err)
-		case <-ctx.Done():
-			t.Fatal("timeout waiting for container to exit")
-		}
-
 		res, err := client.ContainerCommit(ctx, id, containertypes.CommitOptions{Reference: tag})
 		assert.NilError(t, err)