Skip to content

Commit ad199a4

Browse files
committed
test(bare): use new operator constructors
1 parent 6c7404d commit ad199a4

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

test/e2e/setup_bare_test.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"github.com/sirupsen/logrus"
1515
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
16+
utilclock "k8s.io/apimachinery/pkg/util/clock"
1617

1718
v1 "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1"
1819
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client"
@@ -67,8 +68,9 @@ func TestMain(m *testing.M) {
6768
cleaner = newNamespaceCleaner(testNamespace)
6869
namespaces := strings.Split(*watchedNamespaces, ",")
6970

70-
olmStopCh := make(chan struct{}, 1)
71-
catalogStopCh := make(chan struct{}, 1)
71+
// Get exit signal context
72+
ctx, cancel := context.WithCancel(signals.Context())
73+
defer cancel()
7274

7375
// operator dependencies
7476
crClient, err := client.NewClient(*kubeConfigPath)
@@ -106,18 +108,25 @@ func TestMain(m *testing.M) {
106108
})
107109

108110
// start operators
109-
olmOperator, err := olm.NewOperator(olmlogger, crClient, olmOpClient, &install.StrategyResolver{}, time.Minute, namespaces)
111+
olmOperator, err := olm.NewOperator(
112+
ctx,
113+
olm.WithLogger(olmLogger),
114+
olm.WithWatchedNamespaces(namespaces...),
115+
olm.WithResyncPeriod(time.Minute),
116+
olm.WithExternalClient(crClient),
117+
olm.WithOperatorClient(olmOpClient),
118+
)
110119
if err != nil {
111120
logrus.WithError(err).Fatalf("error configuring olm")
112121
}
113-
olmready, _, _ := olmOperator.Run(olmStopCh)
114-
catalogOperator, err := catalog.NewOperator(*kubeConfigPath, catlogger, time.Minute, "quay.io/operatorframework/configmap-operator-registry:latest", *namespace, namespaces...)
122+
olmOperator.Run(ctx)
123+
catalogOperator, err := catalog.NewOperator(ctx, *kubeConfigPath, utilclock.RealClock{}, catlogger, time.Minute, "quay.io/operatorframework/configmap-operator-registry:latest", *namespace, namespaces...)
115124
if err != nil {
116125
logrus.WithError(err).Fatalf("error configuring catalog")
117126
}
118-
catready, _, _ := catalogOperator.Run(catalogStopCh)
119-
<-olmready
120-
<-catready
127+
catalogOperator.Run(ctx)
128+
<-olmOperator.Ready()
129+
<-catalogOperator.Ready()
121130

122131
c, err := client.NewClient(*kubeConfigPath)
123132
if err != nil {

0 commit comments

Comments
 (0)