You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Open PowerShell as administrator. Run `wsl --install` to install wsl. Run `wsl --list --online` to see list of available Ubuntu distributions. Run `wsl --install -d ` to install a particular distribution e.g `wsl --install -d Ubuntu-22.04`.
After installation, press Windows Key and search for Ubuntu. Open it and set up username and password.
Go to settings -> Resources -> WSL Integration and activate Ubuntu.
Click the activate and restart button to save your change.
Install Make and Git
Open the ubuntu terminal
You should install make using this command sudo apt-get update && sudo apt install make in the ubuntu terminal.
This is necessary for the make secretkey command and other commands.
Ensure git is available by running git --version. If it's not recognized, install git using sudo apt install git
Clone the repo
git clone
Copy the sample env file
cp .env.sample .env
Set DEBUG=True for local development
vi .env
Create a new secret key and put it in .env
make secretkey
vi .env
... SECRETKEY=mynewsecretkey ...
Run tests
make check
Setup the database
make refresh_db
Fully Dockerized Setup (continuation from General Setup 1-7)
Run a dev instance
make up
Navigate to it and add an SSL exception to your browser
https://localhost/
Semi Dockerized Setup (continuation from General Setup 1-7)
One might choose the semi dockerized approach for:
faster startup/teardown time (not having to rebuild/start/stop containers)
# run in separate shells (`poetry shell` in each) yarn workspace @experimenter/nimbus-ui start ./manage.py runserver 0.0.0.0:7001
Pro-tip: we have had at least one large code refactor. You can ignore specific large commits when blaming by setting the Git config's ignoreRevsFile to .git-blame-ignore-revs:
On certain pages an API endpoint is called to receive experiment analysis data from Jetstream to display visualization tables. To see experiment visualization data, you must provide GCP credentials.
Check if you already have access to the storage bucket here
If needed, ask in #nimbus-dev for a project admin to grant storage.objects.list permissions on the moz-fx-data-experiments project
Authorize CLI with your account
make auth_gcloud
this will save your credentials locally to a well-known location for use by any library that requests ADC
Note: if this returns Error saving Application Default Credentials: Unable to write file [...]: [Errno 21] Is a directory: ..., delete the directory and try again (rm -rf ~/.config/gcloud)
The next time you rebuild the docker-compose environment, your credentials will be loaded as a volume
Note that this will require the existing volume to be removed (hint: run make refresh)
(optional) Verify access
make refresh
make bash
./manage.py shell
from django.core.files.storage import default_storage default_storage.listdir('/')
Confirm this second command prints a list instead of an error
Google Cloud Bucket for Media Storage
We support user uploads of media (e.g. screenshots) for some features.
In local development, the default is to store these files in /experimenter/media using Django's FileSystemStorage class and the MEDIA_ROOT and MEDIA_URL settings.
In production, a GCP bucket and credentials are required.
The bucket name is configured with the UPLOADS_GS_BUCKET_NAME setting. For example:
For local testing of a production-like environment, The credentials should be configured as described in the previous section on Google Credentials for Jetstream.
Experimenter uses docker for all development, testing, and deployment.
Building
make build
Build the application container by executing the build script
make compose_build
Build the supporting services (nginx, postgresql) defined in the compose file
make ssl
Create dummy SSL certs to use the dev server over a locally secure
connection. This helps test client behaviour with a secure
connection. This task is run automatically when needed.
make kill
Stop and delete all docker containers.
WARNING: this will remove your database and all data. Use this to reset your dev environment.
make migrate
Apply all django migrations to the database. This must be run after removing database volumes before starting a dev instance.
make load_dummy_experiments
Populates the database with dummy experiments of all types/statuses using the test factories
make refresh
Run kill followed by refresh_db. Useful for resetting your dev environment when switching branches or after package updates.
make refresh_db
Run migrate, load_locales_countries, and load_dummy_experiments.
Running a dev instance
Enabling Cirrus
Cirrus is required to run and test web application experiments locally. It is disabled by default. To enable Cirrus run:
export CIRRUS=1
This will be done automatically for any Cirrus related make commands.
make up
Start a dev server listening on port 80 using the Django runserver. It is useful to run make refresh first to ensure your database is up to date with the latest migrations and test data.
make up_db
Start postgresql, redis, autograph, kinto on their respective ports to allow running the Django runserver and yarn watchers locally (non containerized)
make up_django
Start Django runserver, Celery worker, postgresql, redis, autograph, kinto on their respective ports to allow running the yarn watchers locally (non containerized)
make up_detached
Start all containers in the background (not attached to shell). They can be stopped using make kill.
make update_kinto
Pull in the latest Kinto Docker image. Kinto is not automatically updated when new versions are available, so this command can be used occasionally to stay in sync.
Running tests and checks
make check
Run all test and lint suites, this is run in CI on all PRs and deploys.
Helpful UI Testing Tips
If you have a test failing to find an element (or finding too many, etc.) and the DOM is being cut off in the console output,
you can increase how much is printed by locally editing the DEBUG_PRINT_LIMIT=7000 in the Makefile (line starts with JS_TEST_NIMBUS_UI).
make py_test
Run only the python test suite.
make bash
Start a bash shell inside the container. This lets you interact with the containerized filesystem and run Django management commands.
Helpful Python Tips
You can run the entire python test suite without coverage using the Django test runner:
./manage.py test
For faster performance you can run all tests in parallel:
./manage.py test --parallel
You can run only the tests in a certain module by specifying its Python import path:
./manage.py test experimenter.experiments.tests.api.v5.test_serializers
experiment=NimbusExperimentFactory.create_with_status(NimbusExperiment.Status.DRAFT, name="Look at me, I'm Mr Experiment") nimbus_push_experiment_to_kinto(experiment.id)
Helpful Yarn Tips
You can also interact with the yarn commands, such as checking TypeScript for Nimbus UI:
yarn workspace @experimenter/nimbus-ui lint:tsc
Or the test suite for Nimbus UI:
yarn workspace @experimenter/nimbus-ui test:cov
For a full reference of all the common commands that can be run inside the container, refer to this section of the Makefile
Integration Tests
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.
Running a specific test locally (recommended)
The easiest way to run and debug integration tests is via VNC, which lets you watch Firefox execute the test in real time.
Run a single make command with the test you want to run:
make integration_test_vnc TEST="test_archive_experiment[FIREFOX_DESKTOP]"
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.
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:
firefox_options.binary="/path/to/firefox-bin"
Key files
Path
Description
experimenter/tests/integration/nimbus/conftest.py
Pytest fixtures including create_experiment and Selenium setup
experimenter/tests/integration/nimbus/pages/
Page objects for UI interactions (Summary, Branches, Audience, etc.)
experimenter/tests/integration/nimbus/models/
Data models for test experiments
experimenter/tests/nimbus_integration_tests.sh
Entry point that installs Firefox and runs pytest
experimenter/tests/pytest.ini
Pytest configuration and marker definitions
docker-compose-integration-test.yml
Firefox/Selenium container config
.env.integration-tests
Env file with short Kinto polling intervals for tests
.circleci/config.yml
CI job definitions and PYTEST_ARGS used in CI
Troubleshooting
502 from nginx: The experimenter container IP may have changed after a restart. Run docker restart to re-resolve it.
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.
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.
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.
Testing Tools
Targeting test tool
Navigate to experimenter/tests/tools
To test a targeting expression, first add an app context named app_context.json to the experimenter/tests/tools directory.
You can then invoke the script with the --targeting-string flag:
The script should return the results, either True, False, or an error.
Note that you can change the app_context live, and run the script again after.
Accessing Remote Settings locally
In development you may wish to approve or reject changes to experiments as if they were on Remote Settings. You can do so here: http://localhost:8888/v1/admin/
There are three accounts you can log into Kinto with depending on what you want to do:
admin / admin - This account has permission to view and edit all of the collections.
experimenter / experimenter - This account is used by Experimenter to push its changes to Remote Settings and mark them for review.
review / review - This account should generally be used by developers testing the workflow, it can be used to approve/reject changes pushed from Experimenter.
The admin and review credentials are hard-coded here, and the experimenter credentials can be found or updated in your .env file under KINTO_USER and KINTO_PASS.
Any change in remote settings requires two accounts:
One to make changes and request a review
One to review and approve/reject those changes
Any of the accounts above can be used for any of those two roles, but your local Experimenter will be configured to make its changes through the experimenter account, so that account can't also be used to approve/reject those changes, hence the existence of the review account.
For more detailed information on the Remote Settings integration please see the Kinto module documentation.
Frontend
Experimenter has two front-end UIs:
core is the legacy UI used for Experimenter intake which will remain until nimbus-ui supersedes it
nimbus-ui is the Nimbus Console UI for Experimenter that is actively being developed
Learn more about the organization of these UIs here.
Also see the nimbus-ui README for relevent Nimbus documentation.