@@ -17,7 +17,7 @@ import (
1717)
1818
1919const (
20- defaultTimeout = 30 * time .Second
20+ defaultTimeout = 120 * time .Second
2121 defaultPoll = 1 * time .Second
2222 testCatalogRef = "localhost/testdata/catalogs/test-catalog:e2e"
2323)
@@ -27,25 +27,17 @@ var _ = Describe("Operator Install", func() {
2727 ctx context.Context
2828 pkgName string
2929 operatorName string
30+ catalogName string
3031 operator * operatorv1alpha1.Operator
3132 operatorCatalog * catalogd.Catalog
3233 )
3334 When ("An operator is installed from an operator catalog" , func () {
3435 BeforeEach (func () {
3536 ctx = context .Background ()
36- pkgName = "prometheus"
37- operatorName = fmt .Sprintf ("operator-%s" , rand .String (8 ))
38- operator = & operatorv1alpha1.Operator {
39- ObjectMeta : metav1.ObjectMeta {
40- Name : operatorName ,
41- },
42- Spec : operatorv1alpha1.OperatorSpec {
43- PackageName : pkgName ,
44- },
45- }
37+ catalogName = fmt .Sprintf ("catalog-%s" , rand .String (8 ))
4638 operatorCatalog = & catalogd.Catalog {
4739 ObjectMeta : metav1.ObjectMeta {
48- Name : "test-catalog" ,
40+ Name : catalogName ,
4941 },
5042 Spec : catalogd.CatalogSpec {
5143 Source : catalogd.CatalogSource {
@@ -59,54 +51,140 @@ var _ = Describe("Operator Install", func() {
5951 err := c .Create (ctx , operatorCatalog )
6052 Expect (err ).ToNot (HaveOccurred ())
6153 Eventually (func (g Gomega ) {
62- err = c .Get (ctx , types.NamespacedName {Name : "test-catalog" }, operatorCatalog )
54+ err = c .Get (ctx , types.NamespacedName {Name : catalogName }, operatorCatalog )
6355 g .Expect (err ).ToNot (HaveOccurred ())
64- g .Expect (len (operatorCatalog .Status .Conditions )).To (Equal (1 ))
65- g .Expect (operatorCatalog .Status .Conditions [0 ].Message ).To (ContainSubstring ("successfully unpacked the catalog image" ))
66- }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
67- })
68- It ("resolves the specified package with correct bundle path" , func () {
69- By ("creating the Operator resource" )
70- err := c .Create (ctx , operator )
71- Expect (err ).ToNot (HaveOccurred ())
72-
73- By ("eventually reporting a successful resolution and bundle path" )
74- Eventually (func (g Gomega ) {
75- err = c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )
76- g .Expect (err ).ToNot (HaveOccurred ())
77- g .Expect (len (operator .Status .Conditions )).To (Equal (2 ))
78- cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeResolved )
56+ cond := apimeta .FindStatusCondition (operatorCatalog .Status .Conditions , catalogd .TypeUnpacked )
7957 g .Expect (cond ).ToNot (BeNil ())
8058 g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
81- g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonSuccess ))
82- g .Expect (cond .Message ).To (ContainSubstring ("resolved to" ))
83- g .Expect (operator .Status .ResolvedBundleResource ).ToNot (BeEmpty ())
84- }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
59+ g .Expect (cond .Message ).To (ContainSubstring ("successfully unpacked the catalog image" ))
8560
86- By ("eventually installing the package successfully" )
87- Eventually (func (g Gomega ) {
88- err = c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )
89- g .Expect (err ).ToNot (HaveOccurred ())
90- cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeInstalled )
91- g .Expect (cond ).ToNot (BeNil ())
92- g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
93- g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonSuccess ))
94- g .Expect (cond .Message ).To (ContainSubstring ("installed from" ))
95- g .Expect (operator .Status .InstalledBundleResource ).ToNot (BeEmpty ())
96- bd := rukpakv1alpha1.BundleDeployment {}
97- err = c .Get (ctx , types.NamespacedName {Name : operatorName }, & bd )
61+ // For some reason the above condition check is returning true and the
62+ // Operators end up being created before the packages exist. Adding this check
63+ // to ensure that there are some packages that exist before actually returning from this
64+ // check.
65+ pkgList := & catalogd.PackageList {}
66+ err = c .List (ctx , pkgList )
9867 g .Expect (err ).ToNot (HaveOccurred ())
99- g .Expect (len (bd .Status .Conditions )).To (Equal (2 ))
100- g .Expect (bd .Status .Conditions [0 ].Reason ).To (Equal ("UnpackSuccessful" ))
101- g .Expect (bd .Status .Conditions [1 ].Reason ).To (Equal ("InstallationSucceeded" ))
68+ g .Expect (pkgList .Items ).To (HaveLen (2 ))
10269 }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
103-
10470 })
71+
10572 AfterEach (func () {
10673 err := c .Delete (ctx , operatorCatalog )
10774 Expect (err ).ToNot (HaveOccurred ())
108- err = c .Delete (ctx , operator )
109- Expect (err ).ToNot (HaveOccurred ())
11075 })
76+
77+ When ("the operator bundle format is registry+v1" , func () {
78+ BeforeEach (func () {
79+ pkgName = "prometheus"
80+ operatorName = fmt .Sprintf ("operator-%s" , rand .String (8 ))
81+ operator = & operatorv1alpha1.Operator {
82+ ObjectMeta : metav1.ObjectMeta {
83+ Name : operatorName ,
84+ },
85+ Spec : operatorv1alpha1.OperatorSpec {
86+ PackageName : pkgName ,
87+ },
88+ }
89+ })
90+ It ("resolves the specified package with correct bundle path" , func () {
91+ By ("creating the Operator resource" )
92+ err := c .Create (ctx , operator )
93+ Expect (err ).ToNot (HaveOccurred ())
94+
95+ By ("eventually reporting a successful resolution and bundle path" )
96+ Eventually (func (g Gomega ) {
97+ err = c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )
98+ g .Expect (err ).ToNot (HaveOccurred ())
99+ g .Expect (len (operator .Status .Conditions )).To (Equal (2 ))
100+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeResolved )
101+ g .Expect (cond ).ToNot (BeNil ())
102+ g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
103+ g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonSuccess ))
104+ g .Expect (cond .Message ).To (ContainSubstring ("resolved to" ))
105+ g .Expect (operator .Status .ResolvedBundleResource ).ToNot (BeEmpty ())
106+ }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
107+
108+ By ("eventually installing the package successfully" )
109+ Eventually (func (g Gomega ) {
110+ err = c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )
111+ g .Expect (err ).ToNot (HaveOccurred ())
112+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeInstalled )
113+ g .Expect (cond ).ToNot (BeNil ())
114+ g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
115+ g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonSuccess ))
116+ g .Expect (cond .Message ).To (ContainSubstring ("installed from" ))
117+ g .Expect (operator .Status .InstalledBundleResource ).ToNot (BeEmpty ())
118+ bd := rukpakv1alpha1.BundleDeployment {}
119+ err = c .Get (ctx , types.NamespacedName {Name : operatorName }, & bd )
120+ g .Expect (err ).ToNot (HaveOccurred ())
121+ g .Expect (len (bd .Status .Conditions )).To (Equal (2 ))
122+ g .Expect (bd .Status .Conditions [0 ].Reason ).To (Equal ("UnpackSuccessful" ))
123+ g .Expect (bd .Status .Conditions [1 ].Reason ).To (Equal ("InstallationSucceeded" ))
124+ }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
125+
126+ })
127+ AfterEach (func () {
128+ err := c .Delete (ctx , operator )
129+ Expect (err ).ToNot (HaveOccurred ())
130+ })
131+ })
132+
133+ When ("the operator bundle format is plain+v0" , func () {
134+ BeforeEach (func () {
135+ pkgName = "plain"
136+ operatorName = fmt .Sprintf ("operator-%s" , rand .String (8 ))
137+ operator = & operatorv1alpha1.Operator {
138+ ObjectMeta : metav1.ObjectMeta {
139+ Name : operatorName ,
140+ },
141+ Spec : operatorv1alpha1.OperatorSpec {
142+ PackageName : pkgName ,
143+ },
144+ }
145+ })
146+ It ("resolves the specified package with correct bundle path" , func () {
147+ By ("creating the Operator resource" )
148+ err := c .Create (ctx , operator )
149+ Expect (err ).ToNot (HaveOccurred ())
150+
151+ By ("eventually reporting a successful resolution and bundle path" )
152+ Eventually (func (g Gomega ) {
153+ err = c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )
154+ g .Expect (err ).ToNot (HaveOccurred ())
155+ g .Expect (len (operator .Status .Conditions )).To (Equal (2 ))
156+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeResolved )
157+ g .Expect (cond ).ToNot (BeNil ())
158+ g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
159+ g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonSuccess ))
160+ g .Expect (cond .Message ).To (ContainSubstring ("resolved to" ))
161+ g .Expect (operator .Status .ResolvedBundleResource ).ToNot (BeEmpty ())
162+ }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
163+
164+ By ("eventually installing the package successfully" )
165+ Eventually (func (g Gomega ) {
166+ err = c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )
167+ g .Expect (err ).ToNot (HaveOccurred ())
168+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeInstalled )
169+ g .Expect (cond ).ToNot (BeNil ())
170+ g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
171+ g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonSuccess ))
172+ g .Expect (cond .Message ).To (ContainSubstring ("installed from" ))
173+ g .Expect (operator .Status .InstalledBundleResource ).ToNot (BeEmpty ())
174+ bd := rukpakv1alpha1.BundleDeployment {}
175+ err = c .Get (ctx , types.NamespacedName {Name : operatorName }, & bd )
176+ g .Expect (err ).ToNot (HaveOccurred ())
177+ g .Expect (len (bd .Status .Conditions )).To (Equal (2 ))
178+ g .Expect (bd .Status .Conditions [0 ].Reason ).To (Equal ("UnpackSuccessful" ))
179+ g .Expect (bd .Status .Conditions [1 ].Reason ).To (Equal ("InstallationSucceeded" ))
180+ }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
181+
182+ })
183+ AfterEach (func () {
184+ err := c .Delete (ctx , operator )
185+ Expect (err ).ToNot (HaveOccurred ())
186+ })
187+ })
188+
111189 })
112190})
0 commit comments