Skip to content

Commit

Permalink
Merge pull request #1325 from zhanggbj/e2e
Browse files Browse the repository at this point in the history
🌱 Bump e2e to use latest CAPI/CAPV
  • Loading branch information
k8s-ci-robot authored Dec 6, 2024
2 parents 2bbb00a + ea24168 commit b2d7212
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 137 deletions.
8 changes: 5 additions & 3 deletions test/e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ E2E_CHART ?= ${REPO_ROOT}/charts/vsphere-cpi
# E2E_DATA_DIR contains provider manifests needed to create the bootsrap cluster, required by the E2E_CONF_FILE
E2E_DATA_DIR := ${REPO_ROOT}/test/e2e/data

# E2E_DATA_CAPV_VER defines the providers from which version of CAPV to use
E2E_DATA_CAPV_VER ?= release-1.11
# E2E_DATA_CAPV_TAG defines the providers from which tag of CAPV to use
E2E_DATA_CAPV_TAG ?= v1.12.0-rc.1

# VERSION_DEV is the version of the image used for development
VERSION_DEV ?= $(VERSION)
Expand All @@ -55,7 +55,9 @@ $(TOOLING_BINARIES):
make -C $(TOOLS_DIR) $(@F)

$(TMP_CAPV_DIR):
git clone -b $(E2E_DATA_CAPV_VER) https://github.com/kubernetes-sigs/cluster-api-provider-vsphere.git $(TMP_CAPV_DIR)
git clone https://github.com/kubernetes-sigs/cluster-api-provider-vsphere.git $(TMP_CAPV_DIR); \
cd "$(TMP_CAPV_DIR)"; \
git checkout tags/$(E2E_DATA_CAPV_TAG) -b $(E2E_DATA_CAPV_TAG)

$(E2E_DATA_DIR): $(TMP_CAPV_DIR)
$(MAKE) -C $(TMP_CAPV_DIR) generate-e2e-templates && cp -r $(TMP_CAPV_DIR)/test/e2e/data $(E2E_DATA_DIR) && \
Expand Down
22 changes: 11 additions & 11 deletions test/e2e/config/vsphere-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,51 +10,51 @@ providers:
- name: cluster-api
type: CoreProvider
versions:
- name: v1.8.1
- name: v1.9.0
# Use manifest from source files
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.8.1/core-components.yaml"
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.9.0-rc.1/core-components.yaml"
type: "url"
contract: v1beta1
files:
- sourcePath: "../data/shared/capi/v1.8/metadata.yaml"
- sourcePath: "../data/shared/capi/v1.9/metadata.yaml"
replacements:
- old: "imagePullPolicy: Always"
new: "imagePullPolicy: IfNotPresent"

- name: kubeadm
type: BootstrapProvider
versions:
- name: v1.8.1
- name: v1.9.0
# Use manifest from source files
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.8.1/bootstrap-components.yaml"
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.9.0-rc.1/bootstrap-components.yaml"
type: "url"
contract: v1beta1
files:
- sourcePath: "../data/shared/capi/v1.8/metadata.yaml"
- sourcePath: "../data/shared/capi/v1.9/metadata.yaml"
replacements:
- old: "imagePullPolicy: Always"
new: "imagePullPolicy: IfNotPresent"

- name: kubeadm
type: ControlPlaneProvider
versions:
- name: v1.8.1
- name: v1.9.0
# Use manifest from source files
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.8.1/control-plane-components.yaml"
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.9.0-rc.1/control-plane-components.yaml"
type: "url"
contract: v1beta1
files:
- sourcePath: "../data/shared/capi/v1.8/metadata.yaml"
- sourcePath: "../data/shared/capi/v1.9/metadata.yaml"
replacements:
- old: "imagePullPolicy: Always"
new: "imagePullPolicy: IfNotPresent"

- name: vsphere
type: InfrastructureProvider
versions:
- name: v1.11.0
- name: v1.12.0
# Use manifest from source files
value: "https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/releases/download/v1.11.0/infrastructure-components.yaml"
value: "https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/releases/download/v1.12.0-rc.1/infrastructure-components.yaml"
type: "url"
contract: v1beta1
files:
Expand Down
43 changes: 43 additions & 0 deletions test/e2e/cpi_vm_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package e2e

