From a0b1e3e5bbff6acb0f24b9bf4eadfb5973096b4f Mon Sep 17 00:00:00 2001 From: Saverio Proto Date: Wed, 27 Mar 2024 21:06:49 +0100 Subject: [PATCH] Added test --- test/e2e/helm_test.go | 23 +++ test/e2e/resources/feature-gates.yaml | 230 ++++++++++++++++++++++++++ 2 files changed, 253 insertions(+) create mode 100644 test/e2e/resources/feature-gates.yaml diff --git a/test/e2e/helm_test.go b/test/e2e/helm_test.go index 066ca938..9f109ab8 100644 --- a/test/e2e/helm_test.go +++ b/test/e2e/helm_test.go @@ -206,4 +206,27 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func Expect(err).ToNot(HaveOccurred()) Expect(manifests).To(Equal(string(expectedManifests))) }) + It("should deploy core and infra with feature gates enabled", func() { + manifests, err := helmChart.Run(map[string]string{ + "configSecret.name": "aws-variables", + "configSecret.namespace": "default", + "infrastructure": "aws:v2.4.0", + "addon": "helm:", + "image.manager.tag": "v0.9.1", + "cert-manager.enabled": "false", + "cert-manager.installCRDs": "false", + "core": "cluster-api:v1.6.2", + "manager.featureGates.core.ClusterTopology": "true", + "manager.featureGates.core.MachinePool": "true", + "manager.featureGates.aws.ClusterTopology": "true", + "manager.featureGates.aws.MachinePool": "true", + "manager.featureGates.aws.EKSEnableIAM": "true", + "manager.featureGates.aws.EKSAllowAddRoles": "true", + }) + Expect(err).ToNot(HaveOccurred()) + Expect(manifests).ToNot(BeEmpty()) + expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "feature-gates.yaml")) + Expect(err).ToNot(HaveOccurred()) + Expect(manifests).To(Equal(string(expectedManifests))) + }) }) diff --git a/test/e2e/resources/feature-gates.yaml b/test/e2e/resources/feature-gates.yaml new file mode 100644 index 00000000..60970fd8 --- /dev/null +++ b/test/e2e/resources/feature-gates.yaml @@ -0,0 +1,230 @@ +--- +# Source: cluster-api-operator/templates/deployment.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: capi-cluster-api-operator + namespace: 'default' + labels: + app: cluster-api-operator + app.kubernetes.io/name: cluster-api-operator + app.kubernetes.io/instance: capi + app.kubernetes.io/component: "controller" + control-plane: controller-manager + clusterctl.cluster.x-k8s.io/core: capi-operator +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/name: cluster-api-operator + app.kubernetes.io/instance: capi + app.kubernetes.io/component: "controller" + control-plane: controller-manager + clusterctl.cluster.x-k8s.io/core: capi-operator + template: + metadata: + labels: + app: cluster-api-operator + app.kubernetes.io/name: cluster-api-operator + app.kubernetes.io/instance: capi + app.kubernetes.io/component: "controller" + control-plane: controller-manager + clusterctl.cluster.x-k8s.io/core: capi-operator + spec: + containers: + - args: + - --v=2 + - --health-addr=:8081 + - --metrics-bind-addr=127.0.0.1:8080 + - --diagnostics-address=8443 + - --leader-elect=true + command: + - /manager + image: "gcr.io/k8s-staging-capi-operator/cluster-api-operator:v0.9.1" + imagePullPolicy: IfNotPresent + name: manager + ports: + - containerPort: 9443 + name: webhook-server + protocol: TCP + resources: + limits: + cpu: 100m + memory: 150Mi + requests: + cpu: 100m + memory: 100Mi + volumeMounts: + - mountPath: /tmp/k8s-webhook-server/serving-certs + name: cert + readOnly: true + terminationGracePeriodSeconds: 10 + volumes: + - name: cert + secret: + defaultMode: 420 + secretName: capi-operator-webhook-service-cert + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/arch + operator: In + values: + - amd64 + - arm64 + - ppc64le + - key: kubernetes.io/os + operator: In + values: + - linux + tolerations: + - effect: NoSchedule + key: node-role.kubernetes.io/master + - effect: NoSchedule + key: node-role.kubernetes.io/control-plane +--- +# Source: cluster-api-operator/templates/addon.yaml +# Addon provider +--- +# Source: cluster-api-operator/templates/bootstrap.yaml +# Bootstrap provider +--- +# Source: cluster-api-operator/templates/control-plane.yaml +# Control plane provider +--- +# Source: cluster-api-operator/templates/core-conditions.yaml +# Deploy core components if not specified +--- +# Source: cluster-api-operator/templates/core.yaml +# Core provider +--- +# Source: cluster-api-operator/templates/infra-conditions.yaml +# Deploy bootstrap, and infrastructure components if not specified +--- +# Source: cluster-api-operator/templates/infra.yaml +# Infrastructure providers +--- +# Source: cluster-api-operator/templates/addon.yaml +apiVersion: v1 +kind: Namespace +metadata: + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "1" + name: helm-addon-system +--- +# Source: cluster-api-operator/templates/core.yaml +apiVersion: v1 +kind: Namespace +metadata: + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "1" + name: capi-system +--- +# Source: cluster-api-operator/templates/infra-conditions.yaml +apiVersion: v1 +kind: Namespace +metadata: + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "1" + name: capi-kubeadm-bootstrap-system +--- +# Source: cluster-api-operator/templates/infra-conditions.yaml +apiVersion: v1 +kind: Namespace +metadata: + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "1" + name: capi-kubeadm-control-plane-system +--- +# Source: cluster-api-operator/templates/infra.yaml +apiVersion: v1 +kind: Namespace +metadata: + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "1" + name: aws-infrastructure-system +--- +# Source: cluster-api-operator/templates/addon.yaml +apiVersion: operator.cluster.x-k8s.io/v1alpha2 +kind: AddonProvider +metadata: + name: helm + namespace: helm-addon-system + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "2" +--- +# Source: cluster-api-operator/templates/infra-conditions.yaml +apiVersion: operator.cluster.x-k8s.io/v1alpha2 +kind: BootstrapProvider +metadata: + name: kubeadm + namespace: capi-kubeadm-bootstrap-system + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "2" +spec: + configSecret: + name: aws-variables + namespace: default +--- +# Source: cluster-api-operator/templates/infra-conditions.yaml +apiVersion: operator.cluster.x-k8s.io/v1alpha2 +kind: ControlPlaneProvider +metadata: + name: kubeadm + namespace: capi-kubeadm-control-plane-system + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "2" +spec: + configSecret: + name: aws-variables + namespace: default +--- +# Source: cluster-api-operator/templates/core.yaml +apiVersion: operator.cluster.x-k8s.io/v1alpha2 +kind: CoreProvider +metadata: + name: cluster-api + namespace: capi-system + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "2" +spec: + version: v1.6.2 + manager: + featureGates: + ClusterTopology: true + MachinePool: true + configSecret: + name: aws-variables + namespace: default +--- +# Source: cluster-api-operator/templates/infra.yaml +apiVersion: operator.cluster.x-k8s.io/v1alpha2 +kind: InfrastructureProvider +metadata: + name: aws + namespace: aws-infrastructure-system + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "2" +spec: + version: v2.4.0 + manager: + featureGates: + ClusterTopology: true + EKSAllowAddRoles: true + EKSEnableIAM: true + MachinePool: true + configSecret: + name: aws-variables + namespace: default