From 1e0b890dd12c5d2d57bb333b6faa5d09a75ace9e Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Sun, 7 Jan 2018 13:34:10 -0800 Subject: [PATCH] client: fix tests to wait snapshots to become releasable Signed-off-by: Tonis Tiigi --- client/client_test.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/client/client_test.go b/client/client_test.go index 94917420..e48423d1 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -588,6 +588,22 @@ func readTarToMap(dt []byte, compressed bool) (map[string]*tarItem, error) { } func checkAllReleasable(t *testing.T, c *Client, sb integration.Sandbox, checkContent bool) { + retries := 0 +loop0: + for { + require.True(t, 20 > retries) + retries++ + du, err := c.DiskUsage(context.TODO()) + require.NoError(t, err) + for _, d := range du { + if d.InUse { + time.Sleep(500 * time.Millisecond) + continue loop0 + } + } + break + } + err := c.Prune(context.TODO(), nil) require.NoError(t, err) @@ -614,7 +630,7 @@ func checkAllReleasable(t *testing.T, c *Client, sb integration.Sandbox, checkCo ctx := namespaces.WithNamespace(context.Background(), "buildkit") snapshotService := client.SnapshotService("overlayfs") - retries := 0 + retries = 0 for { count := 0 err = snapshotService.Walk(ctx, func(context.Context, snapshots.Info) error {