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