Skip to content

Commit ea46700

Browse files
Merge pull request #1365 from vr4manta/OCPBUGS-55461
OCPBUGS-55461: Changed machineset tests to be serial
2 parents c34e593 + 267681b commit ea46700

File tree

4 files changed

+75
-25
lines changed

4 files changed

+75
-25
lines changed

test/e2e/util.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/openshift/api/machine/v1beta1"
1111
configclient "github.com/openshift/client-go/config/clientset/versioned"
1212
machinesetclient "github.com/openshift/client-go/machine/clientset/versioned/typed/machine/v1beta1"
13+
v1 "k8s.io/api/core/v1"
1314
"k8s.io/apimachinery/pkg/api/errors"
1415
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1516
"k8s.io/apimachinery/pkg/runtime"
@@ -176,6 +177,13 @@ func CreateMachine(ctx context.Context, cfg *rest.Config, mc *machinesetclient.M
176177
ProviderSpec: v1beta1.ProviderSpec{
177178
Value: provider,
178179
},
180+
Taints: []v1.Taint{
181+
{
182+
Effect: v1.TaintEffectNoSchedule,
183+
Key: "mapi-e2e",
184+
Value: "yes",
185+
},
186+
},
179187
},
180188
}
181189

@@ -223,6 +231,13 @@ func CreateMachineSet(ctx context.Context, cfg *rest.Config, mc *machinesetclien
223231
ProviderSpec: v1beta1.ProviderSpec{
224232
Value: provider,
225233
},
234+
Taints: []v1.Taint{
235+
{
236+
Effect: v1.TaintEffectNoSchedule,
237+
Key: "mapi-e2e",
238+
Value: "yes",
239+
},
240+
},
226241
},
227242
},
228243
},

test/e2e/vsphere/machines.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ import (
1919
)
2020

2121
const (
22-
machineRole = "e2e-test"
22+
machineRole = "feature-gate-test"
2323
machineReadyTimeout = time.Minute * 6
2424
)
2525

26-
var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:VSphereMultiDisk][platform:vsphere] Managed cluster should", func() {
26+
var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:VSphereMultiDisk][platform:vsphere][Disruptive] Managed cluster should", Label("Conformance"), Label("Serial"), func() {
2727
defer GinkgoRecover()
2828
ctx := context.Background()
2929

@@ -46,7 +46,7 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:VSphereMultiDisk][platf
4646
Expect(err).NotTo(HaveOccurred())
4747
})
4848

49-
It("create machines with data disks [apigroup:machine.openshift.io]", func() {
49+
It("create machines with data disks [apigroup:machine.openshift.io][Suite:openshift/conformance/serial]", func() {
5050
machineName := "machine-multi-test"
5151
dataDisks := []v1beta1.VSphereDisk{
5252
{
@@ -151,33 +151,43 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:VSphereMultiDisk][platf
151151
err = util.ScaleMachineSet(cfg, ddMachineSet.Name, 0)
152152
Expect(err).NotTo(HaveOccurred())
153153

154+
// Verify / wait for machine is removed
155+
By("verifying machine is destroyed")
156+
Eventually(func() (int32, error) {
157+
ms, err := mc.MachineSets(util.MachineAPINamespace).Get(ctx, ddMachineSet.Name, metav1.GetOptions{})
158+
if err != nil {
159+
return -1, err
160+
}
161+
return ms.Status.ReadyReplicas, nil
162+
}, machineReadyTimeout).Should(BeEquivalentTo(0))
163+
154164
// Delete machineset
155165
By("deleting the machineset")
156166
err = mc.MachineSets(util.MachineAPINamespace).Delete(ctx, ddMachineSet.Name, metav1.DeleteOptions{})
157167
Expect(err).NotTo(HaveOccurred())
158168
},
159-
Entry("with thin data disk [apigroup:machine.openshift.io]", "ms-thin-test", []v1beta1.VSphereDisk{
169+
Entry("with thin data disk [apigroup:machine.openshift.io][Suite:openshift/conformance/serial]", "ms-thin-test", []v1beta1.VSphereDisk{
160170
{
161171
Name: "thickDataDisk",
162172
SizeGiB: 1,
163173
ProvisioningMode: v1beta1.ProvisioningModeThick,
164174
},
165175
}),
166-
Entry("with thick data disk [apigroup:machine.openshift.io]", "ms-thick-test", []v1beta1.VSphereDisk{
176+
Entry("with thick data disk [apigroup:machine.openshift.io][Suite:openshift/conformance/serial]", "ms-thick-test", []v1beta1.VSphereDisk{
167177
{
168178
Name: "thickDataDisk",
169179
SizeGiB: 1,
170180
ProvisioningMode: v1beta1.ProvisioningModeThick,
171181
},
172182
}),
173-
Entry("with eagerly zeroed data disk [apigroup:machine.openshift.io]", "ms-zeroed-test", []v1beta1.VSphereDisk{
183+
Entry("with eagerly zeroed data disk [apigroup:machine.openshift.io][Suite:openshift/conformance/serial]", "ms-zeroed-test", []v1beta1.VSphereDisk{
174184
{
175185
Name: "zeroedDataDisk",
176186
SizeGiB: 1,
177187
ProvisioningMode: v1beta1.ProvisioningModeEagerlyZeroed,
178188
},
179189
}),
180-
Entry("with a data disk using each provisioning mode [apigroup:machine.openshift.io]", "ms-multi-test", []v1beta1.VSphereDisk{
190+
Entry("with a data disk using each provisioning mode [apigroup:machine.openshift.io][Suite:openshift/conformance/serial]", "ms-multi-test", []v1beta1.VSphereDisk{
181191
{
182192
Name: "thinDataDisk",
183193
SizeGiB: 1,

test/e2e/vsphere/multi-nic.go

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,19 @@ func failIfNodeNotInMachineNetwork(nodes corev1.NodeList, machineNetworks []stri
4141

4242
func failIfIncorrectPortgroupsAttachedToVMs(
4343
ctx context.Context,
44-
infra configv1.PlatformSpec,
44+
infra *configv1.Infrastructure,
4545
nodeList *corev1.NodeList,
4646
vsphereCreds *corev1.Secret) {
4747

4848
By("checking if VMs have the correct portgroups attached")
4949

50-
for _, failureDomain := range infra.VSphere.FailureDomains {
51-
nodes, err := getNodesInFailureDomain(infra.VSphere, failureDomain, nodeList)
50+
providerSpec := infra.Spec.PlatformSpec
51+
for _, failureDomain := range providerSpec.VSphere.FailureDomains {
52+
nodes, err := getNodesInFailureDomain(providerSpec.VSphere, failureDomain, nodeList)
5253
fmt.Printf("nodes: %d", len(nodes))
5354
Expect(err).NotTo(HaveOccurred())
5455

55-
vmPortgroupMap, err := GetPortGroupsAttachedToVMsInFailureDomain(ctx, failureDomain, vsphereCreds, infra.VSphere.VCenters)
56+
vmPortgroupMap, err := GetPortGroupsAttachedToVMsInFailureDomain(ctx, infra.Status.InfrastructureName, failureDomain, vsphereCreds, providerSpec.VSphere.VCenters)
5657
if err != nil {
5758
Expect(err).NotTo(HaveOccurred())
5859
}
@@ -82,13 +83,21 @@ func failIfIncorrectPortgroupsAttachedToVMs(
8283
}
8384

8485
func failIfNodeNetworkingInconsistentWithMachineNetwork(infra configv1.PlatformSpec, machineNetworks []string) {
86+
// This can happen in scenarios where multinetwork is not enabled.
87+
if len(infra.VSphere.NodeNetworking.External.NetworkSubnetCIDR) == 0 ||
88+
len(infra.VSphere.NodeNetworking.Internal.NetworkSubnetCIDR) == 0 {
89+
Skip("skipping test due to incomplete config")
90+
}
91+
8592
internalNodeNetworking := infra.VSphere.NodeNetworking.Internal
8693
externalNodeNetworking := infra.VSphere.NodeNetworking.External
8794

95+
// machineNetworks contain the VIPs now so we'll need to check each network to see if we find one that matches internal/external.
8896
By("comparing nodeNetworking slices to the machine network")
8997
for _, nodeNetworkingSpec := range []configv1.VSpherePlatformNodeNetworkingSpec{internalNodeNetworking, externalNodeNetworking} {
90-
slices.Sort(nodeNetworkingSpec.NetworkSubnetCIDR)
91-
Expect(slices.Equal(nodeNetworkingSpec.NetworkSubnetCIDR, machineNetworks)).To(BeTrue())
98+
for _, network := range nodeNetworkingSpec.NetworkSubnetCIDR {
99+
Expect(slices.Contains(machineNetworks, network)).To(BeTrue())
100+
}
92101
}
93102
}
94103

@@ -126,7 +135,7 @@ func failIfMachineDoesNotHaveAllPortgroups(machine machinev1beta1.Machine, failu
126135
Expect(slices.Equal(expectedPortgroups, portgroups)).To(BeTrue())
127136
}
128137

129-
var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:VSphereMultiNetworks][platform:vsphere] Managed cluster should", func() {
138+
var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:VSphereMultiNetworks][platform:vsphere] Managed cluster should", Label("Conformance"), func() {
130139
defer GinkgoRecover()
131140
ctx := context.Background()
132141

@@ -190,24 +199,24 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:VSphereMultiNetworks][p
190199
}
191200
})
192201

193-
It("node addresses should be correlated with the machine network", func() {
202+
It("node addresses should be correlated with the machine network [apigroup:machine.openshift.io][Suite:openshift/conformance/parallel]", func() {
194203
By("checking for correlation between node internal/external IPs and the machine network")
195204
failIfNodeNotInMachineNetwork(*nodes, machineNetworks)
196205
})
197206

198-
It("machine network should be correlated with node networking", func() {
207+
It("machine network should be correlated with node networking [apigroup:machine.openshift.io][Suite:openshift/conformance/parallel]", func() {
199208
failIfNodeNetworkingInconsistentWithMachineNetwork(infra.Spec.PlatformSpec, machineNetworks)
200209
})
201210

202-
It("machines should have all specified portgroup associated with their failure domain", func() {
211+
It("machines should have all specified portgroup associated with their failure domain [apigroup:machine.openshift.io][Suite:openshift/conformance/parallel]", func() {
203212
failIfMachinesDoNotHaveAllPortgroups(infra.Spec.PlatformSpec, machines)
204213
})
205214

206-
It("node VMs should have all specified portgroups attached which are associated with their failure domain", func() {
207-
failIfIncorrectPortgroupsAttachedToVMs(ctx, infra.Spec.PlatformSpec, nodes, vsphereCreds)
215+
It("node VMs should have all specified portgroups attached which are associated with their failure domain [apigroup:machine.openshift.io][Suite:openshift/conformance/parallel]", func() {
216+
failIfIncorrectPortgroupsAttachedToVMs(ctx, infra, nodes, vsphereCreds)
208217
})
209218

210-
It("new machines should pass multi network tests", func() {
219+
It("new machines should pass multi network tests [apigroup:machine.openshift.io][Suite:openshift/conformance/serial]", Label("Serial"), func() {
211220
machineSets, err := e2eutil.GetMachineSets(cfg)
212221
Expect(err).NotTo(HaveOccurred())
213222

@@ -244,6 +253,6 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:VSphereMultiNetworks][p
244253
failIfNodeNotInMachineNetwork(*nodes, machineNetworks)
245254
failIfNodeNetworkingInconsistentWithMachineNetwork(infra.Spec.PlatformSpec, machineNetworks)
246255
failIfMachinesDoNotHaveAllPortgroups(infra.Spec.PlatformSpec, machines)
247-
failIfIncorrectPortgroupsAttachedToVMs(ctx, infra.Spec.PlatformSpec, nodes, vsphereCreds)
256+
failIfIncorrectPortgroupsAttachedToVMs(ctx, infra, nodes, vsphereCreds)
248257
})
249258
})

test/e2e/vsphere/util.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ import (
66
"net"
77
"net/url"
88
"path"
9+
"slices"
910
"strconv"
1011
"time"
1112

1213
. "github.com/onsi/ginkgo/v2"
1314
. "github.com/onsi/gomega"
14-
1515
configv1 "github.com/openshift/api/config/v1"
1616
"github.com/openshift/api/machine/v1beta1"
1717
machinev1beta1 "github.com/openshift/api/machine/v1beta1"
18-
util "github.com/openshift/machine-api-operator/test/e2e"
1918
"github.com/pkg/errors"
2019
"github.com/vmware/govmomi"
2120
"github.com/vmware/govmomi/find"
2221
"github.com/vmware/govmomi/object"
2322
vapirest "github.com/vmware/govmomi/vapi/rest"
23+
"github.com/vmware/govmomi/vapi/tags"
2424
"github.com/vmware/govmomi/vim25"
2525
"github.com/vmware/govmomi/vim25/mo"
2626
"github.com/vmware/govmomi/vim25/soap"
@@ -29,6 +29,7 @@ import (
2929
"k8s.io/client-go/rest"
3030

3131
"github.com/openshift/machine-api-operator/pkg/controller/vsphere"
32+
util "github.com/openshift/machine-api-operator/test/e2e"
3233
)
3334

3435
func isIpInCidrRange(ip string, cidr string) (bool, error) {
@@ -255,6 +256,7 @@ func getCredentialsForVCenter(ctx context.Context, vsphereCreds *corev1.Secret,
255256

256257
func GetPortGroupsAttachedToVMsInFailureDomain(
257258
ctx context.Context,
259+
clusterID string,
258260
failureDomain configv1.VSpherePlatformFailureDomainSpec,
259261
vsphereCreds *corev1.Secret,
260262
vCenters []configv1.VSpherePlatformVCenterSpec) (map[string][]string, error) {
@@ -281,7 +283,7 @@ func GetPortGroupsAttachedToVMsInFailureDomain(
281283

282284
portGroupMap := make(map[string][]string)
283285

284-
client, _, logout, err := CreateVSphereClients(ctx, vcenterUrl, user, pass)
286+
client, rClient, logout, err := CreateVSphereClients(ctx, vcenterUrl, user, pass)
285287
defer logout()
286288

287289
if err != nil {
@@ -290,17 +292,31 @@ func GetPortGroupsAttachedToVMsInFailureDomain(
290292

291293
finder := NewFinder(client)
292294

295+
// Get tagged objects and then grab VMs
296+
tm := tags.NewManager(rClient)
297+
refs, err := tm.ListAttachedObjects(ctx, clusterID)
298+
var vmList []types.ManagedObjectReference
299+
for _, ref := range refs {
300+
if ref.Reference().Type == "VirtualMachine" {
301+
vmList = append(vmList, ref.Reference())
302+
}
303+
}
304+
293305
vms, err := finder.VirtualMachineList(ctx, fmt.Sprintf("/%s/vm/...", failureDomain.Topology.Datacenter))
294306
if err != nil {
295307
return nil, fmt.Errorf("unable to get VMs in %s. %v", failureDomain.Topology.ComputeCluster, err)
296308
}
297309

298310
for _, vm := range vms {
311+
// Make sure vm has the cluster id tag. Note: template will be included.
312+
if !slices.Contains(vmList, vm.Reference()) {
313+
continue
314+
}
315+
299316
vm, err := finder.VirtualMachine(ctx, vm.InventoryPath)
300317
if err != nil {
301318
return nil, fmt.Errorf("unable to get VMs in %s. %v", failureDomain.Topology.ComputeCluster, err)
302319
}
303-
fmt.Printf("UUID: %s\n", vm.UUID(ctx))
304320
virtualDevices, err := vm.Device(ctx)
305321

306322
var portGroups []string

0 commit comments

Comments
 (0)