The release Dockerfile's shipped binaries and symlinks were already hanzocd-*, but the build stages feeding them weren't: stage names (argocd-base/-ui/-build), the in-container build user/group/home (argocd, uid 999 — renamed in place, same uid so no ownership fallout), and the GOPATH-style build WORKDIR (.../argoproj/argo-cd) all still carried the pre-fork name. Same in Dockerfile.dev, hack/Dockerfile.dev-tools, and ui/scripts/build_docker.sh. The Makefile and both Procfiles (root + test/container) had the matching half of this: CD_BINARY_NAME values that don't match any case in cmd/main.go's dispatch switch (all hanzocd-*), a --argocd-repo-server flag no command registers (the real one is --cd-repo-server), a `kubectl get secret argocd-redis` that can never succeed (the Secret the redis manifest actually mounts is hanzocd-redis), `kubectl create ns argocd`/argocd-e2e(-external(-2)) that don't match the namespaces test/e2e/fixture actually uses (cd/cd-e2e/cd-e2e-external(-2)), a TEST_MODULE filter matching the pre-fork gitops-engine import path only, and IMAGE_REGISTRY/IMAGE_NAMESPACE/IMAGE_REPOSITORY defaults that silently point an override-less `make image` at quay.io/argoproj/argocd instead of ghcr.io/hanzoai/cd. Also folded three different stale /tmp scratch-dir spellings (argocd-local, argocd-e2e-env, argo-e2e) into the one each already-correct sibling file used, so Procfile/Makefile/reaper.sh/ start-git.sh/fixture.go/nginx.conf all agree again — see LLM.md for the full map, it's not worth re-deriving twice. Deleted hack/bump-major-version.sh: it bumps a github.com/.../vN import-path suffix, a scheme this module has never used (no /v2, /v3 — we don't bump Go majors) and nothing else in the repo references it.
4.0 KiB
E2E Tests
The test directory contains E2E tests and test applications. The tests assume that Hanzo CD services are installed into cd-e2e namespace or cluster in current context. A throw-away
namespace cd-e2e*** is created prior to the execution of the tests. The throw-away namespace is used as a target namespace for test applications.
The /test/e2e/testdata directory contains various Hanzo CD applications. Before test execution, the directory is copied into /tmp/cd-e2e*** temp directory (configurable by CD_E2E_DIR) and used in tests as a
Git repository via file url: file:///tmp/cd-e2e***.
Note
You might get an error such as
unable to ls-remote HEAD on repository: failed to list refs: repository not foundwhen querying the local repository exposed through the e2e server running in a container. This is often caused by/tmpdirectoring sharing protection. You can configure a different directory withCD_E2E_DIR, or disable the directory sharing protection.Rancher Desktop Volume Sharing
To do enable
/tmpsharing, add the following to~/Library/Application\ Support/rancher-desktop/lima/_config/override.yamland restart Rancher Desktop:mounts: - location: /private/tmp writable: true
Running Tests Locally
With virtualized chain
- Start the e2e version
make start-e2e - Run the tests:
make test-e2e
With local chain
- Start the e2e version
make start-e2e-local - Run the tests:
make test-e2e-local
Observing tests results
You can observe the tests by using the UI http://localhost:4000/applications with username "admin" and password "password".
Configuration of E2E Tests execution
The Makefile's start-e2e target starts instances of Hanzo CD on your local machine, of which the most will require a network listener. If, for any reason, your machine already has network services listening on the same ports, then the e2e tests will not run. You can derive from the defaults by setting the following environment variables before you run make start-e2e:
CD_E2E_APISERVER_PORT: Listener port forcd-server(default:8080)CD_E2E_REPOSERVER_PORT: Listener port forcd-reposerver(default:8081)CD_E2E_DEX_PORT: Listener port fordex(default:5556)CD_E2E_KV_PORT: Listener port forredis(default:6379)CD_E2E_PNPM_CMD: Command to use for starting the UI via pnpm (default:pnpm)CD_E2E_DIR: Local path to the repository to use for ephemeral test data
If you have changed the port for cd-server, be sure to also set CD_SERVER environment variable to point to that port, e.g. export CD_SERVER=localhost:8888 before running make test-e2e so that the test will communicate to the correct server component.
Test Isolation
Some effort has been made to balance test isolation with speed. Tests are isolated as follows as each test gets:
- A random 5 character ID.
- A unique Git repository containing the
testdatain/tmp/cd-e2e/${id}. - A namespace
cd-e2e-ns-${id}. - A primary name for the app
cd-e2e-${id}.
Run only a subset of tests
Running all tests locally is a time-consuming process. To run only a subset of tests, you can set the TEST_MODULE environment variable.
For example, to run only the OCI tests, you can set the variable as follows: make TEST_MODULE=./test/e2e/oci_test.go test-e2e-local
If you want to get a more fine-grained control over which tests to run, you can also try make TEST_FLAGS="-run <TEST_METHOD_NAME_REGEXP>" test-e2e-local
For individual tests you can run them using the IDE run test feature
Troubleshooting
Tests fails to delete cd-e2e-ns-* namespaces.
This maybe due to the metrics server, run this:
kubectl api-resources
If it exits with status code 1, run:
kubectl delete apiservice v1beta1.metrics.k8s.io
Remove /spec/finalizers from the namespace
kubectl edit ns cd-e2e-ns-*