Skip to content

Commit

Permalink
🌱 test: use cluster without worker definition for kcp only test (#11212)
Browse files Browse the repository at this point in the history
* test: use cluster without worker definition for kcp only test

* add additional quick-start test for covering zero replicas

* Rewrite quick-start test

* comment fix

* fix kcp-only clusterclass
  • Loading branch information
chrischdi authored Sep 26, 2024
1 parent d495b4e commit 7c62eb2
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ hack/tools/bin

# E2E test templates
test/e2e/data/infrastructure-docker/**/cluster-template*.yaml
!test/e2e/data/infrastructure-docker/**/clusterclass-quick-start.yaml
!test/e2e/data/infrastructure-docker/**/clusterclass-quick-start-runtimesdk.yaml
test/e2e/data/infrastructure-docker/**/clusterclass-*.yaml
test/e2e/data/infrastructure-inmemory/**/cluster-template*.yaml

# Output of Makefile targets using sed on MacOS systems
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,12 @@ generate-e2e-templates-main: $(KUSTOMIZE)
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-ipv6 --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-ipv6.yaml
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-topology-dualstack-ipv6-primary --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-topology-dualstack-ipv6-primary.yaml
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-topology-dualstack-ipv4-primary --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-topology-dualstack-ipv4-primary.yaml
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-topology-single-node-cluster --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-topology-single-node-cluster.yaml
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-topology-no-workers --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-topology-no-workers.yaml
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-topology-kcp-only --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-topology-kcp-only.yaml
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-topology-autoscaler --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-topology-autoscaler.yaml
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-topology --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-topology.yaml
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-ignition --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-ignition.yaml
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/clusterclass-quick-start-kcp-only --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/clusterclass-quick-start-kcp-only.yaml

$(KUSTOMIZE) build $(INMEMORY_TEMPLATES)/main/cluster-template --load-restrictor LoadRestrictionsNone > $(INMEMORY_TEMPLATES)/main/cluster-template.yaml

Expand Down
4 changes: 3 additions & 1 deletion test/e2e/config/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,13 @@ providers:
- sourcePath: "../data/infrastructure-docker/main/cluster-template-ipv6.yaml"
- sourcePath: "../data/infrastructure-docker/main/cluster-template-topology-dualstack-ipv6-primary.yaml"
- sourcePath: "../data/infrastructure-docker/main/cluster-template-topology-dualstack-ipv4-primary.yaml"
- sourcePath: "../data/infrastructure-docker/main/cluster-template-topology-single-node-cluster.yaml"
- sourcePath: "../data/infrastructure-docker/main/cluster-template-topology-no-workers.yaml"
- sourcePath: "../data/infrastructure-docker/main/cluster-template-topology-kcp-only.yaml"
- sourcePath: "../data/infrastructure-docker/main/cluster-template-topology-autoscaler.yaml"
- sourcePath: "../data/infrastructure-docker/main/cluster-template-topology.yaml"
- sourcePath: "../data/infrastructure-docker/main/cluster-template-ignition.yaml"
- sourcePath: "../data/infrastructure-docker/main/clusterclass-quick-start.yaml"
- sourcePath: "../data/infrastructure-docker/main/clusterclass-quick-start-kcp-only.yaml"
- sourcePath: "../data/infrastructure-docker/main/clusterclass-quick-start-runtimesdk.yaml"
- sourcePath: "../data/shared/main/metadata.yaml"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- op: add
path: /spec/topology/class
value: "quick-start-kcp-only"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resources:
- ../cluster-template-topology-no-workers

patches:
- path: cluster-topology-class.yaml
target:
group: cluster.x-k8s.io
version: v1beta1
kind: Cluster
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ patches:
group: cluster.x-k8s.io
version: v1beta1
kind: Cluster

- path: remove-topology-workers.yaml
target:
group: cluster.x-k8s.io
version: v1beta1
kind: Cluster
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- op: remove
path: /spec/topology/workers
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- op: replace
path: /metadata/name
value: quick-start-kcp-only
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
resources:
- ../clusterclass-quick-start.yaml

patches:
- path: remove-workers.yaml
target:
group: cluster.x-k8s.io
version: v1beta1
kind: ClusterClass
- path: clusterclass-name.yaml
target:
group: cluster.x-k8s.io
version: v1beta1
kind: ClusterClass
- path: remove-worker-patches.yaml
target:
group: cluster.x-k8s.io
version: v1beta1
kind: ClusterClass
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- op: remove
path: /spec/patches/14
- op: remove
path: /spec/patches/9
- op: remove
path: /spec/patches/5
- op: remove
path: /spec/patches/4/definitions/0/selector/matchResources/machineDeploymentClass
- op: remove
path: /spec/patches/3/definitions/2
- op: remove
path: /spec/patches/3/definitions/0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- op: remove
path: /spec/workers
16 changes: 16 additions & 0 deletions test/e2e/quick_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,19 @@ var _ = Describe("When following the Cluster API quick-start with dualstack and
}
})
})

var _ = Describe("When following the Cluster API quick-start with ClusterClass without any worker definitions [ClusterClass]", func() {
QuickStartSpec(ctx, func() QuickStartSpecInput {
return QuickStartSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
Flavor: ptr.To("topology-kcp-only"),
InfrastructureProvider: ptr.To("docker"),
// Note: the used template is not using the corresponding variable
WorkerMachineCount: ptr.To[int64](0),
}
})
})
5 changes: 3 additions & 2 deletions test/e2e/self_hosted_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ var _ = Describe("When testing Cluster API working on single-node self-hosted cl
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
Flavor: "topology-single-node-cluster",
Flavor: "topology-no-workers",
InfrastructureProvider: ptr.To("docker"),
ControlPlaneMachineCount: ptr.To[int64](1),
WorkerMachineCount: ptr.To[int64](0),
// Note: the used template is not using the corresponding variable.
WorkerMachineCount: ptr.To[int64](0),
}
})
})

0 comments on commit 7c62eb2

Please sign in to comment.