Skip to content

Commit 4c16b21

Browse files
committed
feat: add both labels
1 parent ef5843b commit 4c16b21

File tree

4 files changed

+36
-12
lines changed

4 files changed

+36
-12
lines changed

test/e2e/frmwrk/cluster_basic_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var _ = Describe("Basic Cluster", Ordered, Label("basic"), func() {
3737
done()
3838
})
3939

40-
It("create new cluster", Label("create"), func() {
40+
It("create new cluster", Label("basic", "create"), func() {
4141
ec = createE2ECluster(ctx, e2eCtx, ClusterConfig{
4242
SpecName: "basic-cluster-creation-" + v,
4343
NamespaceName: fmt.Sprintf("basic-%d", i),
@@ -51,7 +51,7 @@ var _ = Describe("Basic Cluster", Ordered, Label("basic"), func() {
5151
Expect(ec).ToNot(BeNil())
5252
})
5353

54-
It("move from bootstrap to workload cluster", Label("move"), func() {
54+
It("move from bootstrap to workload cluster", Label("basic", "move"), func() {
5555
Expect(ec).NotTo(BeNil(), "e2e cluster required")
5656

5757
clusterctl.InitManagementClusterAndWatchControllerLogs(ctx, clusterctl.InitManagementClusterAndWatchControllerLogsInput{
@@ -84,7 +84,7 @@ var _ = Describe("Basic Cluster", Ordered, Label("basic"), func() {
8484
Expect(err).ToNot(HaveOccurred(), "cluster should be present")
8585
})
8686

87-
It("move from workload to bootstrap cluster", Label("move"), func() {
87+
It("move from workload to bootstrap cluster", Label("basic", "move"), func() {
8888
Expect(ec).NotTo(BeNil(), "e2e cluster required")
8989

9090
clusterctl.Move(ctx, clusterctl.MoveInput{
@@ -110,7 +110,7 @@ var _ = Describe("Basic Cluster", Ordered, Label("basic"), func() {
110110
Expect(err).ToNot(HaveOccurred(), "cluster should be present")
111111
})
112112

113-
It("delete cluster", Label("teardown"), func() {
113+
It("delete cluster", Label("basic", "teardown"), func() {
114114
ec.Teardown(ctx)
115115
})
116116
})

test/e2e/frmwrk/cluster_ha_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var _ = Describe("High Availability Cluster", Ordered, Label("ha"), func() {
3131
done()
3232
})
3333

34-
It("create new cluster", Label("create"), func() {
34+
It("create new cluster", Label("ha", "create"), func() {
3535
ec = createE2ECluster(ctx, e2eCtx, ClusterConfig{
3636
SpecName: "ha-cluster-creation-" + v,
3737
NamespaceName: fmt.Sprintf("ha-%d", i),
@@ -45,7 +45,10 @@ var _ = Describe("High Availability Cluster", Ordered, Label("ha"), func() {
4545
Expect(ec).ToNot(BeNil())
4646
})
4747

48-
It("delete cluster", Label("teardown"), func() {
48+
It("delete cluster", Label("ha", "teardown"), func() {
49+
if ec == nil {
50+
Skip("E2ECluster not initialized, skipping teardown")
51+
}
4952
ec.Teardown(ctx)
5053
})
5154
})

test/e2e/frmwrk/frmwrk_suite_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/onsi/ginkgo/v2"
8+
ginkgotypes "github.com/onsi/ginkgo/v2/types"
89
. "github.com/onsi/gomega"
910

1011
"k8s.io/klog/v2"
@@ -36,6 +37,12 @@ var _ = ginkgo.AfterSuite(func() {
3637
return
3738
}
3839
if e2eCtx != nil {
40+
filter, err := ginkgotypes.ParseLabelFilter(ginkgo.GinkgoLabelFilter())
41+
Expect(err).ToNot(HaveOccurred(), "failed to parse ginkgo label filter")
42+
43+
if !filter([]string{"teardown"}) {
44+
return
45+
}
3946
e2eCtx.Teardown(context.TODO())
4047
}
4148
})

test/e2e/frmwrk/shared_cases.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,22 @@ func createE2ECluster(ctx context.Context, e2eCtx *E2EContext, cfg ClusterConfig
1919
ec.SetupNamespace(ctx)
2020
ec.GenerateAndApplyClusterTemplate(ctx)
2121

22-
By("Wait for cluster")
23-
controlPlane := framework.GetKubeadmControlPlaneByCluster(ctx, framework.GetKubeadmControlPlaneByClusterInput{
24-
Lister: e2eCtx.Environment.Bootstrap.GetClient(),
25-
ClusterName: ec.Refs.Cluster.Name,
26-
Namespace: ec.Refs.Cluster.Namespace,
22+
DeferCleanup(func() {
23+
ec.Dump(context.Background())
2724
})
2825

26+
By("Wait for cluster")
2927
framework.DiscoveryAndWaitForCluster(ctx, framework.DiscoveryAndWaitForClusterInput{
3028
Getter: e2eCtx.Environment.Bootstrap.GetClient(),
3129
Namespace: ec.Refs.Cluster.Namespace,
3230
Name: ec.Refs.Cluster.Name,
3331
}, e2eCtx.E2EConfig.GetIntervals("default", "wait-cluster")...)
3432

33+
controlPlane := framework.GetKubeadmControlPlaneByCluster(ctx, framework.GetKubeadmControlPlaneByClusterInput{
34+
Lister: e2eCtx.Environment.Bootstrap.GetClient(),
35+
ClusterName: ec.Refs.Cluster.Name,
36+
Namespace: ec.Refs.Cluster.Namespace,
37+
})
3538
Expect(controlPlane).To(Not(BeNil()))
3639

3740
By("Wait for CNI and CCM")
@@ -59,6 +62,17 @@ func createE2ECluster(ctx context.Context, e2eCtx *E2EContext, cfg ClusterConfig
5962
Getter: e2eCtx.Environment.Bootstrap.GetClient(),
6063
}, e2eCtx.E2EConfig.GetIntervals("default", "wait-cluster-provisioned")...)
6164

62-
ec.Dump(ctx)
65+
framework.WaitForOneKubeadmControlPlaneMachineToExist(ctx, framework.WaitForOneKubeadmControlPlaneMachineToExistInput{
66+
Lister: e2eCtx.Environment.Bootstrap.GetClient(),
67+
Cluster: ec.Refs.Cluster,
68+
ControlPlane: controlPlane,
69+
}, e2eCtx.E2EConfig.GetIntervals("default", "wait-control-plane-machine")...)
70+
71+
framework.WaitForControlPlaneAndMachinesReady(ctx, framework.WaitForControlPlaneAndMachinesReadyInput{
72+
Cluster: ec.Refs.Cluster,
73+
GetLister: e2eCtx.Environment.Bootstrap.GetClient(),
74+
ControlPlane: controlPlane,
75+
}, e2eCtx.E2EConfig.GetIntervals("default", "wait-control-plane-and-machines-ready")...)
76+
6377
return ec
6478
}

0 commit comments

Comments
 (0)