Skip to content

Commit 18ed875

Browse files
committed
test: successful :)
1 parent 3bf9016 commit 18ed875

File tree

5 files changed

+65
-69
lines changed

5 files changed

+65
-69
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ E2E_METAL_API_HMAC_AUTH_TYPE ?= "$(or $(METALCTL_HMAC_AUTH_TYPE),Metal-Admin)"
113113
E2E_METAL_PROJECT_ID ?= "00000000-0000-0000-0000-000000000001"
114114
E2E_METAL_PARTITION ?= "mini-lab"
115115
E2E_METAL_PUBLIC_NETWORK ?= "internet-mini-lab"
116-
E2E_KUBERNETES_VERSIONS ?= "v1.32.9,v1.33.5,v1.34.1"
116+
E2E_KUBERNETES_VERSIONS ?= "v1.32.9"
117117
E2E_CONTROL_PLANE_MACHINE_IMAGE_PREFIX ?= "capms-ubuntu-"
118118
E2E_CONTROL_PLANE_MACHINE_SIZE ?= "v1-small-x86"
119119
E2E_WORKER_MACHINE_IMAGE_PREFIX ?= "capms-ubuntu-"
@@ -143,7 +143,7 @@ test-e2e: manifests generate fmt vet
143143
FIREWALL_IMAGE=$(E2E_FIREWALL_IMAGE) \
144144
FIREWALL_SIZE=$(E2E_FIREWALL_SIZE) \
145145
FIREWALL_NETWORKS=$(E2E_FIREWALL_NETWORKS) \
146-
go test ./test/e2e/frmwrk -v ginkgo -vv
146+
go test -v ./test/e2e/frmwrk -timeout 60m -v ginkgo -vv
147147

148148
.PHONY: lint
149149
lint: golangci-lint ## Run golangci-lint linter

config/manager/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
44
kind: Kustomization
55
images:
66
- name: controller
7-
newName: ghcr.io/metal-stack/capms-controller
7+
newName: ghcr.io/metal-stack/cluster-api-metal-stack-controller
88
newTag: latest

test/e2e/frmwrk/bootstrap_test.go

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import (
77
"path"
88
"strings"
99

10+
"github.com/drone/envsubst/v2"
1011
. "github.com/onsi/ginkgo/v2"
1112
. "github.com/onsi/gomega"
1213

13-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14-
controlplanev1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1"
1514
"sigs.k8s.io/cluster-api/test/framework"
1615
)
1716

