@@ -24,6 +24,8 @@ import (
24
24
"fmt"
25
25
"os"
26
26
"path/filepath"
27
+ "strings"
28
+ "time"
27
29
28
30
. "github.com/onsi/ginkgo/v2"
29
31
. "github.com/onsi/gomega"
@@ -115,6 +117,24 @@ var _ = Describe("Workload cluster creation", func() {
115
117
ControlPlane : client .ObjectKeyFromObject (result .ControlPlane ),
116
118
}, e2eConfig .GetIntervals (specName , "wait-control-plane" )... )
117
119
120
+ WaitForClusterReady (ctx , WaitForClusterReadyInput {
121
+ Getter : bootstrapClusterProxy .GetClient (),
122
+ Name : result .Cluster .Name ,
123
+ Namespace : result .Cluster .Namespace ,
124
+ }, e2eConfig .GetIntervals (specName , "wait-cluster" )... )
125
+
126
+ By ("Fetching all Machines" )
127
+ machineList := GetMachinesByCluster (ctx , GetMachinesByClusterInput {
128
+ Lister : bootstrapClusterProxy .GetClient (),
129
+ ClusterName : result .Cluster .Name ,
130
+ Namespace : result .Cluster .Namespace ,
131
+ })
132
+ Expect (machineList .Items ).ShouldNot (BeEmpty (), "There must be at least one Machine" )
133
+ machinesNames := []string {}
134
+ for _ , machine := range machineList .Items {
135
+ machinesNames = append (machinesNames , machine .Name )
136
+ }
137
+
118
138
By ("Upgrading to next boostrap/controlplane provider version" )
119
139
UpgradeManagementCluster (ctx , clusterctl.UpgradeManagementClusterAndWaitInput {
120
140
ClusterProxy : bootstrapClusterProxy ,
@@ -129,6 +149,41 @@ var _ = Describe("Workload cluster creation", func() {
129
149
ControlPlane : client .ObjectKeyFromObject (result .ControlPlane ),
130
150
}, e2eConfig .GetIntervals (specName , "wait-control-plane" )... )
131
151
152
+ WaitForClusterReady (ctx , WaitForClusterReadyInput {
153
+ Getter : bootstrapClusterProxy .GetClient (),
154
+ Name : result .Cluster .Name ,
155
+ Namespace : result .Cluster .Namespace ,
156
+ }, e2eConfig .GetIntervals (specName , "wait-cluster" )... )
157
+
158
+ By ("Verifying machine rollout did not happen" )
159
+ Consistently (func () error {
160
+ updatedMachineList := GetMachinesByCluster (ctx , GetMachinesByClusterInput {
161
+ Lister : bootstrapClusterProxy .GetClient (),
162
+ ClusterName : result .Cluster .Name ,
163
+ Namespace : result .Cluster .Namespace ,
164
+ })
165
+ if len (updatedMachineList .Items ) == 0 {
166
+ return fmt .Errorf ("There must be at least one Machine after provider upgrade" )
167
+ }
168
+ updatedMachinesNames := []string {}
169
+ for _ , machine := range updatedMachineList .Items {
170
+ updatedMachinesNames = append (updatedMachinesNames , machine .Name )
171
+ }
172
+ sameMachines , err := ContainElements (machinesNames ).Match (updatedMachinesNames )
173
+ if err != nil {
174
+ return fmt .Errorf ("matching machines: %w" , err )
175
+ }
176
+ if ! sameMachines {
177
+ fmt .Printf ("Pre-upgrade machines: [%s]\n " , strings .Join (machinesNames , "," ))
178
+ fmt .Printf ("Post-upgrade machines: [%s]\n " , strings .Join (updatedMachinesNames , "," ))
179
+ return fmt .Errorf ("Machines should not have been rolled out after provider upgrade" )
180
+ }
181
+ if len (updatedMachinesNames ) != len (machinesNames ) {
182
+ return fmt .Errorf ("Number of Machines '%d' should match after provider upgrade '%d'" , len (machinesNames ), len (updatedMachinesNames ))
183
+ }
184
+ return nil
185
+ }).WithTimeout (2 * time .Minute ).WithPolling (10 * time .Second ).Should (Succeed ())
186
+
132
187
By ("Scaling down control plane to 2 and workers up to 2" )
133
188
ApplyClusterTemplateAndWait (ctx , ApplyClusterTemplateAndWaitInput {
134
189
ClusterProxy : bootstrapClusterProxy ,
0 commit comments