From 14fc32558983a85c339f452a9c09fe9065aec821 Mon Sep 17 00:00:00 2001 From: Furkat Gofurov Date: Mon, 8 Jan 2024 18:07:40 +0200 Subject: [PATCH] Address review comments Signed-off-by: Furkat Gofurov --- Makefile | 2 +- test/e2e/README.md | 26 ++++++++++++++++--- test/e2e/const.go | 8 +++--- .../e2e/data/capi-operator/capv-provider.yaml | 19 +++++++------- .../data/capi-operator/capv-variables.yaml | 12 ++++++--- .../import-gitops/import_gitops_test.go | 2 +- test/e2e/suites/import-gitops/suite_test.go | 8 +++--- 7 files changed, 51 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index cd12df470..ba03a0a98 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ SKIP_RESOURCE_CLEANUP ?= false USE_EXISTING_CLUSTER ?= false ISOLATED_MODE ?= false GINKGO_NOCOLOR ?= false -GINKGO_LABEL_FILTER ?= short || full || local +GINKGO_LABEL_FILTER ?= short || full GINKGO_TESTS ?= $(ROOT_DIR)/$(TEST_DIR)/e2e/suites/... # to set multiple ginkgo skip flags, if any diff --git a/test/e2e/README.md b/test/e2e/README.md index b2ef7e801..ef0e32095 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -46,9 +46,29 @@ This will consequently: #### Prerequisites 1. Initiate a VPN connection using a client such as OpenVPN or Cisco AnyConnect Secure Mobility Client. -1. Set up all the necessary environment variables. You can start with the [`.envrc.example`](../../.envrc.example) file. - Use [direnv](https://direnv.net/) to load these variables into your shell. Rename the file and modify the values as required. - You can obtain these values from a team common credentials shared location. +1. Set up all the necessary environment variables. You can start with the [`.envrc.example`](../../.envrc.example) file and + use [direnv](https://direnv.net/) to load these variables into your shell. Rename the file and modify the values as required. + You can obtain these values from a team common credentials shared location. Also, they can be fetched by accessing the vcenter + URL and following the steps described on the table below: + +| Name | Details | How to get +| -------------------------- | ----------------------------------------------------------------------------------------------| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| VSPHERE_TLS_THUMBPRINT | sha1 thumbprint of the vcenter certificate: openssl x509 -sha1 -fingerprint -in ca.crt -noout | browse to vcenter URL and check sha-1 fingerprint in the SSL certificate | +| VSPHERE_SERVER | The vCenter server IP or FQDN | once logged in vSphere Client, click on second icon from left to right on top left and select vcenter name (top level name in the folders tree) | +| VSPHERE_DATACENTER | The vSphere datacenter to deploy the management cluster on | `vcenter` name => select `Datacenters` | +| VSPHERE_DATASTORE | The vSphere datastore to deploy the management cluster on | `vcenter` name => `Datacenter` name => select `Datastores` | +| VSPHERE_FOLDER | The VM folder for your VMs. Set to "" to use the root vSphere folder | `vcenter` name => `Datacenter` name => `VMs` => select `VM folders` | +| VSPHERE_TEMPLATE | The VM template to use for your management cluster | `vcenter` name => `Datacenter` name => `VMs` => select `VM Templates` | +| VSPHERE_NETWORK | The VM network to deploy the management cluster on | `vcenter` name => `Datacenter` name => `Networks` => select `Networks` | +| VSPHERE_PASSWORD | The password used to access the remote vSphere endpoint | reach out to team lead | +| VSPHERE_USERNAME | The username used to access the remote vSphere endpoint | reach out to team lead | +| VSPHERE_SSH_AUTHORIZED_KEY | The public ssh authorized key on all machines in this cluster | can be left empty | +| CONTROL_PLANE_ENDPOINT_IP | The IP that kube-vip is going to use as a control plane endpoint | `vcenter` name => `Datacenter` name => `Hosts & Clusters` => `Hosts` => select `host IP` and right click => `Settings` => `Networking` => `Virtual Switches` => click on three dots of `host IP` => `View Settings` => `IPv4 settings` => `Subnet mask`. i.e host IP is 10.10.10.20 and subnet mask is 255.255.255.0, the last IP address of the subnet which is 10.10.10.255 can be used | +| EXP_CLUSTER_RESOURCE_SET | This enables the ClusterResourceSet feature that we are using to deploy CSI | default: true | +| GOVC_URL | The URL of ESXi or vCenter instance to connect to | in the form of `https://` | +| GOVC_USERNAME | The username to use if not specified in `GOVC_URL` | equivalent of `VSPHERE_USERNAME` | +| GOVC_PASSWORD | The password to use if not specified in `GOVC_URL` | equivalent of `VSPHERE_PASSWORD` | +| GOVC_INSECURE | Disable certificate verification | default: true | #### Running the tests diff --git a/test/e2e/const.go b/test/e2e/const.go index 9df681c70..c1dc2cd95 100644 --- a/test/e2e/const.go +++ b/test/e2e/const.go @@ -119,8 +119,8 @@ const ( AuthSecretName = "basic-auth-secret" - ShortTestLabel = "short" - FullTestLabel = "full" - DontRunLabel = "dontrun" - LocalvSphereTestLabel = "local" + ShortTestLabel = "short" + FullTestLabel = "full" + DontRunLabel = "dontrun" + LocalTestLabel = "local" ) diff --git a/test/e2e/data/capi-operator/capv-provider.yaml b/test/e2e/data/capi-operator/capv-provider.yaml index ef8916256..de9a09ef2 100644 --- a/test/e2e/data/capi-operator/capv-provider.yaml +++ b/test/e2e/data/capi-operator/capv-provider.yaml @@ -1,15 +1,16 @@ --- -apiVersion: v1 -kind: Namespace -metadata: - name: capv-system ---- -apiVersion: operator.cluster.x-k8s.io/v1alpha1 -kind: InfrastructureProvider +apiVersion: turtles-capi.cattle.io/v1alpha1 +kind: CAPIProvider metadata: name: vsphere namespace: capv-system spec: + name: vsphere + type: infrastructure version: v1.8.5 - secretName: vsphere-variables - secretNamespace: default \ No newline at end of file + configSecret: + name: vsphere-variables + variables: + CLUSTER_TOPOLOGY: "true" + EXP_CLUSTER_RESOURCE_SET: "true" + EXP_MACHINE_POOL: "true" \ No newline at end of file diff --git a/test/e2e/data/capi-operator/capv-variables.yaml b/test/e2e/data/capi-operator/capv-variables.yaml index 12d7b4d96..de585247f 100644 --- a/test/e2e/data/capi-operator/capv-variables.yaml +++ b/test/e2e/data/capi-operator/capv-variables.yaml @@ -1,11 +1,15 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: capv-system +--- apiVersion: v1 kind: Secret metadata: name: vsphere-variables - namespace: default + namespace: vsphere-system type: Opaque stringData: VSPHERE_USERNAME: "${VSPHERE_USERNAME}" - VSPHERE_PASSWORD: "${VSPHERE_PASSWORD}" - CLUSTER_TOPOLOGY: "true" - EXP_CLUSTER_RESOURCE_SET: "true" \ No newline at end of file + VSPHERE_PASSWORD: "${VSPHERE_PASSWORD}" \ No newline at end of file diff --git a/test/e2e/suites/import-gitops/import_gitops_test.go b/test/e2e/suites/import-gitops/import_gitops_test.go index 5d9bfebc9..602df09aa 100644 --- a/test/e2e/suites/import-gitops/import_gitops_test.go +++ b/test/e2e/suites/import-gitops/import_gitops_test.go @@ -121,7 +121,7 @@ var _ = Describe("[Azure] [AKS] Create and delete CAPI cluster functionality sho }) }) -var _ = Describe("[vSphere] [Kubeadm] Create and delete CAPI cluster functionality should work with namespace auto-import", Label(e2e.LocalvSphereTestLabel), func() { +var _ = Describe("[vSphere] [Kubeadm] Create and delete CAPI cluster functionality should work with namespace auto-import", Label(e2e.LocalTestLabel), func() { BeforeEach(func() { SetClient(setupClusterResult.BootstrapClusterProxy.GetClient()) diff --git a/test/e2e/suites/import-gitops/suite_test.go b/test/e2e/suites/import-gitops/suite_test.go index f5fd144f1..8cc4552fe 100644 --- a/test/e2e/suites/import-gitops/suite_test.go +++ b/test/e2e/suites/import-gitops/suite_test.go @@ -156,7 +156,7 @@ var _ = BeforeSuite(func() { WaitDeploymentsReadyInterval: e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-controllers"), }) - if !shortTestOnly() && !localvSphereTestOnly() { + if !shortTestOnly() && !localTestOnly() { By("Running full tests, deploying additional infrastructure providers") awsCreds := e2eConfig.GetVariable(e2e.CapaEncodedCredentialsVar) Expect(awsCreds).ToNot(BeEmpty(), "AWS creds required for full test") @@ -183,7 +183,7 @@ var _ = BeforeSuite(func() { }, }, }) - } else if Label(e2e.LocalvSphereTestLabel).MatchesLabelFilter(GinkgoLabelFilter()) { + } else if Label(e2e.LocalTestLabel).MatchesLabelFilter(GinkgoLabelFilter()) { By("Running local vSphere tests, deploying vSphere infrastructure provider") testenv.CAPIOperatorDeployProvider(ctx, testenv.CAPIOperatorDeployProviderInput{ @@ -234,6 +234,6 @@ func shortTestOnly() bool { return GinkgoLabelFilter() == e2e.ShortTestLabel } -func localvSphereTestOnly() bool { - return GinkgoLabelFilter() == e2e.LocalvSphereTestLabel +func localTestOnly() bool { + return GinkgoLabelFilter() == e2e.LocalTestLabel }