@@ -3,19 +3,11 @@ package controllers_test
3
3
import (
4
4
"context"
5
5
"fmt"
6
- "strings"
7
- "time"
8
6
9
- "github.com/go-logr/logr/funcr"
10
7
. "github.com/onsi/ginkgo/v2"
11
8
. "github.com/onsi/gomega"
12
- catalogd "github.com/operator-framework/catalogd/pkg/apis/core/v1beta1"
13
9
"github.com/operator-framework/deppy/pkg/deppy"
14
10
"github.com/operator-framework/deppy/pkg/deppy/input"
15
- operatorsv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
16
- "github.com/operator-framework/operator-controller/internal/conditionsets"
17
- "github.com/operator-framework/operator-controller/internal/controllers"
18
- "github.com/operator-framework/operator-controller/internal/resolution"
19
11
rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1"
20
12
apimeta "k8s.io/apimachinery/pkg/api/meta"
21
13
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -25,7 +17,11 @@ import (
25
17
ctrl "sigs.k8s.io/controller-runtime"
26
18
"sigs.k8s.io/controller-runtime/pkg/client"
27
19
"sigs.k8s.io/controller-runtime/pkg/client/fake"
28
- "sigs.k8s.io/controller-runtime/pkg/log"
20
+
21
+ operatorsv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
22
+ "github.com/operator-framework/operator-controller/internal/conditionsets"
23
+ "github.com/operator-framework/operator-controller/internal/controllers"
24
+ "github.com/operator-framework/operator-controller/internal/resolution"
29
25
)
30
26
31
27
var _ = Describe ("Operator Controller Test" , func () {
@@ -1022,94 +1018,6 @@ var _ = Describe("Operator Controller Test", func() {
1022
1018
Expect (cond .Message ).To (Equal ("installation has not been attempted as spec is invalid" ))
1023
1019
})
1024
1020
})
1025
- When ("a catalog changes on cluster" , func () {
1026
- var testLogs , opNames []string
1027
- var cancel context.CancelFunc
1028
- var logCount int
1029
- BeforeEach (func () {
1030
- l := funcr .New (func (prefix , args string ) {
1031
- if prefix == "operator-controller" &&
1032
- strings .Contains (args , `"controller"="operator"` ) &&
1033
- strings .Contains (args , `"msg"="ending"` ) {
1034
- // filter for only relevant logs
1035
- testLogs = append (testLogs , fmt .Sprintf ("%s" , args ))
1036
- }
1037
- }, funcr.Options {Verbosity : 1 })
1038
- mgr , err := ctrl .NewManager (cfg , ctrl.Options {Scheme : sch , Logger : l })
1039
- Expect (err ).To (BeNil ())
1040
-
1041
- err = reconciler .SetupWithManager (mgr )
1042
- Expect (err ).To (BeNil ())
1043
- var mgrCtx context.Context
1044
- mgrCtx , cancel = context .WithCancel (log .IntoContext (ctx , l ))
1045
-
1046
- go func () {
1047
- err := mgr .Start (mgrCtx )
1048
- Expect (err ).To (BeNil ())
1049
- }()
1050
-
1051
- opNames = []string {"prometheus" , "project-quay" }
1052
- for _ , p := range opNames {
1053
- op := & operatorsv1alpha1.Operator {ObjectMeta : metav1.ObjectMeta {Name : p }, Spec : operatorsv1alpha1.OperatorSpec {PackageName : p }}
1054
- err := cl .Create (ctx , op )
1055
- Expect (err ).To (BeNil ())
1056
- }
1057
- Eventually (func (g Gomega ) {
1058
- By ("verifying initial reconcile logs for operator creation" )
1059
- g .Expect (len (testLogs ) >= len (opNames )).To (BeTrue ())
1060
- for _ , p := range opNames {
1061
- g .Expect (testLogs [len (testLogs )- len (opNames ):]).To (ContainElement (ContainSubstring (fmt .Sprintf ("\" Operator\" ={\" name\" :\" %s\" }" , p ))))
1062
- }
1063
- logCount = len (testLogs )
1064
- }).WithTimeout (2 * time .Second ).WithPolling (1 * time .Second ).Should (Succeed ())
1065
- })
1066
-
1067
- It ("reconciles all affected operators on cluster" , func () {
1068
- By ("creating a new catalog" )
1069
- catalog := & catalogd.Catalog {ObjectMeta : metav1.ObjectMeta {Name : "t" }, Spec : catalogd.CatalogSpec {Source : catalogd.CatalogSource {Type : catalogd .SourceTypeImage , Image : & catalogd.ImageSource {}}}}
1070
- err := cl .Create (ctx , catalog )
1071
- Expect (err ).To (BeNil ())
1072
- Eventually (func (g Gomega ) {
1073
- By ("verifying operator reconcile logs on catalog create" )
1074
- g .Expect (testLogs ).To (HaveLen (logCount + len (opNames )))
1075
- for _ , p := range opNames {
1076
- g .Expect (testLogs [len (testLogs )- len (opNames ):]).To (ContainElement (ContainSubstring (fmt .Sprintf ("\" Operator\" ={\" name\" :\" %s\" }" , p ))))
1077
- }
1078
- logCount = len (testLogs )
1079
- }).WithTimeout (2 * time .Second ).WithPolling (1 * time .Second ).Should (Succeed ())
1080
-
1081
- By ("updating a catalog" )
1082
- catalog .Spec .Source .Image .Ref = "s"
1083
- err = cl .Update (ctx , catalog )
1084
- Expect (err ).To (BeNil ())
1085
- Eventually (func (g Gomega ) {
1086
- By ("verifying operator reconcile logs on catalog update" )
1087
- g .Expect (testLogs ).To (HaveLen (logCount + len (opNames )))
1088
- for _ , p := range opNames {
1089
- g .Expect (testLogs [len (testLogs )- len (opNames ):]).To (ContainElement (ContainSubstring (fmt .Sprintf ("\" Operator\" ={\" name\" :\" %s\" }" , p ))))
1090
- }
1091
- logCount = len (testLogs )
1092
- }).WithTimeout (2 * time .Second ).WithPolling (1 * time .Second ).Should (Succeed ())
1093
-
1094
- By ("deleting a catalog" )
1095
- err = cl .Delete (ctx , catalog )
1096
- Expect (err ).To (BeNil ())
1097
- Eventually (func (g Gomega ) {
1098
- By ("verifying operator reconcile logs on catalog delete" )
1099
- g .Expect (testLogs ).To (HaveLen (logCount + len (opNames )))
1100
- for _ , p := range opNames {
1101
- g .Expect (testLogs [len (testLogs )- len (opNames ):]).To (ContainElement (ContainSubstring (fmt .Sprintf ("\" Operator\" ={\" name\" :\" %s\" }" , p ))))
1102
- }
1103
- }).WithTimeout (2 * time .Second ).WithPolling (1 * time .Second ).Should (Succeed ())
1104
- })
1105
- AfterEach (func () {
1106
- for _ , p := range opNames {
1107
- op := & operatorsv1alpha1.Operator {ObjectMeta : metav1.ObjectMeta {Name : p }, Spec : operatorsv1alpha1.OperatorSpec {PackageName : p }}
1108
- Expect (cl .Delete (ctx , op )).To (BeNil ())
1109
- }
1110
- cancel () // stop manager
1111
- })
1112
- })
1113
1021
})
1114
1022
1115
1023
func verifyInvariants (ctx context.Context , op * operatorsv1alpha1.Operator ) {
@@ -1148,12 +1056,6 @@ var testEntitySource = input.NewCacheQuerier(map[deppy.Identifier]input.Entity{
1148
1056
"olm.package" : `{"packageName":"prometheus","version":"0.47.0"}` ,
1149
1057
"olm.gvk" : `[]` ,
1150
1058
}),
1151
- "operatorhub/project-quay/3.8.3" : * input .NewEntity ("operatorhub/project-quay/3.8.3" , map [string ]string {
1152
- "olm.bundle.path" : `"quay.io/openshift-community-operators/project-quay@sha256:4f5698b5fec2e5f9a4df78b5ef9609b3a697c81cdb137b98e82e79104f0eb3b5"` ,
1153
- "olm.channel" : `{"channelName":"stable","priority":0}` ,
1154
- "olm.package" : `{"packageName":"project-quay","version":"3.8.3"}` ,
1155
- "olm.gvk" : `[]` ,
1156
- }),
1157
1059
"operatorhub/badimage/0.1.0" : * input .NewEntity ("operatorhub/badimage/0.1.0" , map [string ]string {
1158
1060
"olm.bundle.path" : `{"name": "quay.io/operatorhubio/badimage:v0.1.0"}` ,
1159
1061
"olm.package" : `{"packageName":"badimage","version":"0.1.0"}` ,
0 commit comments