@@ -91,9 +91,24 @@ var _ = Describe("IPAddressClaimReconciler", func() {
9191 })
9292
9393 When ("the referenced namespaced pool exists" , func () {
94- const poolName = "test-pool"
94+ const (
95+ clusterName = "test-cluster"
96+ poolName = "test-pool"
97+ )
9598
9699 BeforeEach (func () {
100+ cluster := clusterv1.Cluster {
101+ ObjectMeta : metav1.ObjectMeta {
102+ Name : clusterName ,
103+ Namespace : namespace ,
104+ },
105+ Spec : clusterv1.ClusterSpec {
106+ Paused : false ,
107+ },
108+ }
109+ Expect (k8sClient .Create (context .Background (), & cluster )).To (Succeed ())
110+ Eventually (Get (& cluster )).Should (Succeed ())
111+
97112 pool := v1alpha2.InClusterIPPool {
98113 ObjectMeta : metav1.ObjectMeta {
99114 Name : poolName ,
@@ -112,10 +127,20 @@ var _ = Describe("IPAddressClaimReconciler", func() {
112127 AfterEach (func () {
113128 deleteClaim ("test" , namespace )
114129 deleteNamespacedPool (poolName , namespace )
130+
131+ cluster := clusterv1.Cluster {
132+ ObjectMeta : metav1.ObjectMeta {
133+ Name : clusterName ,
134+ Namespace : namespace ,
135+ },
136+ }
137+ ExpectWithOffset (1 , k8sClient .Delete (context .Background (), & cluster )).To (Succeed ())
138+ EventuallyWithOffset (1 , Get (& cluster )).Should (Not (Succeed ()))
115139 })
116140
117141 It ("should allocate an Address from the Pool" , func () {
118142 claim := newClaim ("test" , namespace , "InClusterIPPool" , poolName )
143+ claim .Labels = map [string ]string {clusterv1 .ClusterNameLabel : clusterName }
119144 expectedIPAddress := ipamv1.IPAddress {
120145 ObjectMeta : metav1.ObjectMeta {
121146 Name : "test" ,
@@ -137,6 +162,7 @@ var _ = Describe("IPAddressClaimReconciler", func() {
137162 Name : poolName ,
138163 },
139164 },
165+ Labels : map [string ]string {clusterv1 .ClusterNameLabel : clusterName },
140166 },
141167 Spec : ipamv1.IPAddressSpec {
142168 ClaimRef : corev1.LocalObjectReference {
0 commit comments