diff --git a/test/e2e/README.md b/test/e2e/README.md index 6935c44d..52492e28 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -95,7 +95,7 @@ The config is located in `test/e2e/config/operator.yaml`. Most notable ones: ```yaml variables: - RANCHER_VERSION: "v2.7.5" # Default rancher version to install + RANCHER_VERSION: "v2.9.0" # Default rancher version to install RANCHER_HOSTNAME: "localhost" # Your ngrok domain NGROK_API_KEY: "" # Key and token values for establishing ingress NGROK_AUTHTOKEN: "" diff --git a/test/e2e/config/operator.yaml b/test/e2e/config/operator.yaml index ef9a8101..78893df9 100644 --- a/test/e2e/config/operator.yaml +++ b/test/e2e/config/operator.yaml @@ -29,16 +29,20 @@ intervals: variables: MANAGEMENT_CLUSTER_INFRASTRUCTURE: "isolated-kind" # supported options are eks, isolated-kind, kind RANCHER_VERSION: "v2.8.1" + RANCHER_ALPHA_VERSION: "v2.9.1-alpha1" KUBERNETES_VERSION: "v1.28.6" KUBERNETES_MANAGEMENT_VERSION: "v1.27.0" KUBERNETES_MANAGEMENT_AWS_REGION: "eu-west-2" RANCHER_HOSTNAME: "localhost" RANCHER_FEATURES: "" RANCHER_PATH: "rancher-latest/rancher" + RANCHER_ALPHA_PATH: "rancher-alpha/rancher" CPI_IMAGE_K8S_VERSION: "v1.27.0" RKE2_VERSION: "v1.28.1+rke2r1" RANCHER_REPO_NAME: "rancher-latest" + RANCHER_ALPHA_REPO_NAME: "rancher-alpha" RANCHER_URL: "https://releases.rancher.com/server-charts/latest" + RANCHER_ALPHA_URL: "https://releases.rancher.com/server-charts/alpha" CERT_MANAGER_URL: "https://charts.jetstack.io" CERT_MANAGER_REPO_NAME: "jetstack" CERT_MANAGER_PATH: "jetstack/cert-manager" diff --git a/test/e2e/const.go b/test/e2e/const.go index e94e4fbd..253aadbb 100644 --- a/test/e2e/const.go +++ b/test/e2e/const.go @@ -84,6 +84,9 @@ var ( //go:embed data/cluster-templates/vsphere-rke2.yaml CAPIvSphereRKE2 []byte + //go:embed data/cluster-api-addon-provider-fleet/host-network-patch.yaml + AddonProviderFleetHostNetworkPatch []byte + //go:embed data/gitea/ingress.yaml GiteaIngress []byte ) @@ -108,18 +111,22 @@ const ( KubernetesManagementVersionVar = "KUBERNETES_MANAGEMENT_VERSION" - KubernetesVersionVar = "KUBERNETES_VERSION" - RancherFeaturesVar = "RANCHER_FEATURES" - RancherHostnameVar = "RANCHER_HOSTNAME" - RancherVersionVar = "RANCHER_VERSION" - RancherPathVar = "RANCHER_PATH" - RancherUrlVar = "RANCHER_URL" - RancherRepoNameVar = "RANCHER_REPO_NAME" - RancherPasswordVar = "RANCHER_PASSWORD" - CertManagerUrlVar = "CERT_MANAGER_URL" - CertManagerRepoNameVar = "CERT_MANAGER_REPO_NAME" - CertManagerPathVar = "CERT_MANAGER_PATH" - CapiInfrastructureVar = "CAPI_INFRASTRUCTURE" + KubernetesVersionVar = "KUBERNETES_VERSION" + RancherFeaturesVar = "RANCHER_FEATURES" + RancherHostnameVar = "RANCHER_HOSTNAME" + RancherVersionVar = "RANCHER_VERSION" + RancherAlphaVersionVar = "RANCHER_ALPHA_VERSION" + RancherPathVar = "RANCHER_PATH" + RancherAlphaPathVar = "RANCHER_ALPHA_PATH" + RancherUrlVar = "RANCHER_URL" + RancherAlphaUrlVar = "RANCHER_ALPHA_URL" + RancherRepoNameVar = "RANCHER_REPO_NAME" + RancherAlphaRepoNameVar = "RANCHER_ALPHA_REPO_NAME" + RancherPasswordVar = "RANCHER_PASSWORD" + CertManagerUrlVar = "CERT_MANAGER_URL" + CertManagerRepoNameVar = "CERT_MANAGER_REPO_NAME" + CertManagerPathVar = "CERT_MANAGER_PATH" + CapiInfrastructureVar = "CAPI_INFRASTRUCTURE" NgrokRepoNameVar = "NGROK_REPO_NAME" NgrokUrlVar = "NGROK_URL" diff --git a/test/e2e/data/cluster-api-addon-provider-fleet/host-network-patch.yaml b/test/e2e/data/cluster-api-addon-provider-fleet/host-network-patch.yaml new file mode 100644 index 00000000..03b898dc --- /dev/null +++ b/test/e2e/data/cluster-api-addon-provider-fleet/host-network-patch.yaml @@ -0,0 +1,7 @@ +apiVersion: addons.cluster.x-k8s.io/v1alpha1 +kind: FleetAddonConfig +metadata: + name: fleet-addon-config +spec: + cluster: + hostNetwork: true \ No newline at end of file diff --git a/test/e2e/data/cluster-templates/docker-kubeadm.yaml b/test/e2e/data/cluster-templates/docker-kubeadm.yaml index 17cbe0b6..11e4d733 100644 --- a/test/e2e/data/cluster-templates/docker-kubeadm.yaml +++ b/test/e2e/data/cluster-templates/docker-kubeadm.yaml @@ -146,138 +146,132 @@ spec: name: ${CLUSTER_NAME}-md-0 version: ${KUBERNETES_VERSION} --- -apiVersion: addons.cluster.x-k8s.io/v1beta1 -kind: ClusterResourceSet +kind: Bundle +apiVersion: fleet.cattle.io/v1alpha1 metadata: - name: ${CLUSTER_NAME}-crs-0 + name: kindnet-cni-${CLUSTER_NAME} spec: - clusterSelector: - matchLabels: - cni: ${CLUSTER_NAME}-crs-0 resources: - - kind: ConfigMap - name: cni-${CLUSTER_NAME}-crs-0 - strategy: ApplyOnce ---- -apiVersion: v1 -data: - kindnet.yaml: | - # kindnetd networking manifest - --- - kind: ClusterRole - apiVersion: rbac.authorization.k8s.io/v1 - metadata: - name: kindnet - rules: - - apiGroups: - - "" - resources: - - nodes - verbs: - - list - - watch - - patch - - apiGroups: - - "" - resources: - - configmaps - verbs: - - get - --- - kind: ClusterRoleBinding - apiVersion: rbac.authorization.k8s.io/v1 - metadata: - name: kindnet - roleRef: - apiGroup: rbac.authorization.k8s.io + # List of all resources that will be deployed + - content: |- + # kindnetd networking manifest + --- kind: ClusterRole - name: kindnet - subjects: - - kind: ServiceAccount + apiVersion: rbac.authorization.k8s.io/v1 + metadata: + name: kindnet + rules: + - apiGroups: + - "" + resources: + - nodes + verbs: + - list + - watch + - patch + - apiGroups: + - "" + resources: + - configmaps + verbs: + - get + --- + kind: ClusterRoleBinding + apiVersion: rbac.authorization.k8s.io/v1 + metadata: + name: kindnet + roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: kindnet + subjects: + - kind: ServiceAccount + name: kindnet + namespace: kube-system + --- + apiVersion: v1 + kind: ServiceAccount + metadata: name: kindnet namespace: kube-system - --- - apiVersion: v1 - kind: ServiceAccount - metadata: - name: kindnet - namespace: kube-system - --- - apiVersion: apps/v1 - kind: DaemonSet - metadata: - name: kindnet - namespace: kube-system - labels: - tier: node - app: kindnet - k8s-app: kindnet - spec: - selector: - matchLabels: + --- + apiVersion: apps/v1 + kind: DaemonSet + metadata: + name: kindnet + namespace: kube-system + labels: + tier: node app: kindnet - template: - metadata: - labels: - tier: node + k8s-app: kindnet + spec: + selector: + matchLabels: app: kindnet - k8s-app: kindnet - spec: - hostNetwork: true - tolerations: - - operator: Exists - effect: NoSchedule - serviceAccountName: kindnet - containers: - - name: kindnet-cni - image: kindest/kindnetd:v20230511-dc714da8 - env: - - name: HOST_IP - valueFrom: - fieldRef: - fieldPath: status.hostIP - - name: POD_IP - valueFrom: - fieldRef: - fieldPath: status.podIP - - name: POD_SUBNET - value: '10.1.0.0/16' - volumeMounts: - - name: cni-cfg - mountPath: /etc/cni/net.d - - name: xtables-lock - mountPath: /run/xtables.lock - readOnly: false - - name: lib-modules - mountPath: /lib/modules - readOnly: true - resources: - requests: - cpu: "100m" - memory: "50Mi" - limits: - cpu: "100m" - memory: "50Mi" - securityContext: - privileged: false - capabilities: - add: ["NET_RAW", "NET_ADMIN"] - volumes: - - name: cni-bin - hostPath: - path: /opt/cni/bin - type: DirectoryOrCreate - - name: cni-cfg - hostPath: - path: /etc/cni/net.d - type: DirectoryOrCreate - - name: xtables-lock - hostPath: - path: /run/xtables.lock - type: FileOrCreate - - name: lib-modules - hostPath: - path: /lib/modules -kind: ConfigMap -metadata: - name: cni-${CLUSTER_NAME}-crs-0 \ No newline at end of file + template: + metadata: + labels: + tier: node + app: kindnet + k8s-app: kindnet + spec: + hostNetwork: true + tolerations: + - operator: Exists + effect: NoSchedule + serviceAccountName: kindnet + containers: + - name: kindnet-cni + image: kindest/kindnetd:v20230511-dc714da8 + env: + - name: HOST_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: POD_SUBNET + value: '10.1.0.0/16' + volumeMounts: + - name: cni-cfg + mountPath: /etc/cni/net.d + - name: xtables-lock + mountPath: /run/xtables.lock + readOnly: false + - name: lib-modules + mountPath: /lib/modules + readOnly: true + resources: + requests: + cpu: "100m" + memory: "50Mi" + limits: + cpu: "100m" + memory: "50Mi" + securityContext: + privileged: false + capabilities: + add: ["NET_RAW", "NET_ADMIN"] + volumes: + - name: cni-bin + hostPath: + path: /opt/cni/bin + type: DirectoryOrCreate + - name: cni-cfg + hostPath: + path: /etc/cni/net.d + type: DirectoryOrCreate + - name: xtables-lock + hostPath: + path: /run/xtables.lock + type: FileOrCreate + - name: lib-modules + hostPath: + path: /lib/modules + name: kindnet.yaml + targets: + - clusterSelector: + matchLabels: + cni: ${CLUSTER_NAME}-crs-0 \ No newline at end of file diff --git a/test/e2e/suites/import-gitops-v3/suite_test.go b/test/e2e/suites/import-gitops-v3/suite_test.go index 9733b23e..0c202512 100644 --- a/test/e2e/suites/import-gitops-v3/suite_test.go +++ b/test/e2e/suites/import-gitops-v3/suite_test.go @@ -30,9 +30,13 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/rancher/turtles/test/e2e" - turtlesframework "github.com/rancher/turtles/test/framework" + "github.com/rancher/turtles/test/framework" + "github.com/rancher/turtles/test/testenv" + appsv1 "k8s.io/api/apps/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/klog/v2" + capiframework "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/cluster-api/test/framework/clusterctl" ctrl "sigs.k8s.io/controller-runtime" ) @@ -123,10 +127,10 @@ var _ = BeforeSuite(func() { CertManagerChartPath: e2eConfig.GetVariable(e2e.CertManagerPathVar), CertManagerUrl: e2eConfig.GetVariable(e2e.CertManagerUrlVar), CertManagerRepoName: e2eConfig.GetVariable(e2e.CertManagerRepoNameVar), - RancherChartRepoName: e2eConfig.GetVariable(e2e.RancherRepoNameVar), - RancherChartURL: e2eConfig.GetVariable(e2e.RancherUrlVar), - RancherChartPath: e2eConfig.GetVariable(e2e.RancherPathVar), - RancherVersion: e2eConfig.GetVariable(e2e.RancherVersionVar), + RancherChartRepoName: e2eConfig.GetVariable(e2e.RancherAlphaRepoNameVar), + RancherChartURL: e2eConfig.GetVariable(e2e.RancherAlphaUrlVar), + RancherChartPath: e2eConfig.GetVariable(e2e.RancherAlphaPathVar), + RancherVersion: e2eConfig.GetVariable(e2e.RancherAlphaVersionVar), RancherNamespace: e2e.RancherNamespace, RancherPassword: e2eConfig.GetVariable(e2e.RancherPasswordVar), RancherPatches: [][]byte{e2e.RancherSettingPatch}, @@ -153,7 +157,7 @@ var _ = BeforeSuite(func() { HelmBinaryPath: flagVals.HelmBinaryPath, ChartPath: flagVals.ChartPath, CAPIProvidersYAML: e2e.CapiProviders, - Namespace: turtlesframework.DefaultRancherTurtlesNamespace, + Namespace: framework.DefaultRancherTurtlesNamespace, Image: fmt.Sprintf("ghcr.io/rancher/turtles-e2e-%s", runtime.GOARCH), Tag: "v0.0.1", WaitDeploymentsReadyInterval: e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-controllers"), @@ -166,6 +170,18 @@ var _ = BeforeSuite(func() { testenv.DeployRancherTurtles(ctx, rtInput) + By("Waiting for CAAPF deployment to be available") + capiframework.WaitForDeploymentsAvailable(ctx, capiframework.WaitForDeploymentsAvailableInput{ + Getter: setupClusterResult.BootstrapClusterProxy.GetClient(), + Deployment: &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{ + Name: "caapf-controller-manager", + Namespace: e2e.RancherTurtlesNamespace, + }}, + }, e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-controllers")...) + + By("Setting the CAAPF config to use hostNetwork") + Expect(setupClusterResult.BootstrapClusterProxy.Apply(ctx, e2e.AddonProviderFleetHostNetworkPatch)).To(Succeed()) + if !shortTestOnly() && !localTestOnly() { By("Running full tests, deploying additional infrastructure providers") awsCreds := e2eConfig.GetVariable(e2e.CapaEncodedCredentialsVar) diff --git a/test/e2e/suites/import-gitops/suite_test.go b/test/e2e/suites/import-gitops/suite_test.go index f429bc53..0668fb8e 100644 --- a/test/e2e/suites/import-gitops/suite_test.go +++ b/test/e2e/suites/import-gitops/suite_test.go @@ -126,10 +126,10 @@ var _ = BeforeSuite(func() { CertManagerChartPath: e2eConfig.GetVariable(e2e.CertManagerPathVar), CertManagerUrl: e2eConfig.GetVariable(e2e.CertManagerUrlVar), CertManagerRepoName: e2eConfig.GetVariable(e2e.CertManagerRepoNameVar), - RancherChartRepoName: e2eConfig.GetVariable(e2e.RancherRepoNameVar), - RancherChartURL: e2eConfig.GetVariable(e2e.RancherUrlVar), - RancherChartPath: e2eConfig.GetVariable(e2e.RancherPathVar), - RancherVersion: e2eConfig.GetVariable(e2e.RancherVersionVar), + RancherChartRepoName: e2eConfig.GetVariable(e2e.RancherAlphaRepoNameVar), + RancherChartURL: e2eConfig.GetVariable(e2e.RancherAlphaUrlVar), + RancherChartPath: e2eConfig.GetVariable(e2e.RancherAlphaPathVar), + RancherVersion: e2eConfig.GetVariable(e2e.RancherAlphaVersionVar), RancherNamespace: e2e.RancherNamespace, RancherPassword: e2eConfig.GetVariable(e2e.RancherPasswordVar), RancherPatches: [][]byte{e2e.RancherSettingPatch}, @@ -193,9 +193,12 @@ var _ = BeforeSuite(func() { Getter: setupClusterResult.BootstrapClusterProxy.GetClient(), Deployment: &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{ Name: "caapf-controller-manager", - Namespace: "rancher-turtles-system", + Namespace: e2e.RancherTurtlesNamespace, }}, }, e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-controllers")...) + + By("Setting the CAAPF config to use hostNetwork") + Expect(setupClusterResult.BootstrapClusterProxy.Apply(ctx, e2e.AddonProviderFleetHostNetworkPatch)).To(Succeed()) }) testenv.UpgradeRancherTurtles(ctx, upgradeInput) diff --git a/test/e2e/suites/migrate-gitops/suite_test.go b/test/e2e/suites/migrate-gitops/suite_test.go index 08bfcbfe..f0b421db 100644 --- a/test/e2e/suites/migrate-gitops/suite_test.go +++ b/test/e2e/suites/migrate-gitops/suite_test.go @@ -127,10 +127,10 @@ var _ = BeforeSuite(func() { CertManagerChartPath: e2eConfig.GetVariable(e2e.CertManagerPathVar), CertManagerUrl: e2eConfig.GetVariable(e2e.CertManagerUrlVar), CertManagerRepoName: e2eConfig.GetVariable(e2e.CertManagerRepoNameVar), - RancherChartRepoName: e2eConfig.GetVariable(e2e.RancherRepoNameVar), - RancherChartURL: e2eConfig.GetVariable(e2e.RancherUrlVar), - RancherChartPath: e2eConfig.GetVariable(e2e.RancherPathVar), - RancherVersion: e2eConfig.GetVariable(e2e.RancherVersionVar), + RancherChartRepoName: e2eConfig.GetVariable(e2e.RancherAlphaRepoNameVar), + RancherChartURL: e2eConfig.GetVariable(e2e.RancherAlphaUrlVar), + RancherChartPath: e2eConfig.GetVariable(e2e.RancherAlphaPathVar), + RancherVersion: e2eConfig.GetVariable(e2e.RancherAlphaVersionVar), RancherHost: hostName, RancherNamespace: e2e.RancherNamespace, RancherPassword: e2eConfig.GetVariable(e2e.RancherPasswordVar), @@ -194,9 +194,12 @@ var _ = BeforeSuite(func() { Getter: setupClusterResult.BootstrapClusterProxy.GetClient(), Deployment: &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{ Name: "caapf-controller-manager", - Namespace: "rancher-turtles-system", + Namespace: e2e.RancherTurtlesNamespace, }}, }, e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-controllers")...) + + By("Setting the CAAPF config to use hostNetwork") + Expect(setupClusterResult.BootstrapClusterProxy.Apply(ctx, e2e.AddonProviderFleetHostNetworkPatch)).To(Succeed()) }) testenv.UpgradeRancherTurtles(ctx, upgradeInput)