TestBuildUserNamespaceValidateCapabilitiesAreV2: cleanup daemon storage
This should help with Jenkins failing to clean up the Workspace: - make sure "cleanup" is also called in the defer for all daemons. keeping the daemon's storage around prevented Jenkins from cleaning up. - close client connections and some readers (just to be sure) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
1a15a1a061
commit
eea2758761
1 changed files with 9 additions and 1 deletions
|
@ -40,6 +40,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-slim")
|
||||
assert.NilError(t, err)
|
||||
|
@ -48,6 +49,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 := io.Discard
|
||||
|
|
Loading…
Reference in a new issue