Просмотр исходного кода

integration/container: fix flaky TestResizeWhenContainerNotStarted

This test was failing frequently on Windows, where the test was waiting
for the container to exit before continuing;

    === FAIL: github.com/docker/docker/integration/container TestResizeWhenContainerNotStarted (18.69s)
    resize_test.go:58: timeout hit after 10s: waiting for container to be one of (exited), currently running

It looks like this test is merely validating that a container in any non-
running state should produce an error, so there's no need to run a container
(waiting for it to stop), and just "creating" a container (which would be
in `created` state) should work for this purpose.

Looking at 8f800c941570ffcd087c920c37d3a368a5a19e6d, I see `createSimpleContainer`
and `runSimpleContainer` utilities were added, so I'm even wondering if the
original intent was to use `createSimpleContainer` for  this test.

While updating, also check if we get the expected error-type, instead of
only checking for the error-message.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 1 год назад
Родитель
Сommit
ee7ca6822a
1 измененных файлов с 3 добавлено и 4 удалено
  1. 3 4
      integration/container/resize_test.go

+ 3 - 4
integration/container/resize_test.go

@@ -7,6 +7,7 @@ import (
 
 
 	"github.com/docker/docker/api/types"
 	"github.com/docker/docker/api/types"
 	"github.com/docker/docker/api/types/versions"
 	"github.com/docker/docker/api/types/versions"
+	"github.com/docker/docker/errdefs"
 	"github.com/docker/docker/integration/internal/container"
 	"github.com/docker/docker/integration/internal/container"
 	req "github.com/docker/docker/testutil/request"
 	req "github.com/docker/docker/testutil/request"
 	"gotest.tools/v3/assert"
 	"gotest.tools/v3/assert"
@@ -49,13 +50,11 @@ func TestResizeWhenContainerNotStarted(t *testing.T) {
 	ctx := setupTest(t)
 	ctx := setupTest(t)
 	apiClient := testEnv.APIClient()
 	apiClient := testEnv.APIClient()
 
 
-	cID := container.Run(ctx, t, apiClient, container.WithCmd("echo"))
-
-	poll.WaitOn(t, container.IsInState(ctx, apiClient, cID, "exited"), poll.WithDelay(100*time.Millisecond))
-
+	cID := container.Create(ctx, t, apiClient, container.WithCmd("echo"))
 	err := apiClient.ContainerResize(ctx, cID, types.ResizeOptions{
 	err := apiClient.ContainerResize(ctx, cID, types.ResizeOptions{
 		Height: 40,
 		Height: 40,
 		Width:  40,
 		Width:  40,
 	})
 	})
+	assert.Check(t, is.ErrorType(err, errdefs.IsConflict))
 	assert.Check(t, is.ErrorContains(err, "is not running"))
 	assert.Check(t, is.ErrorContains(err, "is not running"))
 }
 }