How to use contrail test ci container
Before using the container, one must install docker on the host. Please refer the docker installation document for docker install instructions (https://docs.docker.com/engine/installation/).
This is a helper script to manage (run/rebuild/list) contrail-test-ci container.
- Get testrunner.sh from github
$ wget https://raw.githubusercontent.com/Juniper/contrail-test-ci/master/testrunner.sh
$ chmod +x ./testrunner.sh
$ ./testrunner.sh -h
Usage: ./testrunner.sh <Subcommand> [OPTIONS|-h]
Run Contrail test suite in docker container
Subcommands:
run Run contrail-test container
rebuild Rebuild the container provided
list List contrail-test containers
load Load the container image from the filepath provided (tar, tar.gz, tar.bz2)
Run ./testrunner.sh <Subcommand> -h|--help to get subcommand specific help
- Load container images
# ./testrunner.sh load -h
Usage: ./testrunner.sh load DOCKER-IMAGE-URL
Load the docker image to local system
Possitional Parameters:
<docker-image-url> Docker image tar.gz url. Supports three modes:
http[s] url: example, http://myrepo/contrail-test-images/docker-image-contrail-test-ci-kilo-3.0-2709.tar.gz
file path: example /root/docker-image-contrail-test-ci-kilo-3.0-2709.tar.gz
Load docker image from http url
# ./testrunner.sh load http://nodei16/docker-image-contrail-test-juno-3.0-2709.tar.gz
--2016-02-26 16:18:26-- http://nodei16/docker-image-contrail-test-juno-3.0-2709.tar.gz
Resolving nodei16 (nodei16)... 127.0.0.1, 10.204.217.128
Connecting to nodei16 (nodei16)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 425768269 (406M) [application/x-gzip]
Saving to: ‘/tmp/tmp.x7SNNIHMdL/docker-image.tar.gz’
100%[================================================================================================================================================================>] 425,768,269 448MB/s in 0.9s
2016-02-26 16:18:27 (448 MB/s) - ‘/tmp/tmp.x7SNNIHMdL/docker-image.tar.gz’ saved [425768269/425768269]
Loading the image
Successfully Loaded the image http://nodei16/docker-image-contrail-test-juno-3.0-2709.tar.gz
- Run contrail-test-ci using testrunner
This will help running the contrail-test containers without learning docker commands. Also this script will help to save the data out of the contrail-test into the host. It saves logs, reports, testbed.py, and contrail-test code itself out of contrail-test container to said directory (provided using --run-path).
# ./testrunner.sh run -h
Usage: ./testrunner.sh run [OPTIONS] (<image_tag>)
Run Contrail test suite in docker container
-p, --run-path RUNPATH Directory path on the host, in which contrail-test save all the
results and other data. Default: /root/contrail-test-runs/
-s, --shell Do not run tests, but leave a shell, this is useful for debugging.
-r, --rm Remove the container on container exit, Default: Container will be kept.
-b, --background run the container in background
-n, --no-color Disable output coloring
-t, --testbed TESTBED Path to testbed file in the host,
Default: /opt/contrail/utils/fabfile/testbeds/testbed.py
-T, --testbed-json TESTBED_JSON Optional testbed json file.
-P, --params-file PARAMS_FILE Optional Sanity Params ini file
-f, --feature FEATURE Features or Tags to test - valid options are sanity, quick_sanity,
ci_sanity, ci_sanity_WIP, ci_svc_sanity, upgrade, webui_sanity,
ci_webui_sanity, devstack_sanity, k8s_sanity, openshift, upgrade_only.
Default: sanity
NOTE: this is only valid for Full contrail-test suite.
NOTE: Either testbed.py (-t) or both testbed-json and params-file required
Possitional Parameters:
<image_tag> Docker image tag to run (Run "./testrunner.sh list -i" to list all images available)
$ ./testrunner.sh list -i
=========== Images =============
IMAGE IMAGE ID VIRTUAL SIZE
contrail-test-ci-juno:2.21-105 36e5be3a22e9 960.9 MB
contrail-test-juno:3.0-2709 ea98ac942d3d 1.019 GB
# ./testrunner.sh run contrail-test-ci-juno:2.21-105
[localhost] local: git branch
* master
2016-02-26 10:36:34:823464: [localhost] local: git log --format="%H" -n 1
2016-02-26 10:36:34:828473: [localhost] local: git branch
fatal: Not a git repository (or any of the parent directories): .git
2016-02-26 10:36:34:836881: Warning: local() encountered an error (return code 128) while executing 'git branch'
2016-02-26 10:36:34:836881:
2016-02-26 10:36:34:836881: 2016-02-26 10:36:34:833129: [root@10.204.217.88] run: cat /opt/contrail/contrail_packages/VERSION
2016-02-26 10:36:34:837161: [root@10.204.217.88] out: BUILDID=105
2016-02-26 10:36:35:592165: [root@10.204.217.88] out:
2016-02-26 10:36:35:592643:
2016-02-26 10:36:35:596869: [root@10.204.217.88] run: hostname
2016-02-26 10:36:35:597206: [root@10.204.217.88] out: harishku-vm1
2016-02-26 10:36:35:647340: [root@10.204.217.88] out:
2016-02-26 10:36:35:647664:
2016-02-26 10:36:35:647846: [root@10.204.217.88] run: hostname
2016-02-26 10:36:35:648023: [root@10.204.217.88] out: harishku-vm1
2016-02-26 10:36:35:730206: [root@10.204.217.88] out:
2016-02-26 10:36:35:730429:
2016-02-26 10:36:35:735219: [root@10.204.217.88] run: hostname
2016-02-26 10:36:35:735409: [root@10.204.217.88] out: harishku-vm1
2016-02-26 10:36:35:824025: [root@10.204.217.88] out:
2016-02-26 10:36:35:824271:
2016-02-26 10:36:35:828898: [root@10.204.217.90] run: hostname
2016-02-26 10:36:35:829093: [root@10.204.217.90] out: harishku-vm3
2016-02-26 10:36:36:347448: [root@10.204.217.90] out:
2016-02-26 10:36:36:347687:
2016-02-26 10:36:36:352560: [root@10.204.217.88] run: hostname
2016-02-26 10:36:36:352826: [root@10.204.217.88] out: harishku-vm1
2016-02-26 10:36:36:374782: [root@10.204.217.88] out:
The above testrun may create below directory structure under run_path directory in the host
# ls ~/contrail-test-runs/
2016_02_25_11_29_59 2016_02_25_11_31_44 2016_02_25_11_33_31 2016_02_25_11_33_40 2016_02_25_12_02_15 2016_02_25_13_06_20 2016_02_26_16_06_33 2016_02_26_16_10_07 2016_02_26_16_17_43
# ls ~/contrail-test-runs/2016_02_25_12_02_15
contrail-test logs reports testbed.py
- Run contrail-test-ci container with a shell instead of running contrail-test. This would be helpful to login to the container and do some debugging
# ./testrunner.sh run -s contrail-test-ci-juno:2.21-105
root@80132b7c05a0:/#
- Run with testbed.py in non-standard location (by default it takes from /opt/contrail/utils/fabfile/testbeds/testbed.py)
# ./testrunner.sh run -t /tmp/testbed.py contrail-test-ci-juno:2.21-105
- List running contrail-test-ci containers
# ./testrunner.sh list
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9664fea32bd3 contrail-test-ci-juno:2.21-105 "/entrypoint.sh" 7 minutes ago Up 7 minutes contrail_test_egueqpcv
- List all contrail-test-ci containers (including all running as well as finished containers)
# ./testrunner.sh list -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
80132b7c05a0 contrail-test-ci-juno:2.21-105 "/bin/bash" 5 minutes ago Exited (0) 3 minutes ago contrail_test_kkqrdrcn
9664fea32bd3 contrail-test-ci-juno:2.21-105 "/entrypoint.sh" 8 minutes ago Up 8 minutes contrail_test_egueqpcv
- Rebuild existing container (running or non-running container)
# ./testrunner.sh rebuild -h
Usage: ./testrunner.sh rebuild [OPTIONS] <container id/name>
Rebuild contrail-test containers
-p, --run-path RUNPATH Directory path on the host, in which contrail-test save all the
results and other data. Default: /root/contrail-test-runs/
-s, --shell Do not run tests, but leave a shell, this is useful for debugging.
-r, --rm Remove the container on container exit, Default: Container will be kept.
-b, --background run the container in background
-n, --no-color Disable output coloring
-t, --testbed TESTBED Path to testbed file in the host,
Default: /opt/contrail/utils/fabfile/testbeds/testbed.py
-T, --testbed-json TESTBED_JSON Optional testbed json file.
-P, --params-file PARAMS_FILE Optional Sanity Params ini file
-f, --feature FEATURE Features or Tags to test - valid options are sanity, quick_sanity,
ci_sanity, ci_sanity_WIP, ci_svc_sanity, upgrade, webui_sanity,
ci_webui_sanity, devstack_sanity, upgrade_only. Default: sanity
NOTE: this is only valid for Full contrail-test suite.
NOTE: Either testbed.py (-t) or both testbed-json and params-file required
Possitional Parameters:
<container id/name> The container ID or name ( "./testrunner.sh list -ca" to list all containers)
Below code will rebuild an exited container
# ./testrunner.sh rebuild contrail_test_ci_eqsjwxar
rebuilding container - contrail_test_ci_eqsjwxar
This process will create an image with the container contrail_test_ci_eqsjwxar
Creating the image img_contrail_test_ci_eqsjwxar
b9fc87f3dc4b7da716f98ed83ba456ba1b3990df737e55f6cbcabeac8d13e578
no match
Applied patch
patching file __init__.py
+ echo 'Validating if test discovery passes in scripts/ and serial_scripts'
Validating if test discovery passes in scripts/ and serial_scripts
+ echo ''
+ GIVEN_TEST_PATH=
+ export PYTHONPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/contrail-test/scripts:/contrail-test/fixtures
+ PYTHONPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/contrail-test/scripts:/contrail-test/fixtures
+ export OS_TEST_PATH=./scripts
+ OS_TEST_PATH=./scripts
+ testr list-tests
running=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-6000} \
.............
.............
- Load docker image from /export/docker/contrail-test-ci/contrail-test-ci-juno-2.21-105.tar.gz
$ docker load < /export/docker/contrail-test-ci/contrail-test-ci-juno-2.21-105.tar.gz
-
Execute docker container
it run contrail-test ci tests and log the console. The console output may be captured at later point by running "docker logs [-f] ".
$ docker run -v /opt/contrail/utils/fabfile/testbeds/testbed.py:/opt/contrail/utils/fabfile/testbeds/testbed.py \
-t contrail-test-ci-juno:2.21-105
-
Execute the container with logs saved in specific location
The logs will be saved under /export/logs/contrail-test-ci/ on docker host.
$ docker run -v /opt/contrail/utils/fabfile/testbeds/testbed.py:/opt/contrail/utils/fabfile/testbeds/testbed.py \
-v /export/logs/contrail-test-ci/:/contrail-test/logs -t contrail-test-ci-juno:2.21-105
testbed.py need following configuration in order to email the test report.
env.test = {
'mail_to': 'user1@abc.com, user2@gmail.com',
'mail_server': '10.0.0.49',
'mail_sender': 'contrail-test@abc.com'
}
This script can be used to cleanup tenant data. This can be run after testrun to make sure tenant is clean.
$ ./tenant_cleaner.py -h
usage: tenant_cleaner.py [-h] [--user USER] [--password PASSWORD]
[--auth-url AUTH_URL] [--auth-tenant AUTH_TENANT]
[--ip IP] [--port PORT]
tenant [tenant ...]
Cleanup provided tenants by removing all objects in it.It expect openstack
credentials from OS_ environment variables in openrc format.The credentials
can be provided as commandline arguments also
positional arguments:
tenant List of tenants to be cleaned up Note that, the user
must have access to the tenants listed
optional arguments:
-h, --help show this help message and exit
--user USER Openstack user, if not provided, try to get it from
environment variable "OS_USERNAME" with default user
as "admin"
--password PASSWORD Openstack password
--auth-url AUTH_URL Openstack auth url, by default try to get from
environment variableOS_AUTH_URL with default of
http://127.0.0.1:5000/v2.0/
--auth-tenant AUTH_TENANT
Openstack tenant to connect to
--ip IP IP Address of the controller
--port PORT Port of the controller
$ ./tenant_cleaner.py --ip 10.204.217.88 tenant1 tenant2 tenant3
No objects found in tenant tenant1
No objects found in tenant tenant2
Deleted: http://10.204.217.88:8082/security-group/f633163c-2c96-4722-94b2-3a125e981492
No nova objects found in tenant tenant3