From e25fb59cbd21fe0deb9df0f2d029fc04d437636b Mon Sep 17 00:00:00 2001 From: Luca Abbati Date: Thu, 18 Oct 2018 11:44:11 +0200 Subject: [PATCH 1/3] [tests] Provide a CLI preconfogure docker command to run tests --- README.md | 17 ++++++++++++++++- scripts/ddtest | 22 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100755 scripts/ddtest diff --git a/README.md b/README.md index 09cc0929ce5..08a0be221f2 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ launch them through: [docker-compose]: https://www.docker.com/products/docker-compose -#### Running the Tests +#### Running the Tests in your local environment Once docker is up and running you should be able to run the tests. To launch a single test manually. For example to run the tests for `redis-py` 2.10 on Python @@ -61,6 +61,21 @@ To launch the complete test matrix run: $ tox +#### Running Tests in docker + +If you are on a unix machine and prefer not to setup your local machine to run tests, we provide a docker image +preconfigured to run tests. Note that this image is the same used in CircleCI to run tests. + +You still need dockers container running additional services up and running. For example to run the tests +for `redis-py` 2.10 on Python 3.5 and 3.6: + + $ ./scripts/ddtest tox -e '{py35,py36}-redis{210}' + +You can also add the `scripts` folder to your path, so can then run + + $ ddtest tox -e '{py35,py36}-redis{210}' + + ### Continuous Integration We use CircleCI 2.0 for our continuous integration. diff --git a/scripts/ddtest b/scripts/ddtest new file mode 100755 index 00000000000..72396240c72 --- /dev/null +++ b/scripts/ddtest @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -e + +DD_ROOT_TRACE_PY=${DD_ROOT_TRACE_PY:-"$(pwd)"} + +# A note about the mounted volumes: +# - dd-trace-py/(ddtrace|tests|setup.cfg|setup.py|tox.ini): are obviously required to run tests +# - dd-trace-py/.ddtox: we use it as a cache between different runs for tox envs si that tox do not recreate envs + +docker run -t -i --net=host \ + --name ddtrace_py_test_runner \ + --rm \ + -v $DD_ROOT_TRACE_PY/ddtrace/:/src/ddtrace:ro \ + -v $DD_ROOT_TRACE_PY/tests/:/src/tests:ro \ + -v $DD_ROOT_TRACE_PY/setup.cfg/:/src/setup.cfg:ro \ + -v $DD_ROOT_TRACE_PY/setup.py/:/src/setup.py:ro \ + -v $DD_ROOT_TRACE_PY/tox.ini/:/src/tox.ini:ro \ + -v $DD_ROOT_TRACE_PY/.ddtox:/src/.tox \ + -e TOX_SKIP_DIST=${TOX_SKIP_DIST:-True} \ + -w /src \ + datadog/docker-library:ddtrace_py $* From c5f8884a59ea18d900adabe56852b5ebd515bf16 Mon Sep 17 00:00:00 2001 From: Luca Abbati Date: Thu, 18 Oct 2018 12:07:44 +0200 Subject: [PATCH 2/3] [tests] Base the test runner on a docker compose service --- README.md | 20 ++++++++++++++++---- docker-compose.yml | 15 +++++++++++++++ scripts/ddtest | 19 +------------------ 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 08a0be221f2..b1436004ee4 100644 --- a/README.md +++ b/README.md @@ -63,15 +63,27 @@ To launch the complete test matrix run: #### Running Tests in docker -If you are on a unix machine and prefer not to setup your local machine to run tests, we provide a docker image +If you prefer not to setup your local machine to run tests, we provide a docker image preconfigured to run tests. Note that this image is the same used in CircleCI to run tests. -You still need dockers container running additional services up and running. For example to run the tests -for `redis-py` 2.10 on Python 3.5 and 3.6: +You still need dockers container running additional services up and running. + +Run the test runner + + $ docker-compose run --rm testrunner + +Now you are in a bash shell. You can now run tests as you would do in your local environment: + + $ tox -e '{py35,py36}-redis{210}' + +If you are in a unix machine, we also provide a shell script to execute commands in the provided container (so you don't +forget to remove-`--rm` the container after you run it). + +For example to run the tests for `redis-py` 2.10 on Python 3.5 and 3.6: $ ./scripts/ddtest tox -e '{py35,py36}-redis{210}' -You can also add the `scripts` folder to your path, so can then run +You can also add the `scripts` folder to your path, so then you can run $ ddtest tox -e '{py35,py36}-redis{210}' diff --git a/docker-compose.yml b/docker-compose.yml index 6f1d9f2156b..45be06fdaee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -78,3 +78,18 @@ services: - VP_TEST_DATABASE=docker ports: - "127.0.0.1:5433:5433" + + testrunner: + image: datadog/docker-library:ddtrace_py + environment: + - TOX_SKIP_DIST=True + network_mode: host + working_dir: /src + volumes: + - ./ddtrace:/src/ddtrace:ro + - ./tests:/src/tests:ro + - ./setup.cfg:/src/setup.cfg:ro + - ./setup.py:/src/setup.py:ro + - ./tox.ini:/src/tox.ini:ro + - ./.ddtox:/src/.tox + command: bash diff --git a/scripts/ddtest b/scripts/ddtest index 72396240c72..3126984a8ad 100755 --- a/scripts/ddtest +++ b/scripts/ddtest @@ -2,21 +2,4 @@ set -e -DD_ROOT_TRACE_PY=${DD_ROOT_TRACE_PY:-"$(pwd)"} - -# A note about the mounted volumes: -# - dd-trace-py/(ddtrace|tests|setup.cfg|setup.py|tox.ini): are obviously required to run tests -# - dd-trace-py/.ddtox: we use it as a cache between different runs for tox envs si that tox do not recreate envs - -docker run -t -i --net=host \ - --name ddtrace_py_test_runner \ - --rm \ - -v $DD_ROOT_TRACE_PY/ddtrace/:/src/ddtrace:ro \ - -v $DD_ROOT_TRACE_PY/tests/:/src/tests:ro \ - -v $DD_ROOT_TRACE_PY/setup.cfg/:/src/setup.cfg:ro \ - -v $DD_ROOT_TRACE_PY/setup.py/:/src/setup.py:ro \ - -v $DD_ROOT_TRACE_PY/tox.ini/:/src/tox.ini:ro \ - -v $DD_ROOT_TRACE_PY/.ddtox:/src/.tox \ - -e TOX_SKIP_DIST=${TOX_SKIP_DIST:-True} \ - -w /src \ - datadog/docker-library:ddtrace_py $* +docker-compose run --rm testrunner $* From 6bb8224eb7d8fff26a2c9b1e3782b7d4c1f25581 Mon Sep 17 00:00:00 2001 From: Luca Abbati Date: Thu, 18 Oct 2018 12:11:04 +0200 Subject: [PATCH 3/3] [tests] Fixed typo in read me --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b1436004ee4..a2b451b5731 100644 --- a/README.md +++ b/README.md @@ -63,10 +63,10 @@ To launch the complete test matrix run: #### Running Tests in docker -If you prefer not to setup your local machine to run tests, we provide a docker image -preconfigured to run tests. Note that this image is the same used in CircleCI to run tests. +If you prefer not to setup your local machine to run tests, we provide a preconfigured docker image. +Note that this image is the same used in CircleCI to run tests. -You still need dockers container running additional services up and running. +You still need docker containers running additional services up and running. Run the test runner