@@ -7,27 +7,17 @@ import (
77 "path"
88 "strings"
99
10- "github.com/drone/envsubst/v2"
1110 . "github.com/onsi/ginkgo/v2"
1211 . "github.com/onsi/gomega"
1312
1413 apierrors "k8s.io/apimachinery/pkg/api/errors"
1514 "sigs.k8s.io/controller-runtime/pkg/client"
1615
1716 clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
18- "sigs.k8s.io/cluster-api/test/framework"
1917 "sigs.k8s.io/cluster-api/test/framework/clusterctl"
2018)
2119
22- var _ = Describe ("Basic Cluster" , Ordered , func () {
23-
24- BeforeAll (func () {
25- e2eCtx = NewE2EContext ()
26- e2eCtx .ProvideBootstrapCluster ()
27- e2eCtx .CreateClusterctlConfig (context .TODO ())
28- e2eCtx .InitManagementCluster (context .TODO ())
29- })
30-
20+ var _ = Describe ("Basic Cluster" , Ordered , Label ("basic" ), func () {
3121 kubernetesVersions := strings .Split (os .Getenv ("E2E_KUBERNETES_VERSIONS" ), "," )
3222 Expect (kubernetesVersions ).ToNot (BeEmpty (), "E2E_KUBERNETES_VERSIONS must be set" )
3323
@@ -42,11 +32,11 @@ var _ = Describe("Basic Cluster", Ordered, func() {
4232 ctx = context .Background ()
4333 })
4434
45- It ("create new cluster" , func () {
35+ It ("create new cluster" , Label ( "create" ), func () {
4636 ec = createE2ECluster (ctx , e2eCtx , ClusterConfig {
4737 SpecName : "basic-cluster-creation-" + v ,
4838 NamespaceName : fmt .Sprintf ("e2e-basic-cluster-creation-%d" , i ),
49- ClusterName : fmt .Sprintf ("simple -%d" , i ),
39+ ClusterName : fmt .Sprintf ("basic -%d" , i ),
5040 KubernetesVersion : v ,
5141 ControlPlaneMachineImage : os .Getenv ("E2E_CONTROL_PLANE_MACHINE_IMAGE_PREFIX" ) + strings .TrimPrefix (v , "v" ),
5242 ControlPlaneMachineCount : 1 ,
@@ -56,7 +46,7 @@ var _ = Describe("Basic Cluster", Ordered, func() {
5646 Expect (ec ).ToNot (BeNil ())
5747 })
5848
59- It ("move from bootstrap to workload cluster" , func () {
49+ It ("move from bootstrap to workload cluster" , Label ( "move" ), func () {
6050 Expect (ec ).NotTo (BeNil (), "e2e cluster required" )
6151
6252 clusterctl .InitManagementClusterAndWatchControllerLogs (ctx , clusterctl.InitManagementClusterAndWatchControllerLogsInput {
@@ -89,7 +79,7 @@ var _ = Describe("Basic Cluster", Ordered, func() {
8979 Expect (err ).ToNot (HaveOccurred (), "cluster should be present" )
9080 })
9181
92- It ("move from workload to bootstrap cluster" , func () {
82+ It ("move from workload to bootstrap cluster" , Label ( "move" ), func () {
9383 Expect (ec ).NotTo (BeNil (), "e2e cluster required" )
9484
9585 clusterctl .Move (ctx , clusterctl.MoveInput {
@@ -115,63 +105,9 @@ var _ = Describe("Basic Cluster", Ordered, func() {
115105 Expect (err ).ToNot (HaveOccurred (), "cluster should be present" )
116106 })
117107
118- It ("delete cluster" , func () {
108+ It ("delete cluster" , Label ( "delete" ), func () {
119109 ec .Teardown (ctx )
120- // TODO: expect resources to be gone
121110 })
122111 })
123112 }
124-
125- It ("teardown management cluster" , func () {
126- e2eCtx .Teardown (context .Background ())
127- })
128113})
129-
130- func createE2ECluster (ctx context.Context , e2eCtx * E2EContext , cfg ClusterConfig ) * E2ECluster {
131- ec := e2eCtx .NewE2ECluster (cfg )
132-
133- ec .SetupMetalStackPreconditions (ctx )
134- ec .SetupNamespace (ctx )
135- ec .GenerateAndApplyClusterTemplate (ctx )
136-
137- By ("Wait for cluster" )
138- controlPlane := framework .GetKubeadmControlPlaneByCluster (ctx , framework.GetKubeadmControlPlaneByClusterInput {
139- Lister : e2eCtx .Environment .Bootstrap .GetClient (),
140- ClusterName : ec .Refs .Cluster .Name ,
141- Namespace : ec .Refs .Cluster .Namespace ,
142- })
143-
144- framework .DiscoveryAndWaitForCluster (ctx , framework.DiscoveryAndWaitForClusterInput {
145- Getter : e2eCtx .Environment .Bootstrap .GetClient (),
146- Namespace : ec .Refs .Cluster .Namespace ,
147- Name : ec .Refs .Cluster .Name ,
148- }, e2eCtx .E2EConfig .GetIntervals ("default" , "wait-cluster" )... )
149-
150- Expect (controlPlane ).To (Not (BeNil ()))
151-
152- By ("Wait for CNI and CCM" )
153- targetTemplate , err := os .ReadFile (path .Join (e2eCtx .Environment .artifactsPath , "config" , "target" , "base.yaml" ))
154- Expect (err ).ToNot (HaveOccurred ())
155-
156- vars := ec .Variables ()
157- targetResources , err := envsubst .Eval (string (targetTemplate ), func (varName string ) string {
158- return vars [varName ]
159- })
160- Expect (err ).ToNot (HaveOccurred ())
161-
162- Eventually (func () error {
163- return ec .Refs .Workload .CreateOrUpdate (ctx , []byte (targetResources ))
164- }, "5m" , "15s" ).Should (Succeed ())
165-
166- By ("Wait for kubeadm control plane" )
167- framework .DiscoveryAndWaitForControlPlaneInitialized (ctx , framework.DiscoveryAndWaitForControlPlaneInitializedInput {
168- Lister : e2eCtx .Environment .Bootstrap .GetClient (),
169- Cluster : ec .Refs .Cluster ,
170- }, e2eCtx .E2EConfig .GetIntervals ("default" , "wait-control-plane" )... )
171-
172- framework .WaitForClusterToProvision (ctx , framework.WaitForClusterToProvisionInput {
173- Cluster : ec .Refs .Cluster ,
174- Getter : e2eCtx .Environment .Bootstrap .GetClient (),
175- }, e2eCtx .E2EConfig .GetIntervals ("default" , "wait-cluster-provisioned" )... )
176- return ec
177- }
0 commit comments