6
6
7
7
. "github.com/onsi/ginkgo/v2"
8
8
. "github.com/onsi/gomega"
9
- catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1"
10
9
operatorv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
11
10
rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1"
12
11
"k8s.io/apimachinery/pkg/api/errors"
@@ -45,7 +44,6 @@ var _ = Describe("Operator Install", func() {
45
44
By ("eventually reporting a successful resolution and bundle path" )
46
45
Eventually (func (g Gomega ) {
47
46
g .Expect (c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )).To (Succeed ())
48
- g .Expect (len (operator .Status .Conditions )).To (Equal (2 ))
49
47
cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeResolved )
50
48
g .Expect (cond ).ToNot (BeNil ())
51
49
g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
@@ -66,9 +64,16 @@ var _ = Describe("Operator Install", func() {
66
64
67
65
bd := rukpakv1alpha1.BundleDeployment {}
68
66
g .Expect (c .Get (ctx , types.NamespacedName {Name : operatorName }, & bd )).To (Succeed ())
69
- g .Expect (len (bd .Status .Conditions )).To (Equal (2 ))
70
- g .Expect (bd .Status .Conditions [0 ].Reason ).To (Equal ("UnpackSuccessful" ))
71
- g .Expect (bd .Status .Conditions [1 ].Reason ).To (Equal ("InstallationSucceeded" ))
67
+
68
+ cond = apimeta .FindStatusCondition (bd .Status .Conditions , rukpakv1alpha1 .TypeHasValidBundle )
69
+ g .Expect (cond ).ToNot (BeNil ())
70
+ g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
71
+ g .Expect (cond .Reason ).To (Equal (rukpakv1alpha1 .ReasonUnpackSuccessful ))
72
+
73
+ cond = apimeta .FindStatusCondition (bd .Status .Conditions , rukpakv1alpha1 .TypeInstalled )
74
+ g .Expect (cond ).ToNot (BeNil ())
75
+ g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
76
+ g .Expect (cond .Reason ).To (Equal (rukpakv1alpha1 .ReasonInstallationSucceeded ))
72
77
}).Should (Succeed ())
73
78
})
74
79
})
@@ -86,7 +91,6 @@ var _ = Describe("Operator Install", func() {
86
91
By ("eventually reporting a successful resolution and bundle path" )
87
92
Eventually (func (g Gomega ) {
88
93
g .Expect (c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )).To (Succeed ())
89
- g .Expect (len (operator .Status .Conditions )).To (Equal (2 ))
90
94
cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeResolved )
91
95
g .Expect (cond ).ToNot (BeNil ())
92
96
g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
@@ -107,63 +111,20 @@ var _ = Describe("Operator Install", func() {
107
111
108
112
bd := rukpakv1alpha1.BundleDeployment {}
109
113
g .Expect (c .Get (ctx , types.NamespacedName {Name : operatorName }, & bd )).To (Succeed ())
110
- g .Expect (len (bd .Status .Conditions )).To (Equal (2 ))
111
- g .Expect (bd .Status .Conditions [0 ].Reason ).To (Equal ("UnpackSuccessful" ))
112
- g .Expect (bd .Status .Conditions [1 ].Reason ).To (Equal ("InstallationSucceeded" ))
113
- }).Should (Succeed ())
114
- })
115
- })
116
-
117
- It ("resolves again when a new catalog is available" , func () {
118
- pkgName := "prometheus"
119
- operator .Spec = operatorv1alpha1.OperatorSpec {
120
- PackageName : pkgName ,
121
- }
122
-
123
- // Delete the catalog first
124
- Expect (c .Delete (ctx , operatorCatalog )).To (Succeed ())
125
-
126
- Eventually (func (g Gomega ) {
127
- // target package should not be present on cluster
128
- err := c .Get (ctx , types.NamespacedName {Name : pkgName }, & catalogd.Package {})
129
- g .Expect (errors .IsNotFound (err )).To (BeTrue ())
130
- }).Should (Succeed ())
131
-
132
- By ("creating the Operator resource" )
133
- Expect (c .Create (ctx , operator )).To (Succeed ())
134
114
135
- By ("failing to find Operator during resolution" )
136
- Eventually (func (g Gomega ) {
137
- g .Expect (c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )).To (Succeed ())
138
- cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeResolved )
139
- g .Expect (cond ).ToNot (BeNil ())
140
- g .Expect (cond .Status ).To (Equal (metav1 .ConditionFalse ))
141
- g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonResolutionFailed ))
142
- g .Expect (cond .Message ).To (Equal (fmt .Sprintf ("package '%s' not found" , pkgName )))
143
- }).Should (Succeed ())
115
+ cond = apimeta .FindStatusCondition (bd .Status .Conditions , rukpakv1alpha1 .TypeHasValidBundle )
116
+ g .Expect (cond ).ToNot (BeNil ())
117
+ g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
118
+ g .Expect (cond .Reason ).To (Equal (rukpakv1alpha1 .ReasonUnpackSuccessful ))
144
119
145
- By ("creating an Operator catalog with the desired package" )
146
- var err error
147
- operatorCatalog , err = createTestCatalog (ctx , testCatalogName , testCatalogRef )
148
- Expect (err ).ToNot (HaveOccurred ())
149
- Eventually (func (g Gomega ) {
150
- g .Expect (c .Get (ctx , types.NamespacedName {Name : operatorCatalog .Name }, operatorCatalog )).To (Succeed ())
151
- cond := apimeta .FindStatusCondition (operatorCatalog .Status .Conditions , catalogd .TypeUnpacked )
152
- g .Expect (cond ).ToNot (BeNil ())
153
- g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
154
- g .Expect (cond .Reason ).To (Equal (catalogd .ReasonUnpackSuccessful ))
155
- }).Should (Succeed ())
120
+ cond = apimeta .FindStatusCondition (bd .Status .Conditions , rukpakv1alpha1 .TypeInstalled )
121
+ g .Expect (cond ).ToNot (BeNil ())
122
+ g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
123
+ g .Expect (cond .Reason ).To (Equal (rukpakv1alpha1 .ReasonInstallationSucceeded ))
156
124
157
- By ("eventually resolving the package successfully" )
158
- Eventually (func (g Gomega ) {
159
- g .Expect (c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )).To (Succeed ())
160
- cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeResolved )
161
- g .Expect (cond ).ToNot (BeNil ())
162
- g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
163
- g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonSuccess ))
164
- }).Should (Succeed ())
125
+ }).Should (Succeed ())
126
+ })
165
127
})
166
-
167
128
AfterEach (func () {
168
129
Expect (c .Delete (ctx , operator )).To (Succeed ())
169
130
Eventually (func (g Gomega ) {
0 commit comments