Skip to content

Commit

Permalink
Merge pull request #1046 from XudongLiuHarold/remove-helm-dependencies
Browse files Browse the repository at this point in the history
test: remove helm go dependency in e2e test
  • Loading branch information
k8s-ci-robot authored May 24, 2024
2 parents 30ac3c0 + a73b029 commit 2eaf5db
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 396 deletions.
26 changes: 26 additions & 0 deletions hack/install-helm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# Copyright 2024 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

# ========== install Helm Chart ==========
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

# ========== install cloud-provider-vsphere chart ==========
helm repo add vsphere-cpi https://kubernetes.github.io/cloud-provider-vsphere
helm repo update
11 changes: 7 additions & 4 deletions test/e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,15 @@ $(E2E_DATA_DIR): $(TMP_CAPV_DIR)
push-ccm-image:
../../hack/release.sh -p -t pr

run: $(TOOLING_BINARIES) $(E2E_DATA_DIR) push-ccm-image
install-helm:
../../hack/install-helm.sh

run: $(TOOLING_BINARIES) $(E2E_DATA_DIR) push-ccm-image install-helm
$(GINKGO) -v . -- --e2e.config="$(E2E_CONF_FILE)" --e2e.artifacts-folder="$(E2E_ARTIFACTS)" \
--e2e.chart-folder="$(E2E_CHART)" --e2e.skip-resource-cleanup=false \
--e2e.version="$(VERSION)"

dev: $(TOOLING_BINARIES) $(E2E_DATA_DIR) push-ccm-image
dev: $(TOOLING_BINARIES) $(E2E_DATA_DIR) push-ccm-image install-helm
$(GINKGO) -v . -- --e2e.config="$(E2E_CONF_FILE_DEV)" --e2e.artifacts-folder="$(E2E_ARTIFACTS)" \
--e2e.chart-folder="$(E2E_CHART)" --e2e.skip-resource-cleanup=true \
--e2e.version="$(VERSION)"
Expand All @@ -79,13 +82,13 @@ clean:

# run-e2e-with-dev-image is a convenience target to run the E2E tests with the development image already pushed to any
# registry (e.g. dockerhub). No need push permission of gcr.io/cloud-provider-vsphere/cpi/pr/manager
run-e2e-with-dev-image: $(TOOLING_BINARIES) $(E2E_DATA_DIR)
run-e2e-with-dev-image: $(TOOLING_BINARIES) $(E2E_DATA_DIR) install-helm
$(GINKGO) -v . -- --e2e.config="$(E2E_CONF_FILE_DEV)" --e2e.artifacts-folder="$(E2E_ARTIFACTS)" \
--e2e.chart-folder="$(E2E_CHART)" --e2e.skip-resource-cleanup=true \
--e2e.version="$(VERSION_DEV)" --e2e.image="$(IMAGE_DEV)"

# run-on-latest-k8s-version runs the E2E tests on the k8s version specified in KUBERNETES_VERSION_LATEST_CI
run-on-latest-k8s-version: $(TOOLING_BINARIES) $(E2E_DATA_DIR) push-ccm-image
run-on-latest-k8s-version: $(TOOLING_BINARIES) $(E2E_DATA_DIR) push-ccm-image install-helm
$(GINKGO) -v . -- --e2e.config="$(E2E_CONF_FILE)" --e2e.artifacts-folder="$(E2E_ARTIFACTS)" \
--e2e.chart-folder="$(E2E_CHART)" --e2e.skip-resource-cleanup=false \
--e2e.version="$(VERSION)" --e2e.image="$(IMAGE_DEV)" \
Expand Down
77 changes: 25 additions & 52 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,14 @@ import (
"flag"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/kube"
helmrelease "helm.sh/helm/v3/pkg/release"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -92,7 +89,6 @@ var (

// helm install configurations
namespace = "kube-system"
release = "vsphere-cpi-e2e"

// helm install expectation
daemonsetName = "vsphere-cpi"
Expand Down Expand Up @@ -252,23 +248,33 @@ var _ = SynchronizedBeforeSuite(func() []byte {
}, 2*time.Minute).Should(BeNil())
})

By("Install new vsphere-cpi with helm on workload cluster", func() {
actionConfig := new(action.Configuration)
err = actionConfig.Init(kube.GetConfig(workloadKubeconfig, "", namespace), namespace, os.Getenv("HELM_DRIVER"), func(format string, v ...interface{}) {})
Expect(err).NotTo(HaveOccurred())
By("Install dev vsphere cpi using helm on workload cluster", func() {
cmdName := "helm"
cmdArgs := []string{
"install", "vsphere-cpi", "vsphere-cpi/vsphere-cpi",
"--namespace", namespace,
"--set", "config.enabled=true",
"--set", "config.name=cloud-config",
"--set", "config.vcenter=" + e2eConfig.GetVariable("VSPHERE_SERVER"),
"--set", "config.username=" + e2eConfig.GetVariable("VSPHERE_USERNAME"),
"--set", "config.password=" + e2eConfig.GetVariable("VSPHERE_PASSWORD"),
"--set", "config.datacenter=" + e2eConfig.GetVariable("VSPHERE_DATACENTER"),
"--set", "config.region=" + "",
"--set", "config.zone=" + "",
"--set", "daemonset.image=" + image,
"--set", "daemonset.tag=" + version,
"--set", "securityContext.enabled=false",
}

chart, err := loader.Load(chartFolder)
Expect(err).NotTo(HaveOccurred())
// Create the command
cmd := exec.Command(cmdName, cmdArgs...)
cmd.Env = append(os.Environ(), fmt.Sprintf("KUBECONFIG=%s", workloadKubeconfig))

install := newCPIInstallFromConfig(actionConfig)
values := newCPIInstallValues()
// Capture the output (stdout and stderr)
output, err := cmd.CombinedOutput()
Expect(err).NotTo(HaveOccurred())

var release *helmrelease.Release
Eventually(func() error {
release, err = install.Run(chart, values)
return err
}).ShouldNot(HaveOccurred(), "Cannot install vsphere-cpi helm chart")
klog.Infof("Installed %s helm chart in namespace %s\n", release.Name, release.Namespace)
klog.Infof("Command output: %s\n", string(output))
})

By("Watching vsphere-cpi daemonset logs", func() {
Expand Down Expand Up @@ -368,39 +374,6 @@ func removeOldCPI(clientset *kubernetes.Clientset) error {
return nil
}

// newCPIInstallFromConfig returns an `Install` object, given the configurations, for the CPI chart installation
func newCPIInstallFromConfig(config *action.Configuration) *action.Install {
install := action.NewInstall(config)
install.ReleaseName = release
install.Namespace = namespace
install.DryRun = false
return install
}

// newCPIInstallValues returns the values to helm-install the CPI chart
func newCPIInstallValues() map[string]interface{} {
values := map[string]interface{}{
"config": map[string]interface{}{
"enabled": "true",
"name": "cloud-config",
"vcenter": e2eConfig.GetVariable("VSPHERE_SERVER"),
"username": e2eConfig.GetVariable("VSPHERE_USERNAME"),
"password": e2eConfig.GetVariable("VSPHERE_PASSWORD"),
"datacenter": e2eConfig.GetVariable("VSPHERE_DATACENTER"),
"region": "",
"zone": "",
},
"daemonset": map[string]interface{}{
"image": image,
"tag": version,
},
"securityContext": map[string]interface{}{
"enabled": "false",
},
}
return values
}

// resolveK8sVersion valids and sets the correct k8s from KUBERNETES_VERSION_LATEST_CI or KUBERNETES_VERSION
func resolveK8sVersion() {
var kubernetesVersion string
Expand Down
57 changes: 0 additions & 57 deletions test/e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/onsi/ginkgo/v2 v2.17.3
github.com/onsi/gomega v1.33.1
github.com/vmware/govmomi v0.37.1
helm.sh/helm/v3 v3.14.4
k8s.io/api v0.29.3
k8s.io/apimachinery v0.29.3
k8s.io/client-go v0.29.3
Expand All @@ -17,16 +16,12 @@ require (
)

require (
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/BurntSushi/toml v1.3.2 // 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/squirrel v1.5.4 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Microsoft/hcsshim v0.11.4 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
github.com/adrg/xdg v0.4.0 // indirect
github.com/alessio/shellescape v1.4.1 // indirect
Expand All @@ -35,42 +30,27 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/containerd/containerd v1.7.12 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/cli v24.0.6+incompatible // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker v24.0.9+incompatible // indirect
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/drone/envsubst/v2 v2.0.0-20210730161058-179042472c46 // indirect
github.com/emicklei/go-restful/v3 v3.12.0 // indirect
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/gobuffalo/flect v1.0.2 // indirect
github.com/gobwas/glob v0.2.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
github.com/google/btree v1.0.1 // indirect
github.com/google/cel-go v0.17.7 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
Expand All @@ -79,58 +59,33 @@ require (
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect
github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/gosuri/uitable v0.0.4 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmoiron/sqlx v1.3.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.0 // indirect
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rivo/uniseg v0.4.2 // indirect
github.com/rubenv/sql-migrate v1.5.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // 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
Expand All @@ -144,15 +99,8 @@ require (
github.com/stoewer/go-strcase v1.2.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/valyala/fastjson v1.6.4 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.0 // indirect
go.opentelemetry.io/otel v1.22.0 // indirect
go.opentelemetry.io/otel/metric v1.22.0 // indirect
go.opentelemetry.io/otel/trace v1.22.0 // indirect
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
Expand All @@ -177,17 +125,12 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.29.3 // indirect
k8s.io/apiserver v0.29.3 // indirect
k8s.io/cli-runtime v0.29.3 // indirect
k8s.io/cluster-bootstrap v0.29.3 // indirect
k8s.io/component-base v0.29.3 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/kubectl v0.29.3 // indirect
k8s.io/utils v0.0.0-20231127182322-b307cd553661 // indirect
oras.land/oras-go v1.2.4 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kind v0.22.0 // indirect
sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 // indirect
sigs.k8s.io/kustomize/kyaml v0.14.3-0.20230601165947-6ce0bf390ce3 // 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 2eaf5db

Please sign in to comment.