Skip to content

Integration tests: Update testenv.ProtectAll() to also cleanup Services #36581

@thaJeztah

Description

@thaJeztah

Creating a tracking issue for #36538 (comment)

We should update testenv.ProtectAll() and testenv.Clean() to also cleanup services, so that integration-tests don't have to clean up services after running the tests.

Similar to the way containers, networks, and other resources are currently handled;

// ProtectAll protects the existing environment (containers, images, networks,
// volumes, and, on Linux, plugins) from being cleaned up at the end of test
// runs
func ProtectAll(t testingT, testEnv *Execution) {
ProtectContainers(t, testEnv)
ProtectImages(t, testEnv)
ProtectNetworks(t, testEnv)
ProtectVolumes(t, testEnv)
if testEnv.OSType == "linux" {
ProtectPlugins(t, testEnv)
}
}

// Clean the environment, preserving protected objects (images, containers, ...)
// and removing everything else. It's meant to run after any tests so that they don't
// depend on each others.
func (e *Execution) Clean(t testingT) {
client := e.APIClient()
platform := e.OSType
if (platform != "windows") || (platform == "windows" && e.DaemonInfo.Isolation == "hyperv") {
unpauseAllContainers(t, client)
}
deleteAllContainers(t, client, e.protectedElements.containers)
deleteAllImages(t, client, e.protectedElements.images)
deleteAllVolumes(t, client, e.protectedElements.volumes)
deleteAllNetworks(t, client, platform, e.protectedElements.networks)
if platform == "linux" {
deleteAllPlugins(t, client, e.protectedElements.plugins)
}
}

labelling with both "beginner" and "intermediate"; it's probably somewhere in between 😄

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions