Files
docker-stacks/docs/contributing/tests.md
Kevin Bates 10e52ee843 Create base image to base-notebook for non-server Jupyter applications (#1825)
* Create base-jupyter from base-notebook for non-server jupyter applications

* Fix pre-commit errors and begin test refactoring

* More test refactoring

* Add base-jupyter to images_hierarchy

* Use folder work instead of .jupyter in nb-user test

* Add base-jupyter to tagging hierarchy

* Linting: trailing comma

* Apply review comments, remove obsolute Miniforge reference

* Add self-signed cert comment back to base-notebook doc

* Update docs/using/selecting.md

Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>

* Remove redundant apt-get upgrade per review

* Remove b/c approaches per review

* Move test_nb_user_change back to base-notebook tests, per review

* fix linting

* Rename base-jupyter to docker-stacks-foundation, per review

* Rename tests/base-jupyter to docker-stacks-foundation

* Use alphabetical order

* Use alphabetical order

* Fix markdown style

* Split test_nb_user_change between the foundation and base tests

Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
2022-11-13 01:44:44 +04:00

2.3 KiB

Image Tests

We greatly appreciate pull requests that extend the automated tests that vet the basic functionality of the Docker images.

How the Tests Work

A GitHub Action workflow runs tests against pull requests submitted to the jupyter/docker-stacks repository.

We use pytest module to run tests on the image. conftest.py and pytest.ini in the tests folder define the environment in which tests are run. More info on pytest can be found here.

The actual image-specific test files are located in folders like tests/<somestack>/ (e.g., tests/docker-stacks-foundation/, tests/minimal-notebook/, etc.).

If your test is located in `tests/<somestack>/`, it will be run against `jupyter/<somestack>` image and against all the [images inherited from this image](https://jupyter-docker-stacks.readthedocs.io/en/latest/using/selecting.html#image-relationships.

Many tests make use of global pytest fixtures defined in the conftest.py file.

Unit tests

If you want to run a python script in one of our images, you could add a unit test. You can do this by creating a tests/<somestack>/units/ directory, if it doesn't already exist and put your file there. Files in this folder will be executed in the container when tests are run. You could see an example for the TensorFlow package here.

Contributing New Tests

Please follow the process below to add new tests:

  1. Add your test code to one of the modules in tests/<somestack>/ directory or create a new module.

  2. Build one or more images you intend to test and run the tests locally. If you use make, call:

    make build/<somestack>
    make test/<somestack>
    
  3. Submit a pull request (PR) with your changes.

  4. Watch for GitHub to report a build success or failure for your PR on GitHub.

  5. Discuss changes with the maintainers and address any issues running the tests on GitHub.