From c0af60f3c6ab2db2b9426a31c5f349831c7b2cba Mon Sep 17 00:00:00 2001 From: Mohammed Boukhalfa Date: Fri, 21 Jul 2023 18:16:17 +0300 Subject: [PATCH] Edit integration test to call DumpSpecResourcesAndCleanup and collect logs Co-authored-by: huutomerkki --- test/e2e/integration_test.go | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/test/e2e/integration_test.go b/test/e2e/integration_test.go index f5dda9af1e..6336269f8d 100644 --- a/test/e2e/integration_test.go +++ b/test/e2e/integration_test.go @@ -3,19 +3,18 @@ package e2e import ( "path/filepath" - bmov1alpha1 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1" . "github.com/onsi/ginkgo/v2" "sigs.k8s.io/cluster-api/test/framework" - "sigs.k8s.io/controller-runtime/pkg/client" ) var _ = Describe("When testing integration [integration]", func() { + It("CI Test Provision", func() { numberOfWorkers = int(*e2eConfig.GetInt32PtrVariable("WORKER_MACHINE_COUNT")) numberOfControlplane = int(*e2eConfig.GetInt32PtrVariable("CONTROL_PLANE_MACHINE_COUNT")) k8sVersion := e2eConfig.GetVariable("KUBERNETES_VERSION") By("Provision Workload cluster") - targetCluster, result := createTargetCluster(k8sVersion) + targetCluster, _ = createTargetCluster(k8sVersion) By("Pivot objects to target cluster") pivoting(ctx, func() PivotingInput { return PivotingInput{ @@ -49,31 +48,9 @@ var _ = Describe("When testing integration [integration]", func() { ClusterctlConfigPath: clusterctlConfigPath, } }) - By("Deprovision target cluster") - bootstrapClient := bootstrapClusterProxy.GetClient() - intervals := e2eConfig.GetIntervals(specName, "wait-deprovision-cluster") - // In pivoting step we labeled the BMO CRDs (so that the objects are moved - // by CAPI pivoting feature), which made CAPI DeleteClusterAndWait() - // fail as it has a check to make sure all resources managed by CAPI - // is gone after Cluster deletion. Therefore, we opted not to use - // DeleteClusterAndWait(), but only delete the cluster and then wait - // for it to be deleted. - framework.DeleteCluster(ctx, framework.DeleteClusterInput{ - Deleter: bootstrapClient, - Cluster: result.Cluster, - }) - Logf("Waiting for the Cluster object to be deleted") - framework.WaitForClusterDeleted(ctx, framework.WaitForClusterDeletedInput{ - Getter: bootstrapClient, - Cluster: result.Cluster, - }, intervals...) - numberOfAvailableBMHs := numberOfWorkers + numberOfControlplane - intervals = e2eConfig.GetIntervals(specName, "wait-bmh-deprovisioning-available") - WaitForNumBmhInState(ctx, bmov1alpha1.StateAvailable, WaitForNumInput{ - Client: bootstrapClient, - Options: []client.ListOption{client.InNamespace(namespace)}, - Replicas: numberOfAvailableBMHs, - Intervals: intervals, - }) + }) + + AfterEach(func() { + DumpSpecResourcesAndCleanup(ctx, specName, bootstrapClusterProxy, artifactFolder, namespace, e2eConfig.GetIntervals, clusterName, clusterctlLogFolder, skipCleanup) }) })