Skip to main content

Uses docker to spawn containers for services required during tests

Project description

Uses docker to spawn containers for services required during tests

[![Build Status](https://travis-ci.org/dmonroy/docker-services.svg?branch=master)](https://travis-ci.org/dmonroy/docker-services)

# Install

This project is available on pypi, so you can use _pip_ to install it:

```
pip install docker-services
```

Or include it as a dependency on `setup.py` or a `requirements.txt` file, whatever you prefer.


# Use it

## 1. Configure your project services

You need to start listing all services that your project depends on and leverage on _docker-services_ to maintain the lifecycle of those services during test runs.

This must happen using the `docker_services` config option on any pytest _.cfg_ or _.ini_ file, the value for that option must be one or multiple services, one per line.

This is a basic example for a project that depends on a `postgres` service:

```
[pytest]
docker_services=postgres
```

Also this is the same:

```
[pytest]
docker_services=
postgres
```

If the projects depends different services, list all one by one:

```
[pytest]
docker_services=
postgres
redis
```

When image name is not specified then it falls back to use the service name as image name, but it is possible to specify the image name and version to use:

```
[pytest]
docker_services=
postgres:9.10
```

This way service name is `postgres` and image name is `postgres:10`.

Another option is to use a different name for the service, something like:


```
[pytest]
docker_services=
db=postgres:10
```

Now service name is `db` and image name id `postgres:10`.

If you don't want (or need) to set a specific image name, just ignore the version part like this:

```
[pytest]
docker_services=
db=postgres
```

Also you are able to use images from a private registry:

```
[pytest]
docker_services=
db: my.registry.com/custom/postgres
```

## 2. Run tests with docker-services enabled

_docker-services_ adds the `--use-docker-services` command line option for _py.test_, when setting this option it enables service's spawning using docker, run it like this:

```
py.test --use-docker-services
```



Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docker-services-0.0.0.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file docker-services-0.0.0.tar.gz.

File metadata

File hashes

Hashes for docker-services-0.0.0.tar.gz
Algorithm Hash digest
SHA256 e556dfc7f274924e61cf2c2e98ce25acf22e2de1d1dc4eaa2a5892b916af5c39
MD5 c0f6c36968b3abeb6480eb0718778aa4
BLAKE2b-256 66ad5b99113d4956431298f2093eca02aa92537b7fe8fa312040643981597689

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page