Skip to content

Commit 8f1c23b

Browse files
committed
Improve error logging in multi-network e2e test
1 parent 9945531 commit 8f1c23b

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

test/e2e/suites/e2e/e2e_test.go

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,13 @@ var _ = Describe("e2e tests", func() {
196196
})
197197

198198
Describe("Workload cluster (multiple attached networks)", func() {
199-
var extraNet1, extraNet2 *networks.Network
199+
var (
200+
clusterName string
201+
configCluster clusterctl.ConfigClusterInput
202+
md []*clusterv1.MachineDeployment
203+
204+
extraNet1, extraNet2 *networks.Network
205+
)
200206

201207
BeforeEach(func() {
202208
var err error
@@ -225,17 +231,17 @@ var _ = Describe("e2e tests", func() {
225231

226232
os.Setenv("CLUSTER_EXTRA_NET_1", extraNet1.ID)
227233
os.Setenv("CLUSTER_EXTRA_NET_2", extraNet2.ID)
228-
})
229234

230-
It("should attach all machines to multiple networks", func() {
231235
shared.Byf("Creating a cluster")
232-
clusterName := fmt.Sprintf("cluster-%s", namespace.Name)
233-
configCluster := defaultConfigCluster(clusterName, namespace.Name)
236+
clusterName = fmt.Sprintf("cluster-%s", namespace.Name)
237+
configCluster = defaultConfigCluster(clusterName, namespace.Name)
234238
configCluster.ControlPlaneMachineCount = pointer.Int64Ptr(1)
235239
configCluster.WorkerMachineCount = pointer.Int64Ptr(1)
236240
configCluster.Flavor = shared.FlavorMultiNetwork
237-
md := createCluster(ctx, configCluster)
241+
md = createCluster(ctx, configCluster)
242+
})
238243

244+
It("should attach all machines to multiple networks", func() {
239245
workerMachines := framework.GetMachinesByMachineDeployments(ctx, framework.GetMachinesByMachineDeploymentsInput{
240246
Lister: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
241247
ClusterName: clusterName,
@@ -276,21 +282,17 @@ var _ = Describe("e2e tests", func() {
276282
Expect(err).NotTo(HaveOccurred())
277283
Expect(ports).To(HaveLen(len(expectedPorts)))
278284

279-
var seen []string
285+
var seenNetworks []string
280286
var seenAddresses clusterv1.MachineAddresses
281287
for j := range ports {
282288
port := &ports[j]
283289

284-
// Check that the port has an expected network ID
285-
expectedDescription, ok := expectedPorts[port.NetworkID]
286-
Expect(ok).To(BeTrue())
287-
288-
// Check that the port has the expected description for that network ID
289-
Expect(port.Description).To(Equal(expectedDescription))
290+
// Check that the port has an expected network ID and description
291+
Expect(expectedPorts).To(HaveKeyWithValue(port.NetworkID, port.Description))
290292

291-
// Check that we don't have duplicate networks
292-
Expect(seen).ToNot(ContainElement(port.NetworkID))
293-
seen = append(seen, port.NetworkID)
293+
// We don't expect to see another port with this network on this machine
294+
Expect(seenNetworks).ToNot(ContainElement(port.NetworkID))
295+
seenNetworks = append(seenNetworks, port.NetworkID)
294296

295297
for k := range port.FixedIPs {
296298
seenAddresses = append(seenAddresses, clusterv1.MachineAddress{

0 commit comments

Comments
 (0)