@@ -37,6 +37,7 @@ import (
37
37
"sigs.k8s.io/controller-runtime/pkg/client"
38
38
"sigs.k8s.io/controller-runtime/pkg/client/fake"
39
39
40
+ clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
40
41
runtimev1 "sigs.k8s.io/cluster-api/exp/runtime/api/v1alpha1"
41
42
runtimecatalog "sigs.k8s.io/cluster-api/exp/runtime/catalog"
42
43
runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1"
@@ -45,6 +46,7 @@ import (
45
46
runtimeregistry "sigs.k8s.io/cluster-api/internal/runtime/registry"
46
47
fakev1alpha1 "sigs.k8s.io/cluster-api/internal/runtime/test/v1alpha1"
47
48
"sigs.k8s.io/cluster-api/util"
49
+ v1beta2conditions "sigs.k8s.io/cluster-api/util/conditions/v1beta2"
48
50
)
49
51
50
52
func TestExtensionReconciler_Reconcile (t * testing.T ) {
@@ -106,10 +108,19 @@ func TestExtensionReconciler_Reconcile(t *testing.T) {
106
108
}
107
109
g .Expect (warmup .Start (ctx )).To (Succeed ())
108
110
109
- // Reconcile the extension and assert discovery has succeeded (the first reconcile adds Paused).
111
+ // Reconcile the extension and assert discovery has succeeded (the first reconcile adds the Paused condition ).
110
112
_ , err = r .Reconcile (ctx , ctrl.Request {NamespacedName : util .ObjectKey (extensionConfig )})
111
113
g .Expect (err ).ToNot (HaveOccurred ())
112
114
115
+ // Wait until the ExtensionConfig in the cache has the Paused condition so the next Reconcile can do discovery.
116
+ g .Eventually (func (g Gomega ) {
117
+ conf := & runtimev1.ExtensionConfig {}
118
+ g .Expect (env .Get (ctx , util .ObjectKey (extensionConfig ), conf )).To (Succeed ())
119
+ pausedCondition := v1beta2conditions .Get (conf , clusterv1 .PausedV1Beta2Condition )
120
+ g .Expect (pausedCondition ).ToNot (BeNil ())
121
+ g .Expect (pausedCondition .ObservedGeneration ).To (Equal (conf .Generation ))
122
+ }).WithTimeout (10 * time .Second ).WithPolling (100 * time .Millisecond ).Should (Succeed ())
123
+
113
124
_ , err = r .Reconcile (ctx , ctrl.Request {NamespacedName : util .ObjectKey (extensionConfig )})
114
125
g .Expect (err ).ToNot (HaveOccurred ())
115
126
@@ -169,10 +180,19 @@ func TestExtensionReconciler_Reconcile(t *testing.T) {
169
180
return nil
170
181
}, 30 * time .Second , 100 * time .Millisecond ).Should (Succeed ())
171
182
172
- // Reconcile the extension and assert discovery has succeeded (the first reconcile adds Paused).
183
+ // Reconcile the extension and assert discovery has succeeded (the first reconcile updates observedGeneration in the Paused condition ).
173
184
_ , err = r .Reconcile (ctx , ctrl.Request {NamespacedName : util .ObjectKey (extensionConfig )})
174
185
g .Expect (err ).ToNot (HaveOccurred ())
175
186
187
+ // Wait until the ExtensionConfig in the cache has the up-to-date Paused condition so the next Reconcile can do discovery.
188
+ g .Eventually (func (g Gomega ) {
189
+ conf := & runtimev1.ExtensionConfig {}
190
+ g .Expect (env .Get (ctx , util .ObjectKey (extensionConfig ), conf )).To (Succeed ())
191
+ pausedCondition := v1beta2conditions .Get (conf , clusterv1 .PausedV1Beta2Condition )
192
+ g .Expect (pausedCondition ).ToNot (BeNil ())
193
+ g .Expect (pausedCondition .ObservedGeneration ).To (Equal (conf .Generation ))
194
+ }).WithTimeout (10 * time .Second ).WithPolling (100 * time .Millisecond ).Should (Succeed ())
195
+
176
196
_ , err = r .Reconcile (ctx , ctrl.Request {NamespacedName : util .ObjectKey (extensionConfig )})
177
197
g .Expect (err ).ToNot (HaveOccurred ())
178
198
0 commit comments