cleanup the image synchronously for Usage case

TestImageIsUnpacked will unpacked docker.io/library/busybox:latest with
linux/amd64 platform. If the TestImageUsage doesn't wait for cleanup
finish (snapshotter is cleanup by gc asynchronously) and fetch image,
the Usage(ctx) will get 10767844 bytes(manifestUsage + snapshotUsage).

However, the manifestUsage is 9466142 bytes. That is why we got the
error:

```
Expected actual usage to equal manifest reported usage of 9466142:
got 10767844
```

This commit is to make sure that the image has been cleanup fully.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
Wei Fu 2020-02-21 23:48:44 +08:00
parent 0e08405433
commit 1d888ad6a6

View File

@ -151,7 +151,7 @@ func TestImageUsage(t *testing.T) {
defer client.Close()
// Cleanup
err = client.ImageService().Delete(ctx, imageName)
err = client.ImageService().Delete(ctx, imageName, images.SynchronousDelete())
if err != nil && !errdefs.IsNotFound(err) {
t.Fatal(err)
}