@@ -164,56 +164,36 @@ func Test_GetBootstrapScalingStrategy(t *testing.T) {
164
164
func Test_IsBootstrapComplete (t * testing.T ) {
165
165
tests := map [string ]struct {
166
166
bootstrapConfigMap * corev1.ConfigMap
167
- nodes []operatorv1.NodeStatus
168
167
etcdMembers []* etcdserverpb.Member
169
168
expectComplete bool
170
169
expectError error
171
170
}{
172
- "bootstrap complete, nodes up to date " : {
171
+ "bootstrap complete, configmap status is complete " : {
173
172
bootstrapConfigMap : bootstrapComplete ,
174
- nodes : twoNodesAtCurrentRevision ,
175
173
etcdMembers : u .DefaultEtcdMembers (),
176
174
expectComplete : true ,
177
175
expectError : nil ,
178
176
},
179
- "bootstrap progressing, nodes up to date " : {
177
+ "bootstrap progressing, configmap status is progressing " : {
180
178
bootstrapConfigMap : bootstrapProgressing ,
181
- nodes : twoNodesAtCurrentRevision ,
182
179
etcdMembers : u .DefaultEtcdMembers (),
183
180
expectComplete : false ,
184
181
expectError : nil ,
185
182
},
186
183
"bootstrap configmap missing" : {
187
184
bootstrapConfigMap : nil ,
188
- nodes : twoNodesAtCurrentRevision ,
189
- etcdMembers : u .DefaultEtcdMembers (),
190
- expectComplete : false ,
191
- expectError : nil ,
192
- },
193
- "bootstrap complete, no recorded revisions" : {
194
- bootstrapConfigMap : bootstrapComplete ,
195
- nodes : zeroNodesAtAnyRevision ,
196
- etcdMembers : u .DefaultEtcdMembers (),
197
- expectComplete : true ,
198
- expectError : nil ,
199
- },
200
- "bootstrap complete, node progressing" : {
201
- bootstrapConfigMap : bootstrapComplete ,
202
- nodes : twoNodesProgressingTowardsCurrentRevision ,
203
185
etcdMembers : u .DefaultEtcdMembers (),
204
186
expectComplete : false ,
205
187
expectError : nil ,
206
188
},
207
189
"bootstrap complete, etcd-bootstrap removed" : {
208
190
bootstrapConfigMap : bootstrapComplete ,
209
- nodes : twoNodesAtCurrentRevision ,
210
191
etcdMembers : u .DefaultEtcdMembers (),
211
192
expectComplete : true ,
212
193
expectError : nil ,
213
194
},
214
195
"bootstrap complete, etcd-bootstrap exists" : {
215
196
bootstrapConfigMap : bootstrapComplete ,
216
- nodes : twoNodesAtCurrentRevision ,
217
197
etcdMembers : append (u .DefaultEtcdMembers (), u .FakeEtcdBootstrapMember (0 )),
218
198
expectComplete : false ,
219
199
expectError : nil ,
@@ -230,25 +210,58 @@ func Test_IsBootstrapComplete(t *testing.T) {
230
210
}
231
211
fakeConfigMapLister := corev1listers .NewConfigMapLister (indexer )
232
212
233
- operatorStatus := & operatorv1.StaticPodOperatorStatus {
234
- OperatorStatus : operatorv1.OperatorStatus {LatestAvailableRevision : 1 },
235
- NodeStatuses : test .nodes ,
236
- }
237
- fakeStaticPodClient := v1helpers .NewFakeStaticPodOperatorClient (nil , operatorStatus , nil , nil )
238
-
239
213
fakeEtcdClient , err := etcdcli .NewFakeEtcdClient (test .etcdMembers )
240
214
if err != nil {
241
215
t .Fatal (err )
242
216
}
243
217
244
- actualComplete , actualErr := IsBootstrapComplete (fakeConfigMapLister , fakeStaticPodClient , fakeEtcdClient )
218
+ actualComplete , actualErr := IsBootstrapComplete (fakeConfigMapLister , fakeEtcdClient )
245
219
246
220
assert .Equal (t , test .expectComplete , actualComplete )
247
221
assert .Equal (t , test .expectError , actualErr )
248
222
})
249
223
}
250
224
}
251
225
226
+ func Test_IsRevisionStable (t * testing.T ) {
227
+ tests := map [string ]struct {
228
+ nodes []operatorv1.NodeStatus
229
+ expectedStability bool
230
+ expectedError error
231
+ }{
232
+ "is revision stable, node progressing" : {
233
+ nodes : twoNodesProgressingTowardsCurrentRevision ,
234
+ expectedStability : false ,
235
+ expectedError : nil ,
236
+ },
237
+ "is revision stable, nodes up to date" : {
238
+ nodes : twoNodesAtCurrentRevision ,
239
+ expectedStability : true ,
240
+ expectedError : nil ,
241
+ },
242
+ "bootstrap complete, no recorded revisions" : {
243
+ nodes : zeroNodesAtAnyRevision ,
244
+ expectedStability : true ,
245
+ expectedError : nil ,
246
+ },
247
+ }
248
+ for name , test := range tests {
249
+ t .Run (name , func (t * testing.T ) {
250
+ operatorStatus := & operatorv1.StaticPodOperatorStatus {
251
+ OperatorStatus : operatorv1.OperatorStatus {LatestAvailableRevision : 1 },
252
+ NodeStatuses : test .nodes ,
253
+ }
254
+ fakeStaticPodClient := v1helpers .NewFakeStaticPodOperatorClient (nil , operatorStatus , nil , nil )
255
+
256
+ actualStability , actualErr := IsRevisionStable (fakeStaticPodClient )
257
+
258
+ assert .Equal (t , test .expectedStability , actualStability )
259
+ assert .Equal (t , test .expectedError , actualErr )
260
+
261
+ })
262
+ }
263
+ }
264
+
252
265
func Test_CheckSafeToScaleCluster (t * testing.T ) {
253
266
tests := map [string ]struct {
254
267
namespace * corev1.Namespace
0 commit comments