@@ -36,13 +35,13 @@ var _ = Describe("Basic Cluster Creation", Ordered, func() {
3635
kubernetesVersions := strings.Split(os.Getenv("E2E_KUBERNETES_VERSIONS"), ",")
3736
Expect(kubernetesVersions).ToNot(BeEmpty(), "E2E_KUBERNETES_VERSIONS must be set")
3837

39-
for _, v := range kubernetesVersions {
38+
for i, v := range kubernetesVersions {
4039
It(fmt.Sprintf("create new cluster with kubernetes %s", v), func() {
4140
ctx := context.Background()
4241

4342
ec = createE2ECluster(ctx, e2eCtx, ClusterConfig{
4443
SpecName: "basic-cluster-creation-" + v,
45-
NamespaceName: "simple-" + v,
44+
NamespaceName: fmt.Sprintf("e2e-basic-cluster-creation-%d", i),
4645
ClusterName: "simple",
4746
KubernetesVersion: v,
4847
ControlPlaneMachineImage: os.Getenv("E2E_CONTROL_PLANE_MACHINE_IMAGE_PREFIX") + strings.TrimPrefix(v, "v"),
@@ -78,38 +77,29 @@ func createE2ECluster(ctx context.Context, e2eCtx *E2EContext, cfg ClusterConfig
7877

7978
Expect(controlPlane).To(Not(BeNil()))
8079

81-
targetResources, err := os.ReadFile(path.Join(e2eCtx.Environment.artifactsPath, "config", "target", "base.yaml"))
80+
By("Wait for CNI and CCM")
81+
targetTemplate, err := os.ReadFile(path.Join(e2eCtx.Environment.artifactsPath, "config", "target", "base.yaml"))
8282
Expect(err).ToNot(HaveOccurred())
8383

84-
err = ec.Refs.Workload.CreateOrUpdate(ctx, targetResources)
84+
vars := ec.Variables()
85+
targetResources, err := envsubst.Eval(string(targetTemplate), func(varName string) string {
86+
return vars[varName]
87+
})
8588
Expect(err).ToNot(HaveOccurred())
8689

87-
framework.WaitForKubeadmControlPlaneMachinesToExist(ctx, framework.WaitForKubeadmControlPlaneMachinesToExistInput{
88-
Lister: e2eCtx.Environment.Bootstrap.GetClient(),
89-
Cluster: cluster,
90-
ControlPlane: controlPlane,
91-
}, e2eCtx.E2EConfig.GetIntervals("default", "wait-control-plane")...)
90+
Eventually(func() error {
91+
return ec.Refs.Workload.CreateOrUpdate(ctx, []byte(targetResources))
92+
}, "5m", "15s").Should(Succeed())
93+
94+
By("Wait for kubeadm control plane")
9295
framework.DiscoveryAndWaitForControlPlaneInitialized(ctx, framework.DiscoveryAndWaitForControlPlaneInitializedInput{
9396
Lister: e2eCtx.Environment.Bootstrap.GetClient(),
9497
Cluster: cluster,
9598
}, e2eCtx.E2EConfig.GetIntervals("default", "wait-control-plane")...)
9699

97-
By("Wait for control plane")
98-
framework.WaitForControlPlaneToBeReady(ctx, framework.WaitForControlPlaneToBeReadyInput{
99-
Getter: e2eCtx.Environment.Bootstrap.GetClient(),
100-
ControlPlane: &controlplanev1.KubeadmControlPlane{
101-
ObjectMeta: metav1.ObjectMeta{
102-
Name: ec.ClusterName,
103-
Namespace: ec.NamespaceName,
104-
},
105-
},
106-
}, e2eCtx.E2EConfig.GetIntervals("default", "wait-control-plane")...)
107-
108-
framework.WaitForClusterMachinesReady(ctx, framework.WaitForClusterMachinesReadyInput{
109-
Cluster: cluster,
110-
GetLister: e2eCtx.Environment.Bootstrap.GetClient(),
111-
NodeGetter: e2eCtx.Environment.Bootstrap.GetClient(),
112-
}, e2eCtx.E2EConfig.GetIntervals("default", "wait-workers")...)
113-
100+
framework.WaitForClusterToProvision(ctx, framework.WaitForClusterToProvisionInput{
101+
Cluster: cluster,
102+
Getter: e2eCtx.Environment.Bootstrap.GetClient(),
103+
}, e2eCtx.E2EConfig.GetIntervals("default", "wait-cluster-provisioned")...)
114104
return ec
115105
}

test/e2e/frmwrk/config/capi-e2e-config.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ providers:
109109
files:
110110
- sourcePath: "../../../../metadata.yaml"
111111
- sourcePath: "../../../../config/clusterctl-templates/cluster-template.yaml"
112-
- sourcePath: "../../../../config/cluster-resource-sets/calico-resource-set.yaml"
113-
- sourcePath: "../../../../config/cluster-resource-sets/metal-ccm-resource-set.yaml"
114-
- sourcePath: "../../../../config/cluster-resource-sets/metallb-resource-set.yaml"
115112
replacements:
116113
- old: --metrics-addr=127.0.0.1:8080
117114
new: --metrics-addr=:8080
@@ -137,6 +134,7 @@ variables:
137134
intervals:
138135
default/wait-controllers: ["4m", "10s"]
139136
default/wait-cluster: ["5m", "10s"]
137+
metal-stack/wait-firewall-allocate: ["5m", "10s"]
140138
default/wait-control-plane: ["10m", "10s"]
141139
default/wait-worker-nodes: ["5m", "10s"]
142140
default/wait-machine-pool-nodes: ["5m", "10s"]

test/e2e/frmwrk/shared.go

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
metalmodels "github.com/metal-stack/metal-go/api/models"
2121

2222
corev1 "k8s.io/api/core/v1"
23-
apierrors "k8s.io/apimachinery/pkg/api/errors"
2423
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2524
"k8s.io/apimachinery/pkg/runtime"
2625
"k8s.io/utils/ptr"
@@ -285,6 +284,33 @@ func (e2e *E2EContext) NewE2ECluster(cfg ClusterConfig) *E2ECluster {
285284
}
286285
}
287286

287+
func (e2e *E2ECluster) Variables() map[string]string {
288+
vars := make(map[string]string)
289+
290+
for k := range e2e.E2EContext.E2EConfig.Variables {
291+
vars[k] = e2e.E2EContext.envOrVar(k)
292+
}
293+
294+
vars["METAL_API_URL"] = e2e.E2EContext.envOrVar("METAL_API_URL")
295+
vars["METAL_API_HMAC"] = e2e.E2EContext.envOrVar("METAL_API_HMAC")
296+
vars["METAL_API_HMAC_AUTH_TYPE"] = e2e.E2EContext.envOrVar("METAL_API_HMAC_AUTH_TYPE")
297+
298+
vars["NAMESPACE"] = e2e.NamespaceName
299+
vars["METAL_PROJECT_ID"] = e2e.E2EContext.Environment.project
300+
vars["METAL_PARTITION"] = e2e.E2EContext.Environment.partition
301+
vars["METAL_NODE_NETWORK_ID"] = *e2e.Refs.NodeNetwork.ID
302+
vars["FIREWALL_MACHINE_SIZE"] = e2e.FirewallSize
303+
vars["FIREWALL_MACHINE_IMAGE"] = e2e.FirewallImage
304+
vars["FIREWALL_MACHINE_NETWORKS"] = "[" + strings.Join(e2e.FirewallNetworks, ",") + "]"
305+
vars["CONTROL_PLANE_IP"] = e2e.ControlPlaneIP
306+
vars["CONTROL_PLANE_MACHINE_SIZE"] = e2e.ControlPlaneMachineSize
307+
vars["CONTROL_PLANE_MACHINE_IMAGE"] = e2e.ControlPlaneMachineImage
308+
vars["WORKER_MACHINE_SIZE"] = e2e.WorkerMachineSize
309+
vars["WORKER_MACHINE_IMAGE"] = e2e.WorkerMachineImage
310+
311+
return vars
312+
}
313+
288314
// common
289315

290316
func (e2e *E2ECluster) SetupNamespace(ctx context.Context) *corev1.Namespace {
@@ -322,7 +348,6 @@ func (e2e *E2ECluster) SetupMetalStackPreconditions(ctx context.Context) {
322348

323349
func (e2e *E2ECluster) Teardown(ctx context.Context) {
324350
e2e.teardownCluster(ctx)
325-
e2e.teardownClusterResourceSets(ctx)
326351
e2e.teardownControlPlaneIP(ctx)
327352
e2e.teardownFirewall(ctx)
328353
e2e.teardownNodeNetwork(ctx)
@@ -422,10 +447,15 @@ func (e2e *E2ECluster) setupFirewall(ctx context.Context) {
422447
},
423448
}
424449

425-
fw, err := e2e.E2EContext.Environment.Metal.Firewall().AllocateFirewall(metalfw.NewAllocateFirewallParamsWithContext(ctx).WithBody(fcr), nil)
426-
Expect(err).ToNot(HaveOccurred(), "failed to allocate firewall")
450+
Eventually(func() error {
451+
fw, err := e2e.E2EContext.Environment.Metal.Firewall().AllocateFirewall(metalfw.NewAllocateFirewallParamsWithContext(ctx).WithBody(fcr), nil)
452+
if err != nil {
453+
return err
454+
}
427455

428-
e2e.Refs.Firewall = fw.Payload
456+
e2e.Refs.Firewall = fw.Payload
457+
return nil
458+
}, e2e.E2EContext.E2EConfig.GetIntervals("metal-stack", "wait-firewall-allocate")...).ShouldNot(HaveOccurred(), "firewall not available")
429459
}
430460

431461
func (e2e *E2ECluster) teardownFirewall(ctx context.Context) {
@@ -440,6 +470,10 @@ func (e2e *E2ECluster) teardownFirewall(ctx context.Context) {
440470
}
441471

442472
func (e2e *E2ECluster) setupControlPlaneIP(ctx context.Context) {
473+
if e2e.ControlPlaneIP != "" {
474+
return
475+
}
476+
443477
By("Setup Control Plane IP")
444478

445479
ipr := &metalmodels.V1IPAllocateRequest{
@@ -451,12 +485,15 @@ func (e2e *E2ECluster) setupControlPlaneIP(ctx context.Context) {
451485
fmt.Sprintf("%s=%s", "e2e-test", e2e.SpecName),
452486
},
453487
Networkid: ptr.To(e2e.E2EContext.Environment.publicNetwork),
488+
Type: ptr.To(metalmodels.V1IPAllocateRequestTypeStatic),
454489
}
455490

456491
ip, err := e2e.E2EContext.Environment.Metal.IP().AllocateIP(metalip.NewAllocateIPParamsWithContext(ctx).WithBody(ipr), nil)
457492
Expect(err).ToNot(HaveOccurred(), "failed to allocate control plane IP")
493+
Expect(ip.Payload.Ipaddress).NotTo(BeNil(), "allocated control plane IP has no IP address")
458494

459495
e2e.Refs.ControlPlaneIP = ip.Payload
496+
e2e.ControlPlaneIP = *e2e.Refs.ControlPlaneIP.Ipaddress
460497
}
461498

462499
func (e2e *E2ECluster) teardownControlPlaneIP(ctx context.Context) {
@@ -488,22 +525,7 @@ func (e2e *E2ECluster) GenerateAndApplyClusterTemplate(ctx context.Context) {
488525
InfrastructureProvider: "capms:v0.6.1",
489526
LogFolder: path.Join(e2e.E2EContext.Environment.artifactsPath, "clusters", e2e.ClusterName),
490527
// KubeconfigPath: "",
491-
ClusterctlVariables: map[string]string{
492-
// "METAL_API_URL": "",
493-
// "METAL_API_HMAC": "",
494-
"METAL_PROJECT_ID": e2e.E2EContext.Environment.project,
495-
// "POD_CIDR": "",
496-
"METAL_PARTITION": e2e.E2EContext.Environment.partition,
497-
"METAL_NODE_NETWORK_ID": *e2e.Refs.NodeNetwork.ID,
498-
"FIREWALL_MACHINE_SIZE": e2e.FirewallSize,
499-
"FIREWALL_MACHINE_IMAGE": e2e.FirewallImage,
500-
"FIREWALL_MACHINE_NETWORKS": "[" + strings.Join(e2e.FirewallNetworks, ",") + "]",
501-
"CONTROL_PLANE_IP": e2e.ControlPlaneIP,
502-
"CONTROL_PLANE_MACHINE_SIZE": e2e.ControlPlaneMachineSize,
503-
"CONTROL_PLANE_MACHINE_IMAGE": e2e.ControlPlaneMachineImage,
504-
"WORKER_MACHINE_SIZE": e2e.WorkerMachineSize,
505-
"WORKER_MACHINE_IMAGE": e2e.WorkerMachineImage,
506-
},
528+
ClusterctlVariables: e2e.Variables(),
507529
})
508530

509531
By("Apply cluster template")
@@ -535,20 +557,6 @@ func (e2e *E2ECluster) teardownCluster(ctx context.Context) {
535557
}, e2e.E2EContext.E2EConfig.GetIntervals("default", "wait-delete-cluster")...)
536558
}
537559

538-
func (e2e *E2ECluster) teardownClusterResourceSets(ctx context.Context) {
539-
sets := framework.GetClusterResourceSets(ctx, framework.GetClusterResourceSetsInput{
540-
Lister: e2e.E2EContext.Environment.Bootstrap.GetClient(),
541-
Namespace: e2e.NamespaceName,
542-
})
543-
544-
for _, s := range sets {
545-
err := e2e.E2EContext.Environment.Bootstrap.GetClient().Delete(ctx, s)
546-
if err != nil && !apierrors.IsNotFound(err) {
547-
Expect(err).NotTo(HaveOccurred(), "failed to delete cluster resourceset")
548-
}
549-
}
550-
}
551-
552560
// deleteClusterAndWait deletes a cluster object and waits for it to be gone.
553561
// TODO: remove once cluster expectation has been fixed in framework
554562
func deleteClusterAndWait(ctx context.Context, input framework.DeleteClusterAndWaitInput, intervals ...any) {

0 commit comments

Comments
 (0)