Skip to content

Commit 7947530

Browse files
docs(project): improve integration test docs and add convenience target (#14796)
Because * The integration test section of the README was missing key details that developers need when running tests locally, including the `.env.integration-tests` file, test markers, troubleshooting tips, and key file locations * Running integration tests locally required 5 manual steps that could be automated into a single make command * Yashika's internal integration test setup guide had useful steps that were not reflected in the README This commit * Rewrites the integration test section with a clear step-by-step guide for running tests locally via VNC * Adds a `make integration_test_vnc TEST="..."` convenience target that handles `.env` copy, `SKIP_DUMMY=1`, `PYTEST_ARGS` configuration, and stack setup in a single command * Adds `PYTEST_BASE_URL` default (`https://nginx/nimbus/`) so it no longer needs to be exported manually * Documents test markers, environment variables, key files, and troubleshooting tips * Preserves the native Firefox (non-Docker) workflow as an alternative Fixes #14795 --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d4834d4 commit 7947530

File tree

2 files changed

+105
-63
lines changed

2 files changed

+105
-63
lines changed

Makefile

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ COMPOSE_PROD = docker compose -f docker-compose-prod.yml $$(${COMPOSE_CIRRUS})
1212
COMPOSE_INTEGRATION = ${COMPOSE_PROD} -f docker-compose-integration-test.yml $$(${COMPOSE_CIRRUS})
1313
COMPOSE_INTEGRATION_RUN = ${COMPOSE_INTEGRATION} run --name experimenter_integration
1414
DOCKER_BUILD = docker buildx build
15+
PYTEST_BASE_URL ?= https://nginx/nimbus/
1516

1617
# Extra flags for docker buildx build, per target. Override to add caching, --load, etc.
1718
MEGAZORD_BUILD_FLAGS ?=
@@ -250,7 +251,26 @@ integration_sdk_shell: build_prod build_integration_test
250251

251252
integration_vnc_shell: build_prod
252253
$(COMPOSE_INTEGRATION) up -d firefox
253-
docker exec -it $$(docker ps -qf "name=experimenter-firefox-1") bash
254+
$(COMPOSE_INTEGRATION) exec firefox bash
255+
256+
# Run a specific integration test locally via VNC.
257+
# Usage: make integration_test_vnc TEST="test_archive_experiment[FIREFOX_DESKTOP]"
258+
integration_test_vnc: build_prod
259+
cp .env.integration-tests .env
260+
SKIP_DUMMY=1 $(MAKE) refresh up_prod_detached
261+
@echo ""
262+
@echo "=========================================="
263+
@echo "Connect VNC to watch the test:"
264+
@echo " VNC: vnc://localhost:5900 (password: secret)"
265+
@echo " noVNC: http://localhost:7902 (password: secret)"
266+
@echo ""
267+
@echo "Then run: ./experimenter/tests/nimbus_integration_tests.sh"
268+
@echo "=========================================="
269+
@echo ""
270+
PYTEST_ARGS="-k $(TEST) --reruns 0 --base-url $(PYTEST_BASE_URL)" \
271+
PYTEST_BASE_URL="$(PYTEST_BASE_URL)" \
272+
$(COMPOSE_INTEGRATION) up -d firefox
273+
$(COMPOSE_INTEGRATION) exec firefox bash
254274

255275
integration_test_nimbus_desktop: build_prod integration_clean
256276
MOZ_HEADLESS=1 $(COMPOSE_INTEGRATION_RUN) firefox sh -c "FIREFOX_CHANNEL=$(FIREFOX_CHANNEL) PYTEST_SENTRY_DSN=$(PYTEST_SENTRY_DSN) PYTEST_SENTRY_ALWAYS_REPORT=$(PYTEST_SENTRY_ALWAYS_REPORT) CIRCLECI=$(CIRCLECI) ./experimenter/tests/nimbus_integration_tests.sh"

README.md

Lines changed: 84 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -430,97 +430,119 @@ yarn workspace @experimenter/nimbus-ui test:cov
430430

431431
For a full reference of all the common commands that can be run inside the container, refer to [this section of the Makefile](https://github.com/mozilla/experimenter/blob/main/Makefile#L16-L38)
432432

433-
#### make integration_test_legacy
433+
### Integration Tests
434434

435-
Run the integration test suite for experimenter inside a containerized instance of Firefox. You must also be already running a `make up` dev instance in another shell to run the integration tests.
435+
The integration tests run Selenium against a full Experimenter stack (app server, nginx, kinto, Firefox) inside Docker containers. They are defined in `experimenter/tests/integration/nimbus/` and configured in `.circleci/config.yml`.
436436

437-
#### make FIREFOX_CHANNEL integration_test_nimbus_desktop
437+
#### Running a specific test locally (recommended)
438438

439-
Run the integration test suite for nimbus inside a containerized instance of Firefox. You must also be already running a `make up` dev instance in another shell to run the integration tests.
439+
The easiest way to run and debug integration tests is via VNC, which lets you watch Firefox execute the test in real time.
440440

441-
FIREFOX_CHANNEL should either be `release`, `nightly` or `beta`, and include it in the make command.
442-
443-
#### make integration_test_nimbus_sdk
444-
445-
Run the Nimbus SDK integration tests, which tests the advanced targeting configurations against the Nimbus SDK.
446-
447-
#### make integration_vnc_shell
448-
449-
First start a prod instance of Experimenter with:
441+
1. Run a single make command with the test you want to run:
450442

451443
```bash
452-
make refresh&&make up_prod_detached
444+
make integration_test_vnc TEST="test_archive_experiment[FIREFOX_DESKTOP]"
453445
```
454446

455-
Then start the VNC service:
447+
This automatically handles environment setup (copies `.env.integration-tests`, sets `SKIP_DUMMY=1`, configures `PYTEST_ARGS` with `--reruns 0` and `--base-url`), rebuilds containers, and drops you into a shell inside the Firefox/Selenium container.
448+
449+
2. Connect a VNC viewer to watch the test:
450+
- **VNC client** (e.g. Safari on macOS, [VNC Viewer](https://www.realvnc.com/en/connect/download/viewer/)): `vnc://localhost:5900`, password `secret`
451+
- **noVNC** (browser-based): `http://localhost:7902`, password `secret`
452+
453+
3. From the shell inside the container, run the test script:
456454

457455
```bash
458-
make integration_vnc_shell
456+
./experimenter/tests/nimbus_integration_tests.sh
459457
```
460458

461-
Then open your VNC client (Safari does this on OSX or just use [VNC Viewer](https://www.realvnc.com/en/connect/download/viewer/)) and open `vnc://localhost:5900` with password `secret`.
459+
This installs Firefox, Poetry dependencies, and runs pytest with your `PYTEST_ARGS`. You can watch the test execute in the VNC window.
462460

463-
To use NoVNC, navgate to this url `http://localhost:7902` with the password `secret`. Then you can follow the same steps as above.
461+
#### Make targets
464462

465-
When the command executes successfully, you will have terminal access to the running Firefox container. After you follow the above steps to connect via VNC, run `firefox` and confirm that a Firefox browser loads.
463+
| Target | Description |
464+
|--------|-------------|
465+
| `make integration_test_vnc TEST="..."` | One-command setup: copies `.env`, rebuilds, starts stack, drops into VNC shell with `PYTEST_ARGS` pre-configured |
466+
| `make integration_vnc_shell` | Opens a bash shell in the Firefox/Selenium container with VNC enabled (manual env setup required) |
467+
| `make FIREFOX_CHANNEL=release integration_test_nimbus_desktop` | Runs the full desktop test suite (`release`, `beta`, or `nightly`) |
468+
| `make integration_test_nimbus_sdk` | Runs Nimbus SDK targeting integration tests |
469+
| `make integration_test_legacy` | Runs legacy experimenter integration tests |
470+
| `make integration_sdk_shell` | Opens a shell with the mobile SDK set up for testing |
466471

467-
To then run the tests, set `PYTEST_ARGS` with the tests you want to run, i.e.: `export PYTEST_ARGS=-k test_archive[FIREFOX_DESKTOP]`. You will need to include the nimbus client you want to test against as well. You can also set the Firefox Channel you want to run against via the `FIREFOX_CHANNEL` environment variable. Then execute the test script. The following is an example using the above environment variables:
468-
```sh
469-
PYTEST_ARGS="-k test_archive_experiment[FIREFOX_DESKTOP]" FIREFOX_CHANNEL="nightly" ./experimenter/tests/nimbus_integration_tests.sh
470-
```
472+
#### Environment variables
471473

472-
### Running Integration tests locally
474+
| Variable | Description | Example |
475+
|----------|-------------|---------|
476+
| `PYTEST_ARGS` | [Pytest CLI options](https://docs.pytest.org/en/stable/reference/reference.html#command-line-flags). Use `-k` to select tests, `-m` to select markers, `--reruns 0` to disable retries when debugging. | `-k test_archive_experiment[FIREFOX_DESKTOP] --reruns 0 --base-url https://nginx/nimbus/` |
477+
| `PYTEST_BASE_URL` | Base URL for the Experimenter instance under test. | `https://nginx/nimbus/` |
478+
| `FIREFOX_CHANNEL` | Firefox channel to test against. Defaults to `release`. | `release`, `beta`, `nightly` |
473479

474-
1. Install [geckodriver](https://github.com/mozilla/geckodriver/releases) and have it available in your path. You should be able to run `geckodriver --version` from your command line. On MacOS you can do `brew install geckodriver` if you have homebrew installed.
475-
2. Add your Firefox install to your path. You should be able to run `firefox --version` from your command line.
476-
```sh
477-
alias firefox="path-to/firefox"
478-
```
479-
Example for macos add this to your `~/.zshrc` file:
480-
```sh
481-
alias firefox="/Applications/Firefox.app/Contents/MacOS/firefox"
482-
```
483-
3. Setup experimenter:
484-
```sh
485-
make refresh build_integration_test SKIP_DUMMY=1 up_prod_detached
486-
```
487-
Navigate with your browser to `https://localhost/nimbus` to confirm everything is working.
488-
4. To then run the tests, set `PYTEST_ARGS` with the tests you want to run, i.e.: `PYTEST_ARGS=-k test_archive_experiment[FIREFOX_DESKTOP]`. You will need to include the nimbus client you want to test against as well. You can also set the Firefox Channel you want to run against via the `FIREFOX_CHANNEL` environment variable. Then execute the test script. The following is an example using the above environment variables:
489-
```sh
490-
PYTEST_ARGS="-k test_archive_experiment[FIREFOX_DESKTOP]" FIREFOX_CHANNEL="nightly" ./experimenter/tests/nimbus_integration_tests.sh
491-
```
480+
#### Test markers
492481

493-
Firefox should pop up and start running through your test! You can change the firefox version the tests run on by copying the path of the `firefox-bin` and adding it to the `firefox_options` fixture in the `tests/integration/nimbus/conftest.py` file:
482+
Tests are organized with pytest markers. Use `-m <marker>` in `PYTEST_ARGS` to run a specific group:
494483

495-
```sh
496-
firefox_options.binary = "path/to/firefox-bin"
497-
```
484+
| Marker | Description |
485+
|--------|-------------|
486+
| `nimbus_ui` | UI-only tests (no external service integration) |
487+
| `desktop_enrollment` | Tests that integrate with Nimbus and external services |
488+
| `cirrus_enrollment` | Tests that integrate with the demo app and Cirrus |
489+
| `remote_settings_launch` | A single test for launching to Remote Settings |
490+
| `remote_settings_experiments` | Remote Settings tests for experiments |
491+
| `remote_settings_rollouts` | Remote Settings tests for rollouts (basic flows) |
492+
| `remote_settings_live_updates` | Remote Settings tests for rollout live updates |
493+
| `run_targeting` | JEXL targeting tests in Firefox |
498494

499-
#### Integration Test options
495+
#### Running without Docker (native Firefox)
500496

501-
- `PYTEST_ARGS`: [Pytest](https://docs.pytest.org/en/6.2.x/usage.html#) commandline variables.
497+
If you prefer to run tests against a local Firefox install instead of the Docker container:
502498

503-
An example using PYTEST_ARGS to run one test.
499+
1. Install [geckodriver](https://github.com/mozilla/geckodriver/releases) (`brew install geckodriver` on macOS) and confirm it works:
500+
```bash
501+
geckodriver --version
502+
```
504503

505-
```bash
506-
make integration_test_legacy PYTEST_ARGS="-k test_addon_rollout_experiment_e2e"
507-
```
504+
2. Make sure `firefox` is in your PATH. On macOS, add to your `~/.zshrc`:
505+
```bash
506+
alias firefox="/Applications/Firefox.app/Contents/MacOS/firefox"
507+
```
508508

509-
Note: You need the following firefox version flag when running integration tests
509+
3. Start Experimenter:
510+
```bash
511+
cp .env.integration-tests .env
512+
make refresh build_integration_test SKIP_DUMMY=1 up_prod_detached
513+
```
514+
Confirm it's running at `https://localhost/nimbus`.
510515

511-
```sh
512-
FIREFOX_CHANNEL=release
513-
```
516+
4. Run the tests:
517+
```bash
518+
PYTEST_ARGS="-k test_archive_experiment[FIREFOX_DESKTOP] --reruns 0" ./experimenter/tests/nimbus_integration_tests.sh
519+
```
514520

515-
An example for above:
521+
Firefox will launch and run the test. To use a different Firefox binary, set it in the `firefox_options` fixture in `experimenter/tests/integration/nimbus/conftest.py`:
516522

517-
```sh
518-
make FIREFOX_CHANNEL=release integration_test_nimbus_desktop PYTEST_ARGS=ktest_rollout_create_and_update
523+
```python
524+
firefox_options.binary = "/path/to/firefox-bin"
519525
```
520526

521-
#### make integration_sdk_shell
522-
523-
This builds and sets up the mobile sdk for use in testing.
527+
#### Key files
528+
529+
| Path | Description |
530+
|------|-------------|
531+
| `experimenter/tests/integration/nimbus/conftest.py` | Pytest fixtures including `create_experiment` and Selenium setup |
532+
| `experimenter/tests/integration/nimbus/pages/` | Page objects for UI interactions (Summary, Branches, Audience, etc.) |
533+
| `experimenter/tests/integration/nimbus/models/` | Data models for test experiments |
534+
| `experimenter/tests/nimbus_integration_tests.sh` | Entry point that installs Firefox and runs pytest |
535+
| `experimenter/tests/pytest.ini` | Pytest configuration and marker definitions |
536+
| `docker-compose-integration-test.yml` | Firefox/Selenium container config |
537+
| `.env.integration-tests` | Env file with short Kinto polling intervals for tests |
538+
| `.circleci/config.yml` | CI job definitions and `PYTEST_ARGS` used in CI |
539+
540+
#### Troubleshooting
541+
542+
- **502 from nginx**: The experimenter container IP may have changed after a restart. Run `docker restart <nginx-container>` to re-resolve it.
543+
- **Port conflicts**: Only run one Experimenter stack at a time — they share host ports (3001, 5432, 7001, 8000, 8888). Kill existing containers first with `docker compose kill` in the other directory.
544+
- **Feature dropdown selects wrong feature**: The feature search is substring-based and selects the first alphabetical match. Use a feature name that won't substring-match other features.
545+
- **Flaky button clicks**: Some tests may intermittently fail due to Selenium timing. Use `--reruns 1` in CI or re-run locally. When debugging, use `--reruns 0` to see the actual failure.
524546

525547
### Testing Tools
526548

0 commit comments

Comments
 (0)