@@ -2,6 +2,7 @@ package vsphere
2
2
3
3
import (
4
4
"context"
5
+ "fmt"
5
6
"time"
6
7
7
8
. "github.com/onsi/ginkgo/v2"
@@ -75,6 +76,13 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:VSphereMultiDisk][platf
75
76
// skip if operator is not running
76
77
util .SkipUnlessMachineAPIOperator (dc , c .CoreV1 ().Namespaces ())
77
78
79
+ By ("checking initial cluster size" )
80
+ nodeList , err := c .CoreV1 ().Nodes ().List (context .Background (), metav1.ListOptions {})
81
+ Expect (err ).NotTo (HaveOccurred ())
82
+
83
+ initialNumberOfNodes := len (nodeList .Items )
84
+ By (fmt .Sprintf ("initial cluster size is %v" , initialNumberOfNodes ))
85
+
78
86
// get provider for simple definition vs generating one from scratch
79
87
By ("generating provider for tests" )
80
88
provider := getProviderFromMachineSet (cfg )
@@ -108,6 +116,20 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:VSphereMultiDisk][platf
108
116
By ("delete the machine" )
109
117
err = mc .Machines (util .MachineAPINamespace ).Delete (ctx , machine .Name , metav1.DeleteOptions {})
110
118
Expect (err ).NotTo (HaveOccurred ())
119
+
120
+ // By this point, the node object should be deleted, but seems it may linger momentarily causing issue with other tests that grab current
121
+ // nodes to perform tests against.
122
+ By (fmt .Sprintf ("waiting for cluster to get back to original size. Final size should be %d worker nodes" , initialNumberOfNodes ))
123
+ Eventually (func () bool {
124
+ nodeList , err := c .CoreV1 ().Nodes ().List (context .Background (), metav1.ListOptions {})
125
+ Expect (err ).NotTo (HaveOccurred ())
126
+ By (fmt .Sprintf ("got %v nodes, expecting %v" , len (nodeList .Items ), initialNumberOfNodes ))
127
+ if len (nodeList .Items ) != initialNumberOfNodes {
128
+ return false
129
+ }
130
+
131
+ return true
132
+ }, 10 * time .Minute , 5 * time .Second ).Should (BeTrue (), "number of nodes should be the same as it was before test started" )
111
133
})
112
134
113
135
DescribeTable ("create machinesets" , func (msName string , dataDisks []v1beta1.VSphereDisk ) {
@@ -116,6 +138,13 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:VSphereMultiDisk][platf
116
138
// skip if operator is not running
117
139
util .SkipUnlessMachineAPIOperator (dc , c .CoreV1 ().Namespaces ())
118
140
141
+ By ("checking initial cluster size" )
142
+ nodeList , err := c .CoreV1 ().Nodes ().List (context .Background (), metav1.ListOptions {})
143
+ Expect (err ).NotTo (HaveOccurred ())
144
+
145
+ initialNumberOfNodes := len (nodeList .Items )
146
+ By (fmt .Sprintf ("initial cluster size is %v" , initialNumberOfNodes ))
147
+
119
148
// get provider for simple definition vs generating one from scratch
120
149
By ("generating provider for tests" )
121
150
provider := getProviderFromMachineSet (cfg )
@@ -144,7 +173,7 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:VSphereMultiDisk][platf
144
173
return - 1 , err
145
174
}
146
175
return ms .Status .ReadyReplicas , nil
147
- }, machineReadyTimeout ).Should (BeEquivalentTo (1 ))
176
+ }, machineReadyTimeout ).Should (BeEquivalentTo (1 ), "machine ReadyReplicas should be 1 when all machines are ready" )
148
177
149
178
// Scale down machineset
150
179
By ("scaling down the machineset" )
@@ -159,12 +188,27 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:VSphereMultiDisk][platf
159
188
return - 1 , err
160
189
}
161
190
return ms .Status .ReadyReplicas , nil
162
- }, machineReadyTimeout ).Should (BeEquivalentTo (0 ))
191
+ }, machineReadyTimeout ).Should (BeEquivalentTo (0 ), "machine ReadyReplicas should be zero when all machines are destroyed" )
163
192
164
193
// Delete machineset
165
194
By ("deleting the machineset" )
166
195
err = mc .MachineSets (util .MachineAPINamespace ).Delete (ctx , ddMachineSet .Name , metav1.DeleteOptions {})
167
196
Expect (err ).NotTo (HaveOccurred ())
197
+
198
+ // By this point, the node object should be deleted, but seems it may linger momentarily causing issue with other tests that grab current
199
+ // nodes to perform tests against.
200
+ By (fmt .Sprintf ("waiting for cluster to get back to original size. Final size should be %d worker nodes" , initialNumberOfNodes ))
201
+ Eventually (func () bool {
202
+ nodeList , err := c .CoreV1 ().Nodes ().List (context .Background (), metav1.ListOptions {})
203
+ Expect (err ).NotTo (HaveOccurred ())
204
+ By (fmt .Sprintf ("got %v nodes, expecting %v" , len (nodeList .Items ), initialNumberOfNodes ))
205
+ if len (nodeList .Items ) != initialNumberOfNodes {
206
+ return false
207
+ }
208
+
209
+ return true
210
+ }, 10 * time .Minute , 5 * time .Second ).Should (BeTrue (), "number of nodes should be the same as it was before test started" )
211
+
168
212
},
169
213
Entry ("with thin data disk [apigroup:machine.openshift.io][Serial][Suite:openshift/conformance/serial]" , "ms-thin-test" , []v1beta1.VSphereDisk {
170
214
{
0 commit comments