Skip to content

Commit 09b98ce

Browse files
author
Cecile Robert-Michon
committed
ensure cluster is populated during a failed conformance test
1 parent bb52467 commit 09b98ce

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

test/e2e/conformance_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
. "github.com/onsi/gomega"
3636
corev1 "k8s.io/api/core/v1"
3737
"k8s.io/utils/pointer"
38-
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha4"
3938
capi_e2e "sigs.k8s.io/cluster-api/test/e2e"
4039
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
4140
"sigs.k8s.io/cluster-api/test/framework/kubetest"
@@ -46,7 +45,7 @@ var _ = Describe("Conformance Tests", func() {
4645
var (
4746
ctx = context.TODO()
4847
cancelWatches context.CancelFunc
49-
cluster *clusterv1.Cluster
48+
result *clusterctl.ApplyClusterTemplateAndWaitResult
5049
clusterName string
5150
namespace *corev1.Namespace
5251
specName = "conformance-tests"
@@ -74,6 +73,8 @@ var _ = Describe("Conformance Tests", func() {
7473

7574
Expect(os.Setenv(AzureResourceGroup, clusterName)).NotTo(HaveOccurred())
7675
Expect(os.Setenv(AzureVNetName, fmt.Sprintf("%s-vnet", clusterName))).NotTo(HaveOccurred())
76+
77+
result = new(clusterctl.ApplyClusterTemplateAndWaitResult)
7778
})
7879

7980
Measure(specName, func(b Benchmarker) {
@@ -109,7 +110,6 @@ var _ = Describe("Conformance Tests", func() {
109110
Expect(err).NotTo(HaveOccurred())
110111

111112
runtime := b.Time("cluster creation", func() {
112-
result := &clusterctl.ApplyClusterTemplateAndWaitResult{}
113113
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
114114
ClusterProxy: bootstrapClusterProxy,
115115
ConfigCluster: clusterctl.ConfigClusterInput{
@@ -128,7 +128,6 @@ var _ = Describe("Conformance Tests", func() {
128128
WaitForControlPlaneIntervals: e2eConfig.GetIntervals(specName, "wait-control-plane"),
129129
WaitForMachineDeployments: e2eConfig.GetIntervals(specName, "wait-worker-nodes"),
130130
}, result)
131-
cluster = result.Cluster
132131
})
133132

134133
b.RecordValue("cluster creation", runtime.Seconds())
@@ -170,13 +169,13 @@ var _ = Describe("Conformance Tests", func() {
170169
}, 1)
171170

172171
AfterEach(func() {
173-
if cluster == nil {
172+
if result.Cluster == nil {
174173
// this means the cluster failed to come up. We make an attempt to find the cluster to be able to fetch logs for the failed bootstrapping.
175-
_ = bootstrapClusterProxy.GetClient().Get(ctx, types.NamespacedName{Name: clusterName, Namespace: namespace.Name}, cluster)
174+
_ = bootstrapClusterProxy.GetClient().Get(ctx, types.NamespacedName{Name: clusterName, Namespace: namespace.Name}, result.Cluster)
176175
}
177176

178177
// Dumps all the resources in the spec namespace, then cleanups the cluster object and the spec namespace itself.
179-
dumpSpecResourcesAndCleanup(ctx, specName, bootstrapClusterProxy, artifactFolder, namespace, cancelWatches, cluster, e2eConfig.GetIntervals, skipCleanup)
178+
dumpSpecResourcesAndCleanup(ctx, specName, bootstrapClusterProxy, artifactFolder, namespace, cancelWatches, result.Cluster, e2eConfig.GetIntervals, skipCleanup)
180179

181180
Expect(os.Unsetenv(AzureResourceGroup)).NotTo(HaveOccurred())
182181
Expect(os.Unsetenv(AzureVNetName)).NotTo(HaveOccurred())

0 commit comments

Comments
 (0)