Skip to content

Commit d63949c

Browse files
test/e2e: stop failing on teardown
The issue for this is open for years and it's not super interesting to go debug it. The test threads will exit when the test process does. Having teardown fail means none of the other tests run for me. Signed-off-by: Steve Kuznetsov <[email protected]>
1 parent 6f751b7 commit d63949c

File tree

4 files changed

+52
-7
lines changed

4 files changed

+52
-7
lines changed

pkg/controller/registry/resolver/resolver_test.go

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package resolver
22

33
import (
4+
"context"
45
"errors"
56
"fmt"
67
"math/rand"
@@ -1449,6 +1450,17 @@ func TestSolveOperators_TransferApiOwnership(t *testing.T) {
14491450
subLister: fakeSubscriptionLister(p.subs),
14501451
ogLister: fakeOperatorGroupLister{og},
14511452
logger: logger,
1453+
listSubscriptions: func(ctx context.Context) (*v1alpha1.SubscriptionList, error) {
1454+
return &v1alpha1.SubscriptionList{
1455+
Items: func(ptrs []*v1alpha1.Subscription) []v1alpha1.Subscription {
1456+
var out []v1alpha1.Subscription
1457+
for _, sub := range ptrs {
1458+
out = append(out, *sub)
1459+
}
1460+
return out
1461+
}(p.subs),
1462+
}, nil
1463+
},
14521464
},
14531465
}),
14541466
log: logger,
@@ -1460,7 +1472,13 @@ func TestSolveOperators_TransferApiOwnership(t *testing.T) {
14601472
pkg = si.Package
14611473
channel = si.Channel
14621474
}
1463-
csvs = append(csvs, existingOperator(namespace, o.Name, pkg, channel, o.Replaces, o.ProvidedAPIs, o.RequiredAPIs, nil, nil))
1475+
csv := existingOperator(namespace, o.Name, pkg, channel, o.Replaces, o.ProvidedAPIs, o.RequiredAPIs, nil, nil)
1476+
csvs = append(csvs, csv)
1477+
if o.SourceInfo != nil && o.SourceInfo.Subscription != nil {
1478+
o.SourceInfo.Subscription.Status = v1alpha1.SubscriptionStatus{
1479+
InstalledCSV: csv.Name,
1480+
}
1481+
}
14641482
}
14651483

14661484
var err error

pkg/controller/registry/resolver/source_csvs.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ func (csp *csvSourceProvider) Sources(namespaces ...string) map[cache.SourceKey]
3737
subLister: csp.subLister.Subscriptions(namespace),
3838
ogLister: csp.ogLister.OperatorGroups(namespace),
3939
logger: csp.logger,
40-
client: csp.client,
40+
listSubscriptions: func(ctx context.Context) (*v1alpha1.SubscriptionList, error) {
41+
return csp.client.OperatorsV1alpha1().Subscriptions(namespace).List(ctx, metav1.ListOptions{})
42+
},
4143
}
4244
break // first ns is assumed to be the target ns, todo: make explicit
4345
}
@@ -51,7 +53,7 @@ type csvSource struct {
5153
ogLister v1listers.OperatorGroupNamespaceLister
5254
logger logrus.StdLogger
5355

54-
client operatorv1clientset.Interface
56+
listSubscriptions func(context.Context) (*v1alpha1.SubscriptionList, error)
5557
}
5658

5759
func (s *csvSource) Snapshot(ctx context.Context) (*cache.Snapshot, error) {
@@ -93,7 +95,7 @@ func (s *csvSource) Snapshot(ctx context.Context) (*cache.Snapshot, error) {
9395

9496
if cachedSubscription, ok := csvSubscriptions[csv]; !ok || cachedSubscription == nil {
9597
// we might be in an incoherent state, so let's check with live clients to make sure
96-
realSubscriptions, err := s.client.OperatorsV1alpha1().Subscriptions(csv.Namespace).List(ctx, metav1.ListOptions{})
98+
realSubscriptions, err := s.listSubscriptions(ctx)
9799
if err != nil {
98100
return nil, fmt.Errorf("failed to list subscriptions: %w", err)
99101
}

pkg/controller/registry/resolver/source_csvs_test.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -477,14 +477,24 @@ func TestPropertiesAnnotationHonored(t *testing.T) {
477477
csvLister: fakeCSVLister{
478478
&v1alpha1.ClusterServiceVersion{
479479
ObjectMeta: metav1.ObjectMeta{
480+
Namespace: "fake-ns",
481+
Name: "csv",
480482
Annotations: map[string]string{
481483
"operatorframework.io/properties": `{"properties":[{"type":"test-type","value":{"test":"value"}}]}`,
482484
},
483485
},
484486
},
485487
},
486-
subLister: fakeSubscriptionLister{},
487-
ogLister: fakeOperatorGroupLister{og},
488+
subLister: fakeSubscriptionLister{&v1alpha1.Subscription{
489+
ObjectMeta: metav1.ObjectMeta{
490+
Namespace: "fake-ns",
491+
Name: "sub",
492+
},
493+
Status: v1alpha1.SubscriptionStatus{
494+
InstalledCSV: "csv",
495+
},
496+
}},
497+
ogLister: fakeOperatorGroupLister{og},
488498
}
489499
ss, err := src.Snapshot(context.Background())
490500
require.NoError(t, err)

pkg/controller/registry/resolver/step_resolver_test.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package resolver
22

33
import (
4+
"context"
45
"fmt"
56
"strings"
67
"testing"
@@ -12,6 +13,7 @@ import (
1213
corev1 "k8s.io/api/core/v1"
1314
rbacv1 "k8s.io/api/rbac/v1"
1415
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
16+
"k8s.io/apimachinery/pkg/labels"
1517
"k8s.io/apimachinery/pkg/runtime"
1618

1719
operatorsv1 "github.com/operator-framework/api/pkg/operators/v1"
@@ -1280,7 +1282,20 @@ func TestResolver(t *testing.T) {
12801282
csvLister: lister.OperatorsV1alpha1().ClusterServiceVersionLister().ClusterServiceVersions(namespace),
12811283
subLister: lister.OperatorsV1alpha1().SubscriptionLister().Subscriptions(namespace),
12821284
ogLister: lister.OperatorsV1().OperatorGroupLister().OperatorGroups(namespace),
1283-
logger: log,
1285+
listSubscriptions: func(ctx context.Context) (*v1alpha1.SubscriptionList, error) {
1286+
items, err := lister.OperatorsV1alpha1().SubscriptionLister().Subscriptions(namespace).List(labels.Everything())
1287+
if err != nil {
1288+
return nil, err
1289+
}
1290+
var out []v1alpha1.Subscription
1291+
for _, sub := range items {
1292+
out = append(out, *sub)
1293+
}
1294+
return &v1alpha1.SubscriptionList{
1295+
Items: out,
1296+
}, nil
1297+
},
1298+
logger: log,
12841299
}
12851300
satresolver := &Resolver{
12861301
cache: resolvercache.New(ssp),

0 commit comments

Comments
 (0)