@@ -20,6 +20,8 @@ import (
2020 "github.com/bootc-dev/bink/test/integration/helpers"
2121)
2222
23+ const verifyContainerName = "test-images-verify"
24+
2325var _ = Describe ("Cluster Images Volume" , Serial , func () {
2426 var (
2527 podmanClient * podman.Client
@@ -34,9 +36,18 @@ var _ = Describe("Cluster Images Volume", Serial, func() {
3436 podmanClient , err = podman .NewClient ()
3537 Expect (err ).ToNot (HaveOccurred ())
3638
37- containers , err := podmanClient .ContainerList (ctx , "" )
39+ // Clean up populator containers from previous test runs.
40+ populators , err := podmanClient .ContainerList (ctx , config .LabelFilter (config .LabelComponent , "cluster-images-populator" ))
3841 Expect (err ).ToNot (HaveOccurred ())
39- for _ , name := range containers {
42+ for _ , name := range populators {
43+ _ = podmanClient .ContainerStop (ctx , name )
44+ _ = podmanClient .ContainerRemove (ctx , name , true )
45+ }
46+
47+ // Clean up verify containers from previous test runs.
48+ verifiers , err := podmanClient .ContainerList (ctx , config .LabelFilter (config .LabelComponent , "cluster-images-test-verify" ))
49+ Expect (err ).ToNot (HaveOccurred ())
50+ for _ , name := range verifiers {
4051 _ = podmanClient .ContainerStop (ctx , name )
4152 _ = podmanClient .ContainerRemove (ctx , name , true )
4253 }
@@ -60,7 +71,11 @@ var _ = Describe("Cluster Images Volume", Serial, func() {
6071 AfterEach (func () {
6172 ctx := context .Background ()
6273
63- _ = podmanClient .ContainerRemove (ctx , "test-images-verify" , true )
74+ verifiers , err := podmanClient .ContainerList (ctx , config .LabelFilter (config .LabelComponent , "cluster-images-test-verify" ))
75+ Expect (err ).ToNot (HaveOccurred ())
76+ for _ , name := range verifiers {
77+ _ = podmanClient .ContainerRemove (ctx , name , true )
78+ }
6479 })
6580
6681 It ("should populate a versioned cluster-images volume with Kubernetes and Calico images" , func () {
@@ -99,23 +114,25 @@ var _ = Describe("Cluster Images Volume", Serial, func() {
99114 Expect (err ).ToNot (HaveOccurred (), ".completed marker should exist in the volume" )
100115
101116 By ("Verifying Calico images are stored in the volume" )
102- verifyContainer := "test-images-verify"
103117 _ , err = podmanClient .ContainerCreate (ctx , & podman.ContainerCreateOptions {
104- Name : verifyContainer ,
118+ Name : verifyContainerName ,
105119 Image : config .DefaultClusterImage ,
106120 Command : []string {"sleep" , "infinity" },
121+ Labels : map [string ]string {
122+ config .LabelComponent : "cluster-images-test-verify" ,
123+ },
107124 Volumes : []* specgen.NamedVolume {{
108125 Name : volumeName ,
109126 Dest : "/var/lib/containers/storage" ,
110127 }},
111128 })
112129 Expect (err ).ToNot (HaveOccurred ())
113130
114- err = podmanClient .ContainerExecQuiet (ctx , verifyContainer ,
131+ err = podmanClient .ContainerExecQuiet (ctx , verifyContainerName ,
115132 []string {"podman" , "image" , "exists" , config .CalicoImageBase + "/node:" + config .CalicoVersion })
116133 Expect (err ).ToNot (HaveOccurred (), "calico/node image should exist in the volume" )
117134
118- err = podmanClient .ContainerExecQuiet (ctx , verifyContainer ,
135+ err = podmanClient .ContainerExecQuiet (ctx , verifyContainerName ,
119136 []string {"podman" , "image" , "exists" , config .CalicoImageBase + "/cni:" + config .CalicoVersion })
120137 Expect (err ).ToNot (HaveOccurred (), "calico/cni image should exist in the volume" )
121138 })
0 commit comments