@@ -3,13 +3,9 @@ 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
11
operatorsv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
@@ -25,7 +21,6 @@ import (
25
21
ctrl "sigs.k8s.io/controller-runtime"
26
22
"sigs.k8s.io/controller-runtime/pkg/client"
27
23
"sigs.k8s.io/controller-runtime/pkg/client/fake"
28
- "sigs.k8s.io/controller-runtime/pkg/log"
29
24
)
30
25
31
26
var _ = Describe ("Operator Controller Test" , func () {
@@ -1022,94 +1017,6 @@ var _ = Describe("Operator Controller Test", func() {
1022
1017
Expect (cond .Message ).To (Equal ("installation has not been attempted as spec is invalid" ))
1023
1018
})
1024
1019
})
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
1020
})
1114
1021
1115
1022
func verifyInvariants (ctx context.Context , op * operatorsv1alpha1.Operator ) {
0 commit comments