@@ -162,6 +162,87 @@ var _ = Describe("e2e tests [PR-Blocking]", func() {
162
162
// We expect 4 security group rules that allow Calico traffic on the control plane
163
163
// from both the control plane and worker machines and vice versa, that makes 8 rules.
164
164
Expect (calicoSGRules ).To (Equal (8 ))
165
+
166
+ shared .Logf ("Check the bastion" )
167
+ openStackCluster , err = shared .ClusterForSpec (ctx , e2eCtx , namespace )
168
+ Expect (err ).NotTo (HaveOccurred ())
169
+ bastionSpec := openStackCluster .Spec .Bastion
170
+ Expect (openStackCluster .Status .Bastion ).NotTo (BeNil (), "OpenStackCluster.Status.Bastion has not been populated" )
171
+ bastionServerName := openStackCluster .Status .Bastion .Name
172
+ bastionServer , err := shared .DumpOpenStackServers (e2eCtx , servers.ListOpts {Name : bastionServerName })
173
+ Expect (err ).NotTo (HaveOccurred ())
174
+ Expect (bastionServer ).To (HaveLen (1 ), "Did not find the bastion in OpenStack" )
175
+
176
+ shared .Logf ("Disable the bastion" )
177
+ openStackCluster , err = shared .ClusterForSpec (ctx , e2eCtx , namespace )
178
+ Expect (err ).NotTo (HaveOccurred ())
179
+ openStackClusterDisabledBastion := openStackCluster .DeepCopy ()
180
+ openStackClusterDisabledBastion .Spec .Bastion .Enabled = false
181
+ Expect (e2eCtx .Environment .BootstrapClusterProxy .GetClient ().Update (ctx , openStackClusterDisabledBastion )).To (Succeed ())
182
+ Eventually (
183
+ func () (bool , error ) {
184
+ bastionServer , err := shared .DumpOpenStackServers (e2eCtx , servers.ListOpts {Name : bastionServerName })
185
+ Expect (err ).NotTo (HaveOccurred ())
186
+ if len (bastionServer ) == 0 {
187
+ return true , nil
188
+ }
189
+ return false , errors .New ("Bastion was not deleted in OpenStack" )
190
+ }, e2eCtx .E2EConfig .GetIntervals (specName , "wait-bastion" )... ,
191
+ ).Should (BeTrue ())
192
+ Eventually (
193
+ func () (bool , error ) {
194
+ openStackCluster , err = shared .ClusterForSpec (ctx , e2eCtx , namespace )
195
+ Expect (err ).NotTo (HaveOccurred ())
196
+ if openStackCluster .Status .Bastion == nil {
197
+ return true , nil
198
+ }
199
+ return false , errors .New ("Bastion was not removed in OpenStackCluster.Status" )
200
+ }, e2eCtx .E2EConfig .GetIntervals (specName , "wait-bastion" )... ,
201
+ ).Should (BeTrue ())
202
+
203
+ shared .Logf ("Delete the bastion" )
204
+ openStackCluster , err = shared .ClusterForSpec (ctx , e2eCtx , namespace )
205
+ Expect (err ).NotTo (HaveOccurred ())
206
+ openStackClusterWithoutBastion := openStackCluster .DeepCopy ()
207
+ openStackClusterWithoutBastion .Spec .Bastion = nil
208
+ Expect (e2eCtx .Environment .BootstrapClusterProxy .GetClient ().Update (ctx , openStackClusterWithoutBastion )).To (Succeed ())
209
+ openStackCluster , err = shared .ClusterForSpec (ctx , e2eCtx , namespace )
210
+ Expect (err ).NotTo (HaveOccurred ())
211
+ Eventually (
212
+ func () (bool , error ) {
213
+ openStackCluster , err = shared .ClusterForSpec (ctx , e2eCtx , namespace )
214
+ Expect (err ).NotTo (HaveOccurred ())
215
+ if openStackCluster .Spec .Bastion == nil {
216
+ return true , nil
217
+ }
218
+ return false , errors .New ("Bastion was not removed in OpenStackCluster.Spec" )
219
+ }, e2eCtx .E2EConfig .GetIntervals (specName , "wait-bastion" )... ,
220
+ ).Should (BeTrue ())
221
+
222
+ shared .Logf ("Create the bastion with a new flavor" )
223
+ bastionNewFlavorName := e2eCtx .E2EConfig .GetVariable (shared .OpenStackBastionFlavorAlt )
224
+ bastionNewFlavor , err := shared .GetFlavorFromName (e2eCtx , bastionNewFlavorName )
225
+ Expect (err ).NotTo (HaveOccurred ())
226
+ openStackCluster , err = shared .ClusterForSpec (ctx , e2eCtx , namespace )
227
+ Expect (err ).NotTo (HaveOccurred ())
228
+ openStackClusterWithNewBastionFlavor := openStackCluster .DeepCopy ()
229
+ openStackClusterWithNewBastionFlavor .Spec .Bastion = bastionSpec
230
+ openStackClusterWithNewBastionFlavor .Spec .Bastion .Instance .Flavor = bastionNewFlavorName
231
+ Expect (e2eCtx .Environment .BootstrapClusterProxy .GetClient ().Update (ctx , openStackClusterWithNewBastionFlavor )).To (Succeed ())
232
+ Eventually (
233
+ func () (bool , error ) {
234
+ bastionServer , err := shared .DumpOpenStackServers (e2eCtx , servers.ListOpts {Name : bastionServerName , Flavor : bastionNewFlavor .ID })
235
+ Expect (err ).NotTo (HaveOccurred ())
236
+ if len (bastionServer ) == 1 {
237
+ return true , nil
238
+ }
239
+ return false , errors .New ("Bastion with new flavor was not created in OpenStack" )
240
+ }, e2eCtx .E2EConfig .GetIntervals (specName , "wait-bastion" )... ,
241
+ ).Should (BeTrue ())
242
+ openStackCluster , err = shared .ClusterForSpec (ctx , e2eCtx , namespace )
243
+ Expect (err ).NotTo (HaveOccurred ())
244
+ Expect (openStackCluster .Spec .Bastion ).To (Equal (openStackClusterWithNewBastionFlavor .Spec .Bastion ))
245
+ Expect (openStackCluster .Status .Bastion ).NotTo (BeNil (), "OpenStackCluster.Status.Bastion with new flavor has not been populated" )
165
246
})
166
247
})
167
248
0 commit comments