Code Monkey home page Code Monkey logo

m8a-tests's Introduction

Container testing

Adding new containers and their tests

  1. Find container "type" or "language"
  2. Add it into tox.ini in envlist, if not present.
  3. Create or update a file named test_<container_type>.py (for example, test_python.py)
  4. Add your tests there based on testinfra
  5. Ensure the container data is up to date by updating matryoshka_tester/data.py.

Extending coverage/Writing tests for existing containers

Just use testinfra documentation (linked above). It should be easy.

You can use the convenience tools from conftest:

  • If you are using the "container" fixture, your test will auto generate the right tests for all the versions of your language. This is auto loaded, and doesn't need anything from your side except using the keyword "container". See below for more details.
  • If you want to skip some of those tests, use the decorator named restrict_to_version, which accepts a list of strings of the versions for which to run the test. See below for more details.

The container fixture

The container fixture contains the black magic to run commands for all versions of a language container. If you need to run a test only for certain versions of a language stack, you have the following three options (by order of preference):

  1. Use the restrict_to_version decorator to limit which containers your test applies to.
  2. Create your own fixture
  3. Modify the container fixture. The container fixture automatically finds the testfile filename, uses it to infer the language of the container under test, and starts all the necessary containers. See also conftest.py.

The restrict_to_version decorator

This decorator accepts a list of strings matching the versions from data.py.

To use it:

  1. add from conftest import restrict_to_version to your imports.
  2. wrap your test function as follow (assuming openjdk here):
@restrict_to_version(['11'])
def mytest(container):
    pass
  • If you want to restrict certain tests from running in parallel, add the serial mark to the respective function:
@pytest.mark.serial
def test_my_heavy_installation(container):
    ...

In the example above, the test function mytest will only run for the openjdk:11 container, instead of all the containers for openjdk.

Running all tests

$ tox --parallel

Running specific tests

$ tox -e testname

testname equals to python for the test file named test_python.py

This will run all the tests for a language, which could mean multiple stacks.

m8a-tests's People

Contributors

evrardjp avatar dcermak avatar mvarlese avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.