Skip to content
This repository was archived by the owner on Dec 12, 2025. It is now read-only.

Commit 0aa1ed4

Browse files
authored
Run E2E Tests with Telepresence (#515)
1 parent cf15a17 commit 0aa1ed4

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ fmt:
6464
vet:
6565
go vet ./...
6666

67+
# Run e2e tests locally using go build while also setting up a proxy in the shell to allow
68+
# the test to run as if it were inside the cluster. This enables mongodb connectivity while running locally.
69+
e2e-telepresence: install
70+
telepresence connect; \
71+
telepresence status; \
72+
eval $$(scripts/dev/get_e2e_env_vars.py $(cleanup)); \
73+
go test -v -timeout=30m -failfast ./test/e2e/$(test); \
74+
telepresence quit
75+
6776
# Run e2e test by deploying test image in kubernetes.
6877
e2e-k8s: install e2e-image
6978
python scripts/dev/e2e.py --perform-cleanup --test $(test)
@@ -126,3 +135,5 @@ rm -rf $$TMP_DIR ;\
126135
}
127136
endef
128137

138+
install-prerequisites-macos:
139+
scripts/dev/install_prerequisites.sh

docs/contributing.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,19 @@ make e2e-k8s test=<test-name>
201201
This will run the `replica_set` E2E test which is a simple test which installs a
202202
MongoDB Replica Set and asserts that the deployed server can be connected to.
203203

204+
205+
### Run the test locally with go test & Telepresence
206+
```sh
207+
make e2e-telepresence test=<test-name>
208+
```
209+
210+
This method uses telepresence to allow connectivity as if your local machine is in the kubernetes cluster,
211+
there will be full MongoDB connectivity using `go test` locally.
212+
213+
Note: you must install [telepresence](https://www.getambassador.io/docs/telepresence/latest/quick-start/) before using this method.
214+
215+
If on MacOS, you can run `make install-prerequisites-macos` which will perform the installation.
216+
204217
## Troubleshooting
205218
When you run a test locally, if the `e2e-test` pod is present, you will have to
206219
first manually delete it; failing to do so will cause the `e2e-test` pod to fail.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
if ! command -v telepresence &> /dev/null; then \
4+
echo "Telepresence not found, installing now"
5+
sudo curl -fL https://app.getambassador.io/download/tel2/darwin/amd64/latest/telepresence -o /usr/local/bin/telepresence
6+
sudo chmod a+x /usr/local/bin/telepresence
7+
else
8+
echo "Telepresence already installed."
9+
fi

0 commit comments

Comments
 (0)