@@ -2,6 +2,7 @@ package e2e
2
2
3
3
import (
4
4
"encoding/json"
5
+ "errors"
5
6
"fmt"
6
7
"strings"
7
8
"testing"
@@ -2370,16 +2371,14 @@ func TestCreateInstallPlanWithPermissions(t *testing.T) {
2370
2371
require .NoError (t , err )
2371
2372
2372
2373
done := make (chan struct {})
2373
- quit := make (chan struct {})
2374
- defer close (quit )
2374
+ errExit := make (chan error )
2375
2375
go func () {
2376
2376
for {
2377
2377
select {
2378
- case <- quit :
2379
- return
2380
2378
case evt , ok := <- crWatcher .ResultChan ():
2381
2379
if ! ok {
2382
- t .Fatal ("cr watch channel closed unexpectedly" )
2380
+ errExit <- errors .New ("cr watch channel closed unexpectedly" )
2381
+ return
2383
2382
}
2384
2383
if evt .Type == watch .Deleted {
2385
2384
cr , ok := evt .Object .(* rbacv1.ClusterRole )
@@ -2389,11 +2388,13 @@ func TestCreateInstallPlanWithPermissions(t *testing.T) {
2389
2388
delete (createdClusterRoleNames , cr .GetName ())
2390
2389
if len (createdClusterRoleNames ) == 0 && len (createdClusterRoleBindingNames ) == 0 && len (createdServiceAccountNames ) == 0 {
2391
2390
done <- struct {}{}
2391
+ return
2392
2392
}
2393
2393
}
2394
2394
case evt , ok := <- crbWatcher .ResultChan ():
2395
2395
if ! ok {
2396
- t .Fatal ("crb watch channel closed unexpectedly" )
2396
+ errExit <- errors .New ("crb watch channel closed unexpectedly" )
2397
+ return
2397
2398
}
2398
2399
if evt .Type == watch .Deleted {
2399
2400
crb , ok := evt .Object .(* rbacv1.ClusterRoleBinding )
@@ -2403,11 +2404,13 @@ func TestCreateInstallPlanWithPermissions(t *testing.T) {
2403
2404
delete (createdClusterRoleBindingNames , crb .GetName ())
2404
2405
if len (createdClusterRoleNames ) == 0 && len (createdClusterRoleBindingNames ) == 0 && len (createdServiceAccountNames ) == 0 {
2405
2406
done <- struct {}{}
2407
+ return
2406
2408
}
2407
2409
}
2408
2410
case evt , ok := <- saWatcher .ResultChan ():
2409
2411
if ! ok {
2410
- t .Fatal ("sa watch channel closed unexpectedly" )
2412
+ errExit <- errors .New ("sa watch channel closed unexpectedly" )
2413
+ return
2411
2414
}
2412
2415
if evt .Type == watch .Deleted {
2413
2416
sa , ok := evt .Object .(* corev1.ServiceAccount )
@@ -2417,17 +2420,24 @@ func TestCreateInstallPlanWithPermissions(t *testing.T) {
2417
2420
delete (createdServiceAccountNames , sa .GetName ())
2418
2421
if len (createdClusterRoleNames ) == 0 && len (createdClusterRoleBindingNames ) == 0 && len (createdServiceAccountNames ) == 0 {
2419
2422
done <- struct {}{}
2423
+ return
2420
2424
}
2421
2425
}
2422
2426
case <- time .After (pollDuration ):
2423
2427
done <- struct {}{}
2428
+ return
2424
2429
}
2425
2430
}
2426
2431
}()
2427
2432
2428
2433
t .Logf ("Deleting CSV '%v' in namespace %v" , stableCSVName , testNamespace )
2429
2434
require .NoError (t , crc .OperatorsV1alpha1 ().ClusterServiceVersions (testNamespace ).DeleteCollection (& metav1.DeleteOptions {}, metav1.ListOptions {}))
2430
- <- done
2435
+ select {
2436
+ case <- done :
2437
+ break
2438
+ case err := <- errExit :
2439
+ t .Fatal (err )
2440
+ }
2431
2441
2432
2442
require .Emptyf (t , createdClusterRoleNames , "unexpected cluster role remain: %v" , createdClusterRoleNames )
2433
2443
require .Emptyf (t , createdClusterRoleBindingNames , "unexpected cluster role binding remain: %v" , createdClusterRoleBindingNames )
0 commit comments