import (
"context"
"errors"
"fmt"
"strings"
"time"

Expand All @@ -14,6 +16,8 @@ import (
k8stypes "k8s.io/apimachinery/pkg/types"
"k8s.io/klog/v2"
"sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/test/framework"
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
)

const machineNamespace = "default"
Expand Down Expand Up @@ -110,6 +114,19 @@ func getWorkerVM(name string) (*object.VirtualMachine, error) {
return workerVMs[0], nil
}

// updateClusterSpecPaused update the Cluster.Spec.Paused field with desired value.
func updateClusterSpecPaused(ctx context.Context, name string, namespace string, desired string) {
workloadCluster := framework.GetClusterByName(ctx, framework.GetClusterByNameInput{
Getter: proxy.GetClient(),
Namespace: namespace,
Name: name,
})

patch := ctrlclient.RawPatch(k8stypes.MergePatchType, []byte(fmt.Sprintf("{\"spec\":{\"paused\":%s}}", desired)))
err = proxy.GetClient().Patch(ctx, workloadCluster, patch)
Expect(err).ToNot(HaveOccurred())
}

// WaitForWorkerNodeReadiness returns a function for Eventually that
// retrieves the latest node and asserts its readiness
func WaitForWorkerNodeReadiness(readiness corev1.ConditionStatus) func() error {
Expand Down Expand Up @@ -201,6 +218,19 @@ var _ = Describe("Restarting, recreating and deleting VMs", func() {

providerID := getProviderIDFromNode(workerNode)

By("Pause reconcile for workload cluster", func() {
updateClusterSpecPaused(ctx, workloadResult.Cluster.Name, workloadResult.Cluster.Namespace, "true")
Eventually(func() bool {
wldCluster := framework.GetClusterByName(ctx, framework.GetClusterByNameInput{
Getter: proxy.GetClient(),
Namespace: workloadResult.Cluster.Namespace,
Name: workloadResult.Cluster.Name,
})

return wldCluster.Spec.Paused
}, 180*time.Second, 10*time.Second).Should(BeTrue(), "Failed to pause the Workload Cluster")
})

By("Shutdown VM "+workerVM.Name(), func() {
task, err := workerVM.PowerOff(ctx)
Expect(err).ToNot(HaveOccurred(), "cannot power off vm")
Expand Down Expand Up @@ -229,6 +259,19 @@ var _ = Describe("Restarting, recreating and deleting VMs", func() {
By("Wait for node " + workerNode.Name + " to become ready")
Eventually(WaitForWorkerNodeReadiness(corev1.ConditionTrue), 5*time.Minute, 5*time.Second).Should(BeNil())

By("Unpause reconcile for workload cluster", func() {
updateClusterSpecPaused(ctx, workloadResult.Cluster.Name, workloadResult.Cluster.Namespace, "false")
Eventually(func() bool {
wldCluster := framework.GetClusterByName(ctx, framework.GetClusterByNameInput{
Getter: proxy.GetClient(),
Namespace: workloadResult.Cluster.Namespace,
Name: workloadResult.Cluster.Name,
})

return wldCluster.Spec.Paused
}, 180*time.Second, 10*time.Second).Should(BeFalse(), "Failed to unpause the Workload Cluster")
})

By("Assert that externalIP, internalIP and providerID are preserved after VM restarts", func() {
Eventually(func() error {
workerNode, err = getWorkerNode()
Expand Down
69 changes: 38 additions & 31 deletions test/e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,38 @@ go 1.22.0

toolchain go1.22.3

replace sigs.k8s.io/cluster-api-provider-vsphere => sigs.k8s.io/cluster-api-provider-vsphere v1.10.0-rc.1.0.20240521132953-469f652e57ae
replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.9.0-rc.1

replace sigs.k8s.io/cluster-api-provider-vsphere => sigs.k8s.io/cluster-api-provider-vsphere v1.12.0-rc.1

replace sigs.k8s.io/cluster-api-provider-vsphere/test => sigs.k8s.io/cluster-api-provider-vsphere/test v1.12.0-rc.1

replace sigs.k8s.io/cluster-api/test => sigs.k8s.io/cluster-api/test v1.9.0-rc.1

require (
github.com/onsi/ginkgo/v2 v2.22.0
github.com/onsi/gomega v1.36.0
github.com/vmware/govmomi v0.46.2
k8s.io/api v0.31.1
k8s.io/apimachinery v0.31.1
k8s.io/client-go v0.31.1
k8s.io/api v0.31.3
k8s.io/apimachinery v0.31.3
k8s.io/client-go v0.31.3
k8s.io/klog/v2 v2.130.1
sigs.k8s.io/cluster-api v1.8.4
sigs.k8s.io/cluster-api-provider-vsphere/test v1.11.2
sigs.k8s.io/cluster-api/test v1.8.4
sigs.k8s.io/controller-runtime v0.19.0
sigs.k8s.io/cluster-api v0.0.0-00010101000000-000000000000
sigs.k8s.io/cluster-api-provider-vsphere/test v0.0.0-00010101000000-000000000000
sigs.k8s.io/cluster-api/test v0.0.0-00010101000000-000000000000
sigs.k8s.io/controller-runtime v0.19.3
)

require (
dario.cat/mergo v1.0.1 // indirect
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/Masterminds/semver/v3 v3.3.0 // indirect
github.com/Masterminds/sprig/v3 v3.3.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
github.com/adrg/xdg v0.5.0 // indirect
github.com/adrg/xdg v0.5.3 // indirect
github.com/alessio/shellescape v1.4.2 // indirect
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
Expand All @@ -39,7 +46,7 @@ require (
github.com/cloudflare/circl v1.3.7 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/docker v27.1.1+incompatible // indirect
github.com/docker/docker v27.3.1+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/drone/envsubst/v2 v2.0.0-20210730161058-179042472c46 // indirect
Expand All @@ -54,7 +61,7 @@ require (
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/gobuffalo/flect v1.0.2 // indirect
github.com/gobuffalo/flect v1.0.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
Expand All @@ -70,7 +77,7 @@ require (
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand Down Expand Up @@ -98,10 +105,10 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.19.0 // indirect
Expand All @@ -119,36 +126,36 @@ require (
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/term v0.25.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/term v0.26.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.26.0 // indirect
golang.org/x/tools v0.27.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/grpc v1.65.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.31.0 // indirect
k8s.io/apiserver v0.31.0 // indirect
k8s.io/cluster-bootstrap v0.30.3 // indirect
k8s.io/component-base v0.31.0 // indirect
k8s.io/apiextensions-apiserver v0.31.3 // indirect
k8s.io/apiserver v0.31.3 // indirect
k8s.io/cluster-bootstrap v0.31.3 // indirect
k8s.io/component-base v0.31.3 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kind v0.24.0 // indirect
sigs.k8s.io/kind v0.25.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit b2d7212

Please sign in to comment.