Skip to content
Harish Kumar edited this page Feb 26, 2016 · 18 revisions

contrail ci tests

This repo contain contrail ci tests and other common tools and libraries to run contrail-test.

Table of contents

Install and use contrail-test or contrail-test-ci

A script provided (install.sh) to install both contrail-test-ci as well as contrail-test.

    $ ./install.sh -h

    Install or do docker build of Contrail-test and contrail-test-ci

    Usage: ./install.sh (install|docker-build) [OPTIONS] (contrail-test|contrail-test-ci)

    Subcommands:

    install         Install contrail-test/contrail-test-ci
    docker-build    Build docker container

    Run ./install.sh <Subcommand> -h|--help to get subcommand specific help

    $ ./install.sh install -h

    Install Contrail-test or contrail-test-ci

    Usage: ./install.sh install [OPTIONS] (contrail-test|contrail-test-ci)

      -h|--help                     Print help message
      --test-repo REPO              Contrail-test git repo, Default: github.com/juniper/contrail-test-ci.git
      --test-ref REF                Contrail-test git reference - commit id, branch, tag, Default: master
      --fab-repo FAB_REPO           Contrail-fabric-utils git repo
      --fab-ref FAB_REF             Contrail-fabric-utils git reference (commit id, branch, or tag), Default: master
      --ci-repo CI_REPO	            Contrail-test-ci git repo, Default: github.com/juniper/contrail-test.git
      --ci-ref CI_REF               Contrail-test-ci reference (commit id, branch, or tag), Default: master
      --test-artifact ARTIFACT      Contrail test tar file - this tar file will be used instead of git source in case provided
      --ci-artifact CI_ARTICACT     Contrail test ci tar file
      --fab-artifact FAB_ARTIFACT   Contrail-fabric-utils tar file
      -u|--package-url PACKAGE_URL  Contrail-install-packages deb package web url (http:// or https://) or scp path
                                    (ssh://<server ip/name/< package path>), if url is provided, the
                                    package will be installed and setup local repo.
                                    In case of scp, user name and password will be read from environment variables
                                    SSHUSER - user name to be used during scp
                                    SSHPASS - user password to be used during scp
      positional arguments
        What to install             Valid options are contrail-test, contrail-test-ci

     Example:

        ./install.sh install --test-repo https://github.com/hkumarmk/contrail-test --test-ref working
        --ci-repo https://$GITUSER:$GITPASS@github.com/juniper/contrail-test-ci -e /tmp/export2
        -u http://nodei16/contrail-install-packages_2.21-105~juno_all.deb contrail-test

        $ export SSHUSER=user1 SSHPASS=password
        $ ./install.sh install --test-repo https://github.com/hkumarmk/contrail-test --test-ref working
            --ci-repo https://$GITUSER:$GITPASS@github.com/juniper/contrail-test-ci -e /tmp/export2
            -u ssh://nodei16/var/cache/artifacts/contrail-install-packages_2.21-105~juno_all.deb contrail-test-ci

    - Install with artifacts

      ./install.sh install --ci-artifact /tmp/contrail-test-ci.tar.gz \
            -u http://nodei16/contrail-install-packages_2.21-105~juno_all.deb \
            --fab-artifact /tmp/contrail-fabric-utils.tar.gz contrail-test-ci # Just use contrail-test as last argument to install contrail-test

    - combination of artifacts and git refs

      ./install.sh install --test-ref 1890b36 --ci-artifact /tmp/contrail-test-ci.tar.gz \
            -u http://nodei16/contrail-install-packages_2.21-105~juno_all.deb \
            --fab-artifact /tmp/contrail-fabric-utils.tar.gz contrail-test

Once it is installed, one should copy testbed.py to /opt/contrail/utils/fabfile/testbeds (or any custom fab path in which case, one have to provide --contrail-fab-path while running run_tests.sh). Now just go to /opt/contrail-test and run run_tests.sh as they have done before.

NOTE: No need to run any fab tasks like setup_testenv or anything. Running run_tests.sh will read testbed.py and build required files to run the tests (like sanity_params.ini, sanity_testbed.json).

Here is how I run contrail-test after Install it.

  1. Copy testbed.py to /opt/contrail/utils/fabfile/testbeds/
  2. cd /opt/contrail-test
  3. run ./run_tests.sh with appropriate parameters
    $ cd /opt/contrail-test
    $ ./run_tests.sh -h
    Usage: ./run_tests.sh [OPTION]...
    Run Contrail test suite

      -V, --virtual-env        Always use virtualenv.  Install automatically if not present
      -N, --no-virtual-env     Don't use virtualenv.  Run tests in local environment
      -n, --no-site-packages   Isolate the virtualenv from the global Python environment
      -f, --force              Force a clean re-build of the virtual environment. Useful when dependencies have been added.
      -u, --update             Update the virtual environment with any newer package versions
      -U, --upload             Upload test logs
      -s, --sanity             Only run sanity tests
      -t, --parallel           Run testr in parallel
      -C, --config             Config file location
      -h, --help               Print this usage message
      -d, --debug              Run tests with testtools instead of testr. This allows you to use PDB
      -l, --logging            Enable logging
      -L, --logging-config     Logging config file location.  Default is logging.conf
      -m, --send-mail          Send the report at the end
      -F, --features           Only run tests from features listed
      -T, --tags               Only run tests taged with tags
      -c, --concurrency        Number of threads to be spawned
      --contrail-fab-path      Contrail fab path, default to /opt/contrail/utils
      -- [TESTROPTIONS]        After the first '--' you can pass arbitrary arguments to testr

    $ ./run_tests.sh
    [localhost] local: git branch
    fatal: Not a git repository (or any of the parent directories): .git

    2016-02-09 10:25:35:568148: Warning: local() encountered an error (return code 128) while executing 'git branch'
    2016-02-09 10:25:35:568148:
    2016-02-09 10:25:35:568148: 2016-02-09 10:25:35:561571: [root@10.204.217.88] run: cat /opt/contrail/contrail_packages/VERSION
    2016-02-09 10:25:35:568437: [root@10.204.217.88] out: BUILDID=2709
    2016-02-09 10:25:36:714451: [root@10.204.217.88] out:
    2016-02-09 10:25:36:714859:
    2016-02-09 10:25:36:719259: [localhost] local: git branch
    fatal: Not a git repository (or any of the parent directories): .git

    2016-02-09 10:25:36:726339: Warning: local() encountered an error (return code 128) while executing 'git branch'
    2016-02-09 10:25:36:726339:
    2016-02-09 10:25:36:726339: 2016-02-09 10:25:36:719675: [root@10.204.217.88] run: cat /opt/contrail/contrail_packages/VERSION
    2016-02-09 10:25:36:726615: [root@10.204.217.88] out: BUILDID=2709
    2016-02-09 10:25:36:777523: [root@10.204.217.88] out:
    2016-02-09 10:25:36:777781:
    2016-02-09 10:25:36:778033: [root@10.204.217.88] run: hostname
    2016-02-09 10:25:36:778463: [root@10.204.217.88] out: harishku-vm1
    2016-02-09 10:25:36:832563: [root@10.204.217.88] out:
    2016-02-09 10:25:36:832820:
    2016-02-09 10:25:36:833036: [root@10.204.217.88] run: hostname
    2016-02-09 10:25:36:833272: [root@10.204.217.88] out: harishku-vm1
    2016-02-09 10:25:36:884548: [root@10.204.217.88] out:
    2016-02-09 10:25:36:884789:
    2016-02-09 10:25:36:885041: [root@10.204.217.88] run: hostname
    2016-02-09 10:25:36:885263: [root@10.204.217.88] out: harishku-vm1
    2016-02-09 10:25:36:969527: [root@10.204.217.88] out:
    2016-02-09 10:25:36:969768:
    2016-02-09 10:25:36:974452: [root@10.204.217.90] run: hostname
    2016-02-09 10:25:36:974680: [root@10.204.217.90] out: harishku-vm3
    2016-02-09 10:25:37:708216: [root@10.204.217.90] out:
    2016-02-09 10:25:37:708449:
    2016-02-09 10:25:37:708709: [root@10.204.217.88] run: hostname
    2016-02-09 10:25:37:708983: [root@10.204.217.88] out: harishku-vm1
    2016-02-09 10:25:37:729606: [root@10.204.217.88] out:
    2016-02-09 10:25:37:729832:
    2016-02-09 10:25:37:730082: [root@10.204.217.89] run: hostname
    2016-02-09 10:25:37:730289: [root@10.204.217.89] out: localhost
    2016-02-09 10:25:38:520887: [root@10.204.217.89] out:
    2016-02-09 10:25:38:521179:
    2016-02-09 10:25:38:521440: [root@10.204.217.90] run: hostname
    2016-02-09 10:25:38:521712: [root@10.204.217.90] out: harishku-vm3
    2016-02-09 10:25:38:542269: [root@10.204.217.90] out:
    2016-02-09 10:25:38:542559:
    2016-02-09 10:25:38:542855: [root@10.204.217.88] run: hostname
    2016-02-09 10:25:38:543112: [root@10.204.217.88] out: harishku-vm1
    2016-02-09 10:25:38:589205: [root@10.204.217.88] out:
    2016-02-09 10:25:38:589499:
    2016-02-09 10:25:38:589721: [root@10.204.217.89] run: hostname
    2016-02-09 10:25:38:590029: [root@10.204.217.89] out: localhost
    2016-02-09 10:25:38:611151: [root@10.204.217.89] out:
    2016-02-09 10:25:38:611428:
    2016-02-09 10:25:38:616572: [root@10.204.217.90] run: hostname
    2016-02-09 10:25:38:616852: [root@10.204.217.90] out: harishku-vm3
    2016-02-09 10:25:38:639135: [root@10.204.217.90] out:
    2016-02-09 10:25:38:639500:
    2016-02-09 10:25:38:639774: [root@10.204.217.129] run: hostname
    2016-02-09 10:25:38:640058: [root@10.204.217.129] out: nodei17
    2016-02-09 10:25:38:965649: [root@10.204.217.129] out:
    2016-02-09 10:25:38:965880:
    2016-02-09 10:25:38:968799: Python 2.7.6
    no match
    Reversed (or previously applied) patch detected!  Skipping patch.
    1 out of 1 hunk ignored
    + 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:/usr/games:/usr/local/games:/opt/contrail-test/scripts:/opt/contrail-test/fixtures
    + PYTHONPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/contrail-test/scripts:/opt/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} \
    ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./scripts} --list
    scripts.analytics.test_analytics.AnalyticsTestSanity.test_bgprouter_uve_for_xmpp_and_bgp_peer_count
    scripts.analytics.test_analytics.AnalyticsTestSanity.test_colector_uve_module_sates
    scripts.analytics.test_analytics.AnalyticsTestSanity.test_config_node_uve_states
    scripts.analytics.test_analytics.AnalyticsTestSanity.test_contrail_alarms[sanity,vcenter]
    scripts.analytics.test_analytics.AnalyticsTestSanity.test_contrail_status[sanity,vcenter]
    scripts.analytics.test_analytics.AnalyticsTestSanity.test_message_table
    scripts.analytics.test_analytics.AnalyticsTestSanity.test_verify_hrefs
    scripts.analytics.test_analytics.AnalyticsTestSanity1.test_stats_tables
    scripts.analytics.test_analytics.AnalyticsTestSanity1.test_verify__bgp_router_uve_up_xmpp_and_bgp_count
    scripts.analytics.test_analytics.AnalyticsTestSanity1.test_verify_bgp_peer_uve
    scripts.analytics.test_analytics.AnalyticsTestSanity2.runTest
    scripts.analytics.test_analytics.AnalyticsTestSanity3.test_contrail_database_status[sanity,vcenter]
    scripts.analytics.test_analytics.AnalyticsTestSanity3.test_db_nodemgr_status[sanity,vcenter]
    scripts.analytics.test_analytics.AnalyticsTestSanity3.test_db_purge[sanity,vcenter]
    scripts.analytics.test_analytics.AnalyticsTestSanity3.test_verify_generator_collector_connections[sanity,vcenter]
    scripts.analytics.test_analytics.AnalyticsTestSanity3.test_verify_generator_connections_to_collector_node[sanity,vcenter]
    scripts.analytics.test_analytics.AnalyticsTestSanity3.test_verify_process_status_agent[sanity,vcenter]
    scripts.analytics.test_analytics.AnalyticsTestSanity3.test_verify_process_status_analytics_node[sanity,vcenter]
    scripts.analytics.test_analytics.AnalyticsTestSanity3.test_verify_process_status_config[sanity,vcenter]
    scripts.analytics.test_analytics.AnalyticsTestSanity3.test_verify_process_status_control_node[sanity,vcenter]
    scripts.analytics.test_analytics_basic.AnalyticsBasicTestSanity.test_verify_object_logs[ci_sanity,sanity,vcenter]
    scripts.ceilometer_tests.test_ceilometer.CeilometerTest.test_resources_by_admin_tenant
    scripts.ceilometer_tests.test_ceilometer.CeilometerTest.test_resources_by_user_tenant
    scripts.ceilometer_tests.test_ceilometer.CeilometerTest.test_sample_floating_ip_transmit_packets[sanity]
    scripts.discovery_regression.test_discovery.TestDiscovery.test_ApiServer_subscribed_to_collector_service
    scripts.discovery_regression.test_discovery.TestDiscovery.test_Schema_subscribed_to_collector_service
    scripts.discovery_regression.test_discovery.TestDiscovery.test_ServiceMonitor_subscribed_to_collector_service
    scripts.discovery_regression.test_discovery.TestDiscovery.test_agents_connected_to_collector_service[sanity,vcenter]
    scripts.discovery_regression.test_discovery.TestDiscovery.test_agents_connected_to_dns_service
    scripts.discovery_regression.test_discovery.TestDiscovery.test_cleanup
    scripts.discovery_regression.test_discovery.TestDiscovery.test_control_nodes_connected_to_collector_service

Docker build

There is a script (install.sh) which build docker containers for both contrail-test-ci as well as contrail-test.

    $ ./install.sh docker-build -h

    Build Contrail-test and contrail-test-ci docker container

    Usage: ./install.sh docker-build [OPTIONS] (contrail-test|contrail-test-ci)

      -h|--help                     Print help message
      --test-repo REPO                Contrail-test git repo, Default: github.com/juniper/contrail-test-ci.git
      --test-ref REF                  Contrail-test git reference - commit id, branch, tag, Default: master
      --fab-repo FAB_REPO           Contrail-fabric-utils git repo
      --fab-ref FAB_REF             Contrail-fabric-utils git reference (commit id, branch, or tag), Default: master
      --ci-repo CI_REPO	            Contrail-test-ci git repo, Default: github.com/juniper/contrail-test.git
      --ci-ref CI_REF               Contrail-test-ci reference (commit id, branch, or tag), Default: master
      --container-tag CONTAINER_TAG Docker container tag, default to contrail-test-ci-<openstack-release>:<contrail-version>
                                        openstack-release and contrail-version is extracted from contrail-install-package name
                                        e.g contrail-test-ci-juno:2.21-105
      --test-artifact ARTIFACT        Contrail test tar file - this tar file will be used instead of git source in case provided
      --ci-artifact CI_ARTICACT     Contrail test ci tar file
      --fab-artifact FAB_ARTIFACT   Contrail-fabric-utils tar file
      -u|--package-url PACKAGE_URL  Contrail-install-packages deb package web url (http:// or https://) or scp path
                                    (ssh://<server ip/name/< package path>), if url is provided, the
                                    package will be installed and setup local repo.
                                    In case of scp, user name and password will be read from environment variables
                                    SSHUSER - user name to be used during scp
                                    SSHPASS - user password to be used during scp
      -c|--use-cache                Use docker cache for the build
      -e|--export EXPORT_PATH       Export Container image to the path provided

      positional arguments
        Type of build               What to build, valid options are contrail-test, contrail-test-ci

     Example:

      $ ./install.sh docker-build --test-repo https://github.com/hkumarmk/contrail-test --test-ref working
            --ci-repo https://$GITUSER:$GITPASS@github.com/juniper/contrail-test-ci -e /tmp/export2
            -u http://nodei16/contrail-install-packages_2.21-105~juno_all.deb contrail-test

      $ export SSHUSER=user1 SSHPASS=password
      $ ./install.sh docker-build --test-repo https://github.com/hkumarmk/contrail-test --test-ref working
            --ci-repo https://$GITUSER:$GITPASS@github.com/juniper/contrail-test-ci -e /tmp/export2
            -u ssh://nodei16/var/cache/artifacts/contrail-install-packages_2.21-105~juno_all.deb contrail-test
  • Docker build with artifacts
 $ ./install.sh docker-build -c --ci-artifact /tmp/contrail-test-ci.tar.gz \
        -u http://nodei16/contrail-install-packages_2.21-105~juno_all.deb \
        --fab-artifact /tmp/contrail-fabric-utils.tar.gz contrail-test-ci
  • Docker build with combination of artifacts and git refs
  $ ./install.sh docker-build --test-ref 1890b36 --ci-artifact /tmp/contrail-test-ci.tar.gz \
        -u http://nodei16/contrail-install-packages_2.21-105~juno_all.deb \
        --fab-artifact /tmp/contrail-fabric-utils.tar.gz contrail-test-ci
  • Build and export to /export/docker/contrail-test-ci/
  ./install.sh docker-build --test-ref 1890b36 --ci-artifact /tmp/contrail-test-ci.tar.gz \
        -u http://nodei16/contrail-install-packages_2.21-105~juno_all.deb \
        --fab-artifact /tmp/contrail-fabric-utils.tar.gz contrail-test-ci -e /export/docker/contrail-test-ci/

Docker Container Execution

  • 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

Other Tools

testrunner.sh

This is a helper script to manage (run/rebuild/list) contrail-test/contrail-test-ci container.


$ ./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

  -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
  -p, --run-path RUNPATH           Directory path on the host, in which contrail-test save all the results and other data
  -s, --shell                      Do not run tests, but leave a shell, this is useful for debugging
  -r, --rm	                     Remove the container on container exit, by default the 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  Testbed json file
  -P, --params-file PARAMS_FILE    Sanity Params ini file

NOTE: Any one of testbd or both testbed-json and params-file required

Possitional Parameters:

  <image_tag>        Docker image tag to run


# ./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 or 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 or 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
7c30d25d1842        2783b6dd356e                     "/bin/bash"         27 hours ago        Exited (0) 25 hours ago                         contrail_test_eqsjwxar
0bcc35c344ce        2783b6dd356e                     "/entrypoint.sh"    28 hours ago        Exited (0) 27 hours ago                         contrail_test_fqgpzubi

  • Rebuild existing container (running or non-running container)
# ./testrunner.sh rebuild -h

Usage: ./testrunner.sh rebuild [OPTIONS]
Rebuild contrail-test containers

  -f, --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
  -p, --run-path       Directory path on the host, in which contrail-test save results and other data
  -s, --shell          Do not run tests, but leave a shell, this is useful for debugging
  -r, --rm	         Remove the container on container exit, by default the 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  Testbed json file
  -P, --params-file PARAMS_FILE    Sanity Params ini file

NOTE: Any one of testbd or both testbed-json and params-file required

Possitional Parameters:

  <container id/name>        ontainer

Below code will rebuild an exited container


# ./testrunner.sh rebuild contrail_test_eqsjwxar
 rebuilding container - contrail_test_eqsjwxar
 This process will create an image with the container contrail_test_eqsjwxar
 Creating the image img_contrail_test_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} \
.............
.............

tools/tenent_cleaner.py

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