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