@@ -80,6 +80,10 @@ func TestOperatorGroup(t *testing.T) {
80
80
// Verify copied CVS is deleted
81
81
defer cleaner .NotifyTestComplete (t , true )
82
82
83
+ log := func (s string ) {
84
+ t .Logf ("%s: %s" , time .Now ().Format ("15:04:05.9999" ), s )
85
+ }
86
+
83
87
c := newKubeClient (t )
84
88
crc := newCRClient (t )
85
89
csvName := genName ("another-csv-" ) // must be lowercase for DNS-1123 validation
@@ -114,14 +118,14 @@ func TestOperatorGroup(t *testing.T) {
114
118
require .NoError (t , err )
115
119
}()
116
120
117
- t . Log ("Creating CRD" )
121
+ log ("Creating CRD" )
118
122
mainCRDPlural := genName ("opgroup" )
119
123
mainCRD := newCRD (mainCRDPlural )
120
124
cleanupCRD , err := createCRD (c , mainCRD )
121
125
require .NoError (t , err )
122
126
defer cleanupCRD ()
123
127
124
- t . Log ("Creating operator group" )
128
+ log ("Creating operator group" )
125
129
operatorGroup := v1.OperatorGroup {
126
130
ObjectMeta : metav1.ObjectMeta {
127
131
Name : genName ("e2e-operator-group-" ),
@@ -144,7 +148,7 @@ func TestOperatorGroup(t *testing.T) {
144
148
Namespaces : []string {opGroupNamespace , createdOtherNamespace .GetName ()},
145
149
}
146
150
147
- t . Log ("Waiting on operator group to have correct status" )
151
+ log ("Waiting on operator group to have correct status" )
148
152
err = wait .Poll (pollInterval , pollDuration , func () (bool , error ) {
149
153
fetched , fetchErr := crc .OperatorsV1 ().OperatorGroups (opGroupNamespace ).Get (operatorGroup .Name , metav1.GetOptions {})
150
154
if fetchErr != nil {
@@ -158,7 +162,7 @@ func TestOperatorGroup(t *testing.T) {
158
162
})
159
163
require .NoError (t , err )
160
164
161
- t . Log ("Creating CSV" )
165
+ log ("Creating CSV" )
162
166
// Generate permissions
163
167
serviceAccountName := genName ("nginx-sa" )
164
168
permissions := []install.StrategyDeploymentPermissions {
@@ -219,25 +223,25 @@ func TestOperatorGroup(t *testing.T) {
219
223
createdCSV , err := crc .OperatorsV1alpha1 ().ClusterServiceVersions (opGroupNamespace ).Create (& aCSV )
220
224
require .NoError (t , err )
221
225
222
- t . Log ("wait for CSV to succeed" )
226
+ log ("wait for CSV to succeed" )
223
227
err = wait .Poll (pollInterval , pollDuration , func () (bool , error ) {
224
228
fetched , err := crc .OperatorsV1alpha1 ().ClusterServiceVersions (opGroupNamespace ).Get (createdCSV .GetName (), metav1.GetOptions {})
225
229
if err != nil {
226
230
return false , err
227
231
}
228
- t . Logf ("%s (%s): %s" , fetched .Status .Phase , fetched .Status .Reason , fetched .Status .Message )
232
+ log ( fmt . Sprintf ("%s (%s): %s" , fetched .Status .Phase , fetched .Status .Reason , fetched .Status .Message ) )
229
233
return csvSucceededChecker (fetched ), nil
230
234
})
231
235
require .NoError (t , err )
232
236
233
- t . Log ("Waiting for operator namespace csv to have annotations" )
237
+ log ("Waiting for operator namespace csv to have annotations" )
234
238
err = wait .Poll (pollInterval , pollDuration , func () (bool , error ) {
235
239
fetchedCSV , fetchErr := crc .OperatorsV1alpha1 ().ClusterServiceVersions (opGroupNamespace ).Get (csvName , metav1.GetOptions {})
236
240
if fetchErr != nil {
237
241
if errors .IsNotFound (fetchErr ) {
238
242
return false , nil
239
243
}
240
- t . Logf ("Error (in %v): %v" , testNamespace , fetchErr .Error ())
244
+ log ( fmt . Sprintf ("Error (in %v): %v" , testNamespace , fetchErr .Error () ))
241
245
return false , fetchErr
242
246
}
243
247
if checkOperatorGroupAnnotations (fetchedCSV , & operatorGroup , true , bothNamespaceNames ) == nil {
@@ -247,14 +251,14 @@ func TestOperatorGroup(t *testing.T) {
247
251
})
248
252
require .NoError (t , err )
249
253
250
- t . Log ("Waiting for target namespace csv to have annotations (but not target namespaces)" )
254
+ log ("Waiting for target namespace csv to have annotations (but not target namespaces)" )
251
255
err = wait .Poll (pollInterval , pollDuration , func () (bool , error ) {
252
256
fetchedCSV , fetchErr := crc .OperatorsV1alpha1 ().ClusterServiceVersions (otherNamespaceName ).Get (csvName , metav1.GetOptions {})
253
257
if fetchErr != nil {
254
258
if errors .IsNotFound (fetchErr ) {
255
259
return false , nil
256
260
}
257
- t . Logf ("Error (in %v): %v" , otherNamespaceName , fetchErr .Error ())
261
+ log ( fmt . Sprintf ("Error (in %v): %v" , otherNamespaceName , fetchErr .Error () ))
258
262
return false , fetchErr
259
263
}
260
264
if checkOperatorGroupAnnotations (fetchedCSV , & operatorGroup , false , "" ) == nil {
@@ -264,7 +268,7 @@ func TestOperatorGroup(t *testing.T) {
264
268
return false , nil
265
269
})
266
270
267
- t . Log ("Checking status on csv in target namespace" )
271
+ log ("Checking status on csv in target namespace" )
268
272
err = wait .Poll (pollInterval , pollDuration , func () (bool , error ) {
269
273
fetchedCSV , fetchErr := crc .OperatorsV1alpha1 ().ClusterServiceVersions (otherNamespaceName ).Get (csvName , metav1.GetOptions {})
270
274
if fetchErr != nil {
@@ -281,7 +285,7 @@ func TestOperatorGroup(t *testing.T) {
281
285
})
282
286
require .NoError (t , err )
283
287
284
- t . Log ("Waiting on deployment to have correct annotations" )
288
+ log ("Waiting on deployment to have correct annotations" )
285
289
err = wait .Poll (pollInterval , pollDuration , func () (bool , error ) {
286
290
createdDeployment , err := c .GetDeployment (opGroupNamespace , deploymentName )
287
291
if err != nil {
@@ -325,7 +329,7 @@ func TestOperatorGroup(t *testing.T) {
325
329
326
330
ruleChecker := install .NewCSVRuleChecker (roleInformer .Lister (), roleBindingInformer .Lister (), clusterRoleInformer .Lister (), clusterRoleBindingInformer .Lister (), & aCSV )
327
331
328
- t . Log ("Waiting for operator to have rbac in target namespace" )
332
+ log ("Waiting for operator to have rbac in target namespace" )
329
333
err = wait .Poll (pollInterval , pollDuration , func () (bool , error ) {
330
334
for _ , perm := range permissions {
331
335
sa , err := c .GetServiceAccount (opGroupNamespace , perm .ServiceAccountName )
@@ -368,7 +372,7 @@ func TestOperatorGroup(t *testing.T) {
368
372
require .Equal (t , viewPolicyRules , viewRole .Rules )
369
373
370
374
// Unsupport all InstallModes
371
- t . Log ("unsupporting all csv installmodes" )
375
+ log ("unsupporting all csv installmodes" )
372
376
fetchedCSV , err := crc .OperatorsV1alpha1 ().ClusterServiceVersions (opGroupNamespace ).Get (csvName , metav1.GetOptions {})
373
377
require .NoError (t , err , "could not fetch csv" )
374
378
fetchedCSV .Spec .InstallModes = []v1alpha1.InstallMode {}
@@ -380,11 +384,11 @@ func TestOperatorGroup(t *testing.T) {
380
384
require .NoError (t , err , "csv did not transition to failed as expected" )
381
385
382
386
// ensure deletion cleans up copied CSV
383
- t . Log ("deleting parent csv" )
387
+ log ("deleting parent csv" )
384
388
err = crc .OperatorsV1alpha1 ().ClusterServiceVersions (opGroupNamespace ).Delete (csvName , & metav1.DeleteOptions {})
385
389
require .NoError (t , err )
386
390
387
- t . Log ("waiting for orphaned csv to be deleted" )
391
+ log ("waiting for orphaned csv to be deleted" )
388
392
err = waitForDelete (func () error {
389
393
_ , err = crc .OperatorsV1alpha1 ().ClusterServiceVersions (otherNamespaceName ).Get (csvName , metav1.GetOptions {})
390
394
return err
0 commit comments