Skip to content

Commit

Permalink
Developer docs for single e2e test run locally
Browse files Browse the repository at this point in the history
Signed-off-by: jmcshane <[email protected]>
  • Loading branch information
jmcshane committed Sep 14, 2023
1 parent ab9fc97 commit e6232dd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ endef

#
define exec-in-test-server
$(SUDO) docker exec -it -u $(CONTAINER_UID):$(CONTAINER_GID) -e ARGOCD_E2E_RECORD=$(ARGOCD_E2E_RECORD) -e ARGOCD_E2E_K3S=$(ARGOCD_E2E_K3S) argocd-test-server $(1)
$(SUDO) docker exec -it -u $(CONTAINER_UID):$(CONTAINER_GID) -e ARGOCD_E2E_RECORD=$(ARGOCD_E2E_RECORD) -e TEST_FLAGS="$(TEST_FLAGS)" -e ARGOCD_E2E_K3S=$(ARGOCD_E2E_K3S) argocd-test-server $(1)
endef

PATH:=$(PATH):$(PWD)/hack
Expand Down Expand Up @@ -413,10 +413,10 @@ test-e2e:

# Run the E2E test suite (local version)
.PHONY: test-e2e-local
test-e2e-local: cli-local
test-e2e-local:
# NO_PROXY ensures all tests don't go out through a proxy if one is configured on the test system
export GO111MODULE=off
ARGOCD_E2E_RECORD=${ARGOCD_E2E_RECORD} ARGOCD_GPG_ENABLED=true NO_PROXY=* ./hack/test.sh -timeout $(ARGOCD_E2E_TEST_TIMEOUT) -v ./test/e2e
TEST_FLAGS="${TEST_FLAGS}" ARGOCD_E2E_RECORD=${ARGOCD_E2E_RECORD} ARGOCD_GPG_ENABLED=true NO_PROXY=* ./hack/test.sh -timeout $(ARGOCD_E2E_TEST_TIMEOUT) -v ./test/e2e

# Spawns a shell in the test server container for debugging purposes
debug-test-server: test-tools-image
Expand Down
10 changes: 10 additions & 0 deletions docs/developer-guide/test-e2e.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ Git repository via file url: `file:///tmp/argocd-e2e***`.

You can observe the tests by using the UI [http://localhost:8080/applications](http://localhost:8080/applications) with username `"admin"` and password `"password"`.

### Running Single E2E Test

The `test-e2e` target passes the `TEST_FLAGS` environment variable to the `go test` run inside the local ArgoCD server container. To run a single e2e test, set this environment variable execution: `TEST_FLAGS="-run ^TestCustomToolWithEnv\$$" make test-e2e`

_Dollar signs need to be escaped with a double dollar for the `Makefile` forwarding the execution to the underlying container._

If you are running using the local toolchain, this same environment variable can be used. `make` only reads the variable in the translation between the local and virtual environments, so only standard bash escaping mechanisms need to be used: `TEST_FLAGS="-run ^TestCustomToolWithEnv\$" make test-e2e-local`

See the [Toolchain Guide](toolchain-guide.md) for more information about local development practices.

## Configuration of E2E Tests execution

The Makefile's `start-e2e` target starts instances of ArgoCD on your local machine, of which the most will require a network listener. If for whatever reason you already have network services on your machine listening on the same ports, the e2e tests will not be able to run. You can derive from the defaults by setting the following environment variables before you run `make start-e2e`:
Expand Down
2 changes: 1 addition & 1 deletion hack/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -eux -o pipefail
which go-junit-report || go install github.com/jstemmer/go-junit-report@latest

TEST_RESULTS=${TEST_RESULTS:-test-results}
TEST_FLAGS=
TEST_FLAGS=${TEST_FLAGS:-}

if test "${ARGOCD_TEST_PARALLELISM:-}" != ""; then
TEST_FLAGS="$TEST_FLAGS -p $ARGOCD_TEST_PARALLELISM"
Expand Down

0 comments on commit e6232dd

Please sign in to comment.