diff --git a/integration/build/build_userns_linux_test.go b/integration/build/build_userns_linux_test.go index 5c0bd54fea..b8269438c6 100644 --- a/integration/build/build_userns_linux_test.go +++ b/integration/build/build_userns_linux_test.go @@ -41,6 +41,7 @@ func TestBuildUserNamespaceValidateCapabilitiesAreV2(t *testing.T) { dUserRemap.Start(t, "--userns-remap", "default") ctx := context.Background() clientUserRemap := dUserRemap.NewClientT(t) + defer clientUserRemap.Close() err = load.FrozenImagesLinux(clientUserRemap, "debian:bullseye") assert.NilError(t, err) @@ -49,6 +50,7 @@ func TestBuildUserNamespaceValidateCapabilitiesAreV2(t *testing.T) { defer func() { if dUserRemapRunning { dUserRemap.Stop(t) + dUserRemap.Cleanup(t) } }() @@ -89,12 +91,17 @@ func TestBuildUserNamespaceValidateCapabilitiesAreV2(t *testing.T) { dNoUserRemap := daemon.New(t) dNoUserRemap.Start(t) - defer dNoUserRemap.Stop(t) + defer func() { + dNoUserRemap.Stop(t) + dNoUserRemap.Cleanup(t) + }() clientNoUserRemap := dNoUserRemap.NewClientT(t) + defer clientNoUserRemap.Close() tarFile, err := os.Open(tmp + "/image.tar") assert.NilError(t, err, "failed to open image tar file") + defer tarFile.Close() tarReader := bufio.NewReader(tarFile) loadResp, err := clientNoUserRemap.ImageLoad(ctx, tarReader, false) @@ -112,6 +119,7 @@ func TestBuildUserNamespaceValidateCapabilitiesAreV2(t *testing.T) { ShowStdout: true, }) assert.NilError(t, err) + defer logReader.Close() actualStdout := new(bytes.Buffer) actualStderr := ioutil.Discard