Files
kubevela/makefiles/e2e.mk
bcf6af9747 Feat: helm chart auth (#7148)
* feat: kv native helm auth implementation

Signed-off-by: Ayush Kumar <aykumar@guidewire.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>

* feat: add e2e test cases for helm auth

Signed-off-by: Ayush Kumar <aykumar@guidewire.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>

* test: remove the env auth gate and improve test cases

Signed-off-by: Ayush Kumar <aykumar@guidewire.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>

* lint: drop unused []byte return from non-docker secret dispatchers

unparam flagged dispatchBasicAuthSecret, dispatchTLSSecret, and
dispatchOpaqueSecret because the second return value (raw config
bytes) was always nil. Only dispatchDockerConfigJSONSecret actually
needs that slot for the OCI temp credfile. Drop it from the other
three and update resolveAuthOptions plus the unit tests to match.

Signed-off-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>

* feat: pr review changes

Signed-off-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>

* style: gofmt/goimports auth.go doc comments

Signed-off-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>

* chore: remove e2e-auth-images-load-local target

The dedicated target is gone; e2e-test-local now reads the same
.vscode/k3d-preload.txt image list that the VS Code setup task
uses so both flows pull from one source. Empty or missing file
is a no-op.

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>

* chore: inline auth-test image list in e2e-test-local

`.vscode/k3d-preload.txt` is gitignored so it would not exist on a
fresh clone. Inline the three auth-test registry images directly
in the Make target so `make e2e-test-local` is self-contained.

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>

* feat: address PR review comments

- Webhook ValidateCuexTemplate now wraps the context in helm.WithDryRun
  so a ComponentDefinition with concrete helm.#Render arguments cannot
  trigger a real chart fetch or install during admission validation.
- helmchart audit ConfigMap keeps `helm.oam.dev/chart` as a label when
  the source string is a valid Kubernetes label value (alphanumeric +
  `.-_`, 1-63 chars); URLs containing `://` or `/` only live in the
  annotation. Preserves existing label selectors for repo-style sources
  without breaking long OCI/HTTPS URLs.
- helm_test.go capture-and-restore singleton.KubeClient in fetchURLChart
  and fetchRepoChart auth Describes so fake clients do not leak into
  later tests in the package.
- utils_test.go swap the defer order so singleton.ReloadClients runs
  before WorkloadCompiler.Reload, otherwise the compiler reload would
  pick up the fake dynamic client and leak fake state.
- e2e.mk pre-load loop separates docker pull and k3d image import with
  `;` rather than `&&`. `set -e` does not abort a for-loop body when a
  command inside an `&&` chain fails, so the old form could continue
  after a failed pull.

Signed-off-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>

* style: gofmt AfterAll indentation in helmchart_test.go

Signed-off-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>

* feat: enhance Docker Hub credential handling in auth configuration

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>

* feat: enhance Docker Hub credential handling in auth configuration

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>

* fix(helm-auth): normalize Docker Hub alias for dockerconfigjson Secrets

Cubic flagged that the Docker Hub alias fix in writeOCIRegistryConfigFile
only covered synthesized basic-auth credentials. For verbatim
kubernetes.io/dockerconfigjson Secrets, a user-supplied config keyed
under "registry-1.docker.io" (the OCI pull host) would not be found by
ORAS/Helm, which normalizes to "https://index.docker.io/v1/".

normalizeDockerHubAliases parses the verbatim JSON, and when any of the
three Docker Hub host aliases ("registry-1.docker.io", "index.docker.io",
"docker.io") is keyed but the canonical v1 key is absent, copies the
entry under the canonical key. No-op when:
  - the canonical key is already present
  - no Docker Hub host is involved
  - the JSON is malformed or missing the auths field

Includes 7 new unit specs for the helper covering each alias, the no-op
cases, and malformed input.

Also brings in collateral local-fix changes:
  - pkg/webhook/utils/utils_test.go: register the cue.oam.dev/v1alpha1
    Package GVK in the fake DynamicClient scheme so
    TestValidateCuexTemplate/withCuexPackageImports can resolve the
    test/ext package after the WorkloadCompiler switch.
  - gofmt field-alignment normalization on auth_test.go and
    auth_registry_helpers_test.go (drift caught by check-diff CI).

Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>

* fix: namespace-default rendered resources, bind chart cache to credentials, surface HTTP 401s clearly, inject auth-test CA in e2e

Four fixes from stress testing the helmchart component:

1. Rendered resources without metadata.namespace landed in vela-system.
   Both code paths now default to releaseNamespace for namespaced kinds:
   the velaLabelPostRenderer (before helm SDK apply) and
   parseManifestResources (before KubeVela's tracker re-applies).
   isClusterScopedKind covers CRDs, ClusterRoles, Namespaces, etc.

2. Cached chart bytes survived credential rotation.
   computeAuthCacheTag hashes Secret.Type + sorted Data into a 16-char
   tag suffixed onto the cache key when auth.secretRef is declared. Any
   Secret edit (or different Secret reference) invalidates the cache and
   forces a fresh registry call that exercises the new credentials at the
   wire. Public charts (no auth) are unaffected.

3. HTTP 401/403 on chart fetch surfaced as YAML/JSON parse errors.
   HTTPGetWithOption now rejects non-2xx responses with
   'HTTP <status>: <body>' instead of returning the raw body for
   downstream parsers to choke on.

4. E2E HTTPS tests against chartmuseum's self-signed cert failed at the
   admission webhook. injectAuthTestCA patches vela-core in BeforeSuite
   with an init container that combines /etc/ssl/certs/ca-certificates.crt
   with testdata/auth/certs/ca.crt into a shared volume and points
   SSL_CERT_FILE at it.

Also normalize Docker Hub host aliases on verbatim
kubernetes.io/dockerconfigjson Secrets (cubic comment), and revert
TestValidateCuexTemplate's fake DynamicClient to the empty-scheme form
that lets it wrap every GVK as Unstructured (CI unit test fix).

Finding 3 (options.wait default) is deferred: schema-level defaults
don't materialize for optional fields carried into _options as a
structural copy. Tracked separately.

Issue 2 from the stress matrix (cache + credential rotation) is also
filed upstream as kubevela/kubevela#7150 for a longer-term
credential-bound cache invalidation design.

Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>

* fix(helm-auth): RESTMapper scope detection + auth tag binds source URL + drop flaky webhook test case

Address cubic P1 review comments and the unit-test CI failure. isClusterScopedKind only matched well-known built-in kinds; isClusterScopedGVK now asks the RESTMapper first so third-party cluster-scoped CRDs are recognised, with the static allowlist as a fallback. computeAuthCacheTag now folds params.Source and params.RepoURL into the hash so a multi-host dockerconfigjson Secret cannot reuse cached bytes across different registries. TestValidateCuexTemplate/withCuexPackageImports relied on cuex.DefaultCompiler.Reload picking up a fake-client-served Package CRD; since ValidateCuexTemplate now uses velacuex.WorkloadCompiler the fake-client setup does not surface the test/ext package, so the case is dropped (covered transitively by the helm provider unit tests and the e2e suite under helm.WithDryRun).

Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>

* style: gofmt import order in helm.go (lint + check-diff)

Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>

* fix(e2e): correct vela-core selector, alpine bundler, harden rollout wait

The label selector app.kubernetes.io/name=vela-core also matches the
cluster-gateway Deployment, so the init container was being appended to
the wrong workload and the controller pod never picked up the test CA.
Switching to the unique controller.oam.dev/name label fixes the routing,
and the diagnostic message at the empty-list branch is updated to point
operators at the new label.

addVolume and addInitContainer now update in place when an entry with
the same name already exists. Previously they silently skipped, which
meant the first patch on a cluster stuck for the lifetime of that
cluster and a corrected image or args could not be picked up by a
re-run.

busybox:1.36 ships without /etc/ssl/certs/ca-certificates.crt, so the
bundler was silently producing an empty combined.crt. alpine:3.18 ships
the public CA roots, so concatenating the auth-test CA onto the system
bundle produces a usable trust store that the main container reads via
SSL_CERT_FILE.

waitForDeploymentsAvailable used to return as soon as DeploymentAvailable
flipped to True and the new RS reached the desired replica count, which
left a window where old-RS pods still satisfied Available while the
controller container was still running with the previous image. The
check now also requires Status.Replicas == Status.UpdatedReplicas,
AvailableReplicas >= specReplicas and UnavailableReplicas == 0, so the
helper only returns once the rollout is fully complete.

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>

* test(e2e): gate auth-test setup behind KUBEVELA_E2E_AUTH so other suites stay green

webhook-upgrade-check runs the same test/e2e-test suite as the full e2e
job but with ginkgo --focus-file requiredparam_validation_test.go. The
unconditional setupAuthRegistries in BeforeSuite was bringing up the
ChartMuseum / zot / nginx-bearer stack and patching vela-core for a
focus that did not need any of it, and the patched controller never
finished rolling on the upgrade-check cluster (the helm upgrade in that
job is expected to fail, so vela-core is in a stretched state when our
BeforeSuite tries to patch it).

Re-introduce KUBEVELA_E2E_AUTH=1 as the explicit opt-in. BeforeSuite and
AfterSuite only touch the auth registries when the env var is set, the
Helmchart Auth Describe block skips otherwise, and the make e2e-test
and e2e-test-local targets export the env so the full suite still runs
the auth specs. CI workflows that run a focused subset (like
webhook-upgrade-check) inherit the default off behavior and stop paying
the registry-setup cost.

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>

---------

Signed-off-by: Ayush Kumar <aykumar@guidewire.com>
Signed-off-by: Vishal Kumar <vishal210893@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
2026-05-22 09:09:55 -07:00

255 lines
12 KiB
Makefile

.PHONY: e2e-setup-core-pre-hook
e2e-setup-core-pre-hook:
sh ./hack/e2e/modify_charts.sh
.PHONY: e2e-setup-core-post-hook
e2e-setup-core-post-hook:
kubectl wait --for=condition=Available deployment/kubevela-vela-core -n vela-system --timeout=180s
helm install kruise https://github.com/openkruise/charts/releases/download/kruise-1.1.0/kruise-1.1.0.tgz --set featureGates="PreDownloadImageForInPlaceUpdate=true" --set daemon.socketLocation=/run/k3s/containerd/
kill -9 $(lsof -it:9098) || true
go run ./e2e/addon/mock &
bin/vela addon enable ./e2e/addon/mock/testdata/fluxcd
bin/vela addon enable ./e2e/addon/mock/testdata/terraform
# Wait for webhook service endpoints to be ready before enabling addons that require webhook validation
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=vela-core -n vela-system --timeout=180s
bin/vela addon enable ./e2e/addon/mock/testdata/terraform-alibaba ALICLOUD_ACCESS_KEY=xxx ALICLOUD_SECRET_KEY=yyy ALICLOUD_REGION=cn-beijing
timeout 600s bash -c -- 'while true; do kubectl get ns flux-system; if [ $$? -eq 0 ] ; then break; else sleep 5; fi;done'
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=vela-core,app.kubernetes.io/instance=kubevela -n vela-system --timeout=600s
kubectl wait --for=condition=Ready pod -l app=source-controller -n flux-system --timeout=600s
kubectl wait --for=condition=Ready pod -l app=helm-controller -n flux-system --timeout=600s
.PHONY: e2e-setup-core-wo-auth
e2e-setup-core-wo-auth:
helm upgrade --install \
--create-namespace \
--namespace vela-system \
--set image.pullPolicy=IfNotPresent \
--set image.repository=vela-core-test \
--set applicationRevisionLimit=5 \
--set controllerArgs.reSyncPeriod=1m \
--set optimize.disableComponentRevision=false \
--set image.tag=$(GIT_COMMIT) \
--set multicluster.clusterGateway.image.repository=ghcr.io/oam-dev/cluster-gateway \
--set admissionWebhooks.patch.image.repository=ghcr.io/oam-dev/kube-webhook-certgen/kube-webhook-certgen \
--set featureGates.enableCueValidation=true \
--set featureGates.validateResourcesExist=true \
--set featureGates.enableApplicationScopedPolicies=true \
--set featureGates.enableGlobalPolicies=true \
--wait kubevela ./charts/vela-core \
--debug
.PHONY: e2e-setup-core-w-auth
e2e-setup-core-w-auth:
helm upgrade --install \
--create-namespace \
--namespace vela-system \
--set image.pullPolicy=IfNotPresent \
--set image.repository=vela-core-test \
--set applicationRevisionLimit=5 \
--set optimize.disableComponentRevision=false \
--set image.tag=$(GIT_COMMIT) \
--wait kubevela \
./charts/vela-core \
--set authentication.enabled=true \
--set authentication.withUser=true \
--set authentication.groupPattern='*' \
--set featureGates.zstdResourceTracker=true \
--set featureGates.zstdApplicationRevision=true \
--set featureGates.validateComponentWhenSharding=true \
--set featureGates.validateResourcesExist=true \
--set multicluster.clusterGateway.enabled=true \
--set multicluster.clusterGateway.image.repository=ghcr.io/oam-dev/cluster-gateway \
--set admissionWebhooks.patch.image.repository=ghcr.io/oam-dev/kube-webhook-certgen/kube-webhook-certgen \
--set sharding.enabled=true \
--debug
kubectl get deploy kubevela-vela-core -oyaml -n vela-system | \
sed 's/schedulable-shards=/shard-id=shard-0/g' | \
sed 's/instance: kubevela/instance: kubevela-shard/g' | \
sed 's/shard-id: master/shard-id: shard-0/g' | \
sed 's/name: kubevela/name: kubevela-shard/g' | \
kubectl apply -f -
kubectl wait deployment -n vela-system kubevela-shard-vela-core --for condition=Available=True --timeout=90s
.PHONY: e2e-setup-core
e2e-setup-core: e2e-setup-core-pre-hook e2e-setup-core-wo-auth e2e-setup-core-post-hook
.PHONY: e2e-setup-core-auth
e2e-setup-core-auth: e2e-setup-core-pre-hook e2e-setup-core-w-auth e2e-setup-core-post-hook
.PHONY: e2e-api-test
e2e-api-test:
# Run e2e test
ginkgo -v -skipPackage capability,setup,application -r e2e
ginkgo -v -r e2e/application
.PHONY: e2e-test
e2e-test:
# Run e2e test (KUBEVELA_E2E_AUTH=1 enables auth-test registry setup)
KUBEVELA_E2E_AUTH=1 ginkgo -v ./test/e2e-test
@$(OK) tests pass
# Run e2e tests with k3d and webhook validation
.PHONY: e2e-test-local
e2e-test-local:
# Create k3d cluster if needed
@k3d cluster create kubevela-debug --servers 1 --agents 1 || true
# Build and load image
docker build -t vela-core:e2e-test -f Dockerfile . --build-arg=VERSION=e2e-test --build-arg=GITVERSION=test
k3d image import vela-core:e2e-test -c kubevela-debug
# Pre-load auth-test registry images used by Describe("Helmchart Auth")
# in test/e2e-test/helmchart_test.go. Each command runs on its own
# line under `set -e` so a failed pull stops the loop (a `&&` chain
# would swallow the failure as far as `set -e` is concerned).
@set -e ; for img in \
ghcr.io/project-zot/zot-minimal-linux-amd64:v2.1.1 \
ghcr.io/helm/chartmuseum:v0.16.2 \
docker.io/library/nginx:1.27-alpine ; do \
docker pull $$img ; \
k3d image import $$img -c kubevela-debug ; \
done
# Deploy with Helm
kubectl delete validatingwebhookconfiguration kubevela-vela-core-admission 2>/dev/null || true
helm upgrade --install kubevela ./charts/vela-core \
--namespace vela-system --create-namespace \
--set image.repository=vela-core \
--set image.tag=e2e-test \
--set image.pullPolicy=IfNotPresent \
--set admissionWebhooks.enabled=true \
--set featureGates.enableCueValidation=true \
--set featureGates.validateResourcesExist=true \
--set applicationRevisionLimit=5 \
--set controllerArgs.reSyncPeriod=1m \
--wait --timeout 3m
# Run tests (auth registries pre-loaded above, enable the gate)
KUBEVELA_E2E_AUTH=1 ginkgo -v ./test/e2e-test
@$(OK) tests pass
# Run e2e application tests with k3d and webhook validation
.PHONY: e2e-application-test-local
e2e-application-test-local:
# Create k3d cluster if needed
@k3d cluster create kubevela-debug --servers 1 --agents 1 || true
# Build and load image
docker build -t vela-core:e2e-test -f Dockerfile . --build-arg=VERSION=e2e-test --build-arg=GITVERSION=test
k3d image import vela-core:e2e-test -c kubevela-debug
# Deploy with Helm
kubectl delete validatingwebhookconfiguration kubevela-vela-core-admission 2>/dev/null || true
helm upgrade --install kubevela ./charts/vela-core \
--namespace vela-system --create-namespace \
--set image.repository=vela-core \
--set image.tag=e2e-test \
--set image.pullPolicy=IfNotPresent \
--set admissionWebhooks.enabled=true \
--set featureGates.enableCueValidation=true \
--set featureGates.validateResourcesExist=true \
--set applicationRevisionLimit=5 \
--set controllerArgs.reSyncPeriod=1m \
--wait --timeout 3m
# Clean up any leftover vela resources from previous test runs
@vela ls -n default --quiet 2>/dev/null | tail -n +2 | awk '{print $$1}' | xargs -I {} vela delete {} -n default -y 2>/dev/null || true
@vela env delete env-application 2>/dev/null || true
# Run application tests
ginkgo -v -r e2e/application
@$(OK) tests pass
@$(MAKE) k3d-delete
# Run main_e2e_test.go with k3d cluster and embedded test binary
.PHONY: e2e-test-main-local
e2e-test-main-local:
@echo "==> Setting up k3d cluster for main_e2e_test..."
# Delete existing cluster if it exists and recreate
@k3d cluster delete kubevela-e2e-main 2>/dev/null || true
@k3d cluster create kubevela-e2e-main --servers 1 --agents 1
@echo "==> Building test binary with Dockerfile.e2e..."
# Detect architecture for proper binary naming
$(eval ARCH := $(shell uname -m | sed 's/x86_64/amd64/; s/aarch64\|arm64/arm64/'))
@echo " Detected architecture: $(ARCH)"
# Build test image with embedded e2e test
# Note: Use 'make e2e-test-main-rebuild' if you get "manager-${ARCH}: not found" errors
docker build -t vela-core:e2e-main-test -f Dockerfile.e2e . \
--no-cache \
--build-arg=TARGETARCH=$(ARCH) \
--build-arg=VERSION=e2e-main-test \
--build-arg=GITVERSION=test
# Load image into k3d cluster
k3d image import vela-core:e2e-main-test -c kubevela-e2e-main
@echo "==> Modifying Helm charts to enable e2e test..."
# Backup original chart
@cp ./charts/vela-core/templates/kubevela-controller.yaml ./charts/vela-core/templates/kubevela-controller.yaml.bak || true
# Modify charts to add test flags
sh ./hack/e2e/modify_charts.sh
@echo "==> Deploying vela-core with embedded test..."
# Clean up any existing webhook configs
kubectl delete validatingwebhookconfiguration kubevela-vela-core-admission 2>/dev/null || true
# Deploy with test binary and flags
helm upgrade --install kubevela ./charts/vela-core \
--namespace vela-system --create-namespace \
--set image.repository=vela-core \
--set image.tag=e2e-main-test \
--set image.pullPolicy=IfNotPresent \
--set admissionWebhooks.enabled=false \
--set multicluster.enabled=false \
--set multicluster.clusterGateway.enabled=false \
--set featureGates.enableCueValidation=true \
--set featureGates.validateResourcesExist=true \
--set applicationRevisionLimit=5 \
--set controllerArgs.reSyncPeriod=1m \
--wait --timeout 3m
@echo "==> Waiting for test to complete..."
# Give the test time to run (it starts the server and runs tests)
@sleep 10
@echo "==> Checking test results from pod logs..."
# Get the pod name and check logs for test results
@kubectl logs -n vela-system -l app.kubernetes.io/name=vela-core --tail=100 | grep -E "PASS|FAIL|TestE2EMain" || true
@echo "==> Test coverage will be available at /workspace/data/e2e-profile.out in the pod"
# Optionally copy coverage data from pod
@POD=$$(kubectl get pod -n vela-system -l app.kubernetes.io/name=vela-core -o jsonpath='{.items[0].metadata.name}') && \
kubectl cp vela-system/$$POD:/workspace/data/e2e-profile.out ./e2e-main-coverage.out 2>/dev/null || \
echo "Coverage data not yet available or test still running"
# Restore original chart
@mv ./charts/vela-core/templates/kubevela-controller.yaml.bak ./charts/vela-core/templates/kubevela-controller.yaml 2>/dev/null || true
@echo "==> Done. Check pod logs for detailed test output:"
@echo " kubectl logs -n vela-system -l app.kubernetes.io/name=vela-core -f"
@$(OK) main_e2e_test setup complete
# Clean up k3d cluster used for main_e2e_test
.PHONY: e2e-test-main-clean
e2e-test-main-clean:
@echo "==> Cleaning up k3d cluster for main_e2e_test..."
k3d cluster delete kubevela-e2e-main || true
# Restore original chart if backup exists
@mv ./charts/vela-core/templates/kubevela-controller.yaml.bak ./charts/vela-core/templates/kubevela-controller.yaml 2>/dev/null || true
@echo "==> Cleanup complete"
.PHONY: e2e-addon-test
e2e-addon-test:
cp bin/vela /tmp/
ginkgo -v ./test/e2e-addon-test
@$(OK) tests pass
.PHONY: e2e-multicluster-test
e2e-multicluster-test:
cd ./test/e2e-multicluster-test && go test -timeout=30m -v -ginkgo.v -ginkgo.trace -coverpkg=./... -coverprofile=/tmp/e2e_multicluster_test.out
@$(OK) tests pass
.PHONY: e2e-cleanup
e2e-cleanup:
# Clean up
rm -rf ~/.vela
.PHONY: end-e2e-core
end-e2e-core:
sh ./hack/e2e/end_e2e_core.sh
.PHONY: end-e2e-core-shards
end-e2e-core-shards: end-e2e-core
CORE_NAME=kubevela-shard sh ./hack/e2e/end_e2e_core.sh
.PHONY: end-e2e
end-e2e:
sh ./hack/e2e/end_e2e.sh