Containers
The containers related commands handle the majority of the work that teststack does.
The work is abstracted into the different container drivers. You can specify
which container driver to use in the teststack.toml file.
[client]
name = "docker"
All of the commands can be combined together and they will be executed in order. So if for example you want to rebuild the image without any cache and then run the tests you could do the following.
teststack build --rebuild run
- teststack.commands.containers.start(ctx, no_tests)
Start services and tests containers.
If the flag
--no-testsis passed, then the tests container is not started, and only the services are started. This is useful if running tests outside of a docker container.- --no-tests, -n
do not build an image or start a tests container
- --no-mount, -m
do not mount the current directory as a volume
teststack start --no-tests
- teststack.commands.containers.stop(ctx)
Stop all containers
- --prefix, -p
prefix for container names for imports
teststack stop
- teststack.commands.containers.restart(ctx)
Stop then Start all containers
teststack restart
- teststack.commands.containers.render(ctx, template_file, dockerfile)
Render the template_file to the dockerfile.
- --template-file, -t
template file to render, default: Dockerfile.j2
- --dockerfile, --file, -f
file to write the rendered dockerfile to. default: Dockerfile
teststack render teststack render --template-file Containerfile.j2 --file Containerfile
- teststack.commands.containers.build(ctx, rebuild, tag, dockerfile)
Build the docker image using the dockerfile.
If the dockerfile does not exist, then it will be rendered.
- --template-file
Template to render to the Dockerfile
- --dockerfile, --file, -f
dockerfile to build into an image. Default: Dockerfile
- --directory, -d
directory to build inside. Default: .
- --rebuild, -r
Ignore the cache and rebuild from scratch
- --tag, -t
Tag to use for the image. Default: <dirname>:<latest git hash/”latest”>
- --service
Service specified with a
buildargument to build the image for.- --stage
Stage to build in the Dockerfile, if specified. Default: None
teststack build teststack build --tag blah:old
- teststack.commands.containers.exec(ctx)
Exec into the current tests container.
teststack exec
- teststack.commands.containers.run(ctx, step, posargs)
Run the specified test steps from the teststack.toml.
- --copy, -c
Copy files from [tests.copy] out of the container after the steps have been run
- --step, -s
specify a single step to run.
posargs
All other leftover unprocessed arguments are passed as {posargs} to be rendered when the commands.
teststack run teststack run --step tests -- -k test_add_user tests/unit/test_users.py
- teststack.commands.containers.import_(ctx, repo, ref, stop)
Load up another repo or directory as a dependency service
- --repo, -r
Repository or path to directory for application. Urls have to be cloneable with git. But paths can be whatever as long as they are on the filesystem.
- --ref, --tag, -t
Git reference to checked out after cloning. Only used if a remote repository is specified
- --stop
stop the containers in the imported environment instead
teststack import --repo ./path teststack import --repo ssh://github.com/org/repo.git