From d17fe4910947ec79faa826eb54b5a1eab3d8a67f Mon Sep 17 00:00:00 2001 From: Hongbin Lu Date: Mon, 3 Apr 2017 18:07:56 -0400 Subject: [PATCH] Document how to run tempest tests locally * Add a dev document for how to run tempest tests locally. * Pull the instruction of running unit tests out of quickstart guide and make it a standalone document. * Fix the unit tests guide to make it work at Ubuntu 16.04. * Add a sample local.conf as minimal to run devstack * Add osprofiler guide to the index page. Change-Id: I31794733c9225478f5df029279c8415a23b1caa0 --- devstack/local.conf.sample | 11 +++++ doc/source/dev/quickstart.rst | 52 +--------------------- doc/source/dev/tempest_tests.rst | 64 +++++++++++++++++++++++++++ doc/source/dev/unit_tests.rst | 74 ++++++++++++++++++++++++++++++++ doc/source/index.rst | 5 ++- 5 files changed, 154 insertions(+), 52 deletions(-) create mode 100644 devstack/local.conf.sample create mode 100644 doc/source/dev/tempest_tests.rst create mode 100644 doc/source/dev/unit_tests.rst diff --git a/devstack/local.conf.sample b/devstack/local.conf.sample new file mode 100644 index 000000000..79fce287c --- /dev/null +++ b/devstack/local.conf.sample @@ -0,0 +1,11 @@ +[[local|localrc]] +DATABASE_PASSWORD=password +RABBIT_PASSWORD=password +SERVICE_TOKEN=password +SERVICE_PASSWORD=password +ADMIN_PASSWORD=password +enable_plugin zun https://git.openstack.org/openstack/zun +enable_plugin kuryr-libnetwork http://git.openstack.org/openstack/kuryr-libnetwork + +# Optional: uncomment to enable the Zun UI plugin in Horizon +# enable_plugin zun-ui https://git.openstack.org/openstack/zun-ui diff --git a/doc/source/dev/quickstart.rst b/doc/source/dev/quickstart.rst index 828dafc08..e7d22291e 100644 --- a/doc/source/dev/quickstart.rst +++ b/doc/source/dev/quickstart.rst @@ -12,60 +12,10 @@ an OpenStack project. http://docs.openstack.org/infra/manual/developers.html -Setup Dev Environment -===================== - -Install OS-specific prerequisites:: - - # Ubuntu/Debian: - sudo apt-get update - sudo apt-get install -y libmysqlclient-dev build-essential python-dev \ - python3.4-dev git libssl-dev libffi-dev - -Install pip:: - - curl -s https://bootstrap.pypa.io/get-pip.py | sudo python - -Install common prerequisites:: - - sudo pip install virtualenv flake8 tox testrepository git-review - -You may need to explicitly upgrade virtualenv if you've installed the one -from your OS distribution and it is too old (tox will complain). You can -upgrade it individually, if you need to:: - - sudo pip install -U virtualenv - -Zun source code should be pulled directly from git:: - - # from your home or source directory - cd ~ - git clone https://git.openstack.org/openstack/zun - cd zun - -All unit tests should be run using tox. To run Zun's entire test suite:: - - # run all tests (unit and pep8) - tox - -To run a specific test, use a positional argument for the unit tests:: - - # run a specific test for Python 2.7 - tox -epy27 -- test_conductor - -You may pass options to the test programs using positional arguments:: - - # run all the Python 2.7 unit tests (in parallel!) - tox -epy27 -- --parallel - -To run only the pep8/flake8 syntax and style checks:: - - tox -epep8 - Exercising the Services Using Devstack ====================================== -This session has been tested on Ubuntu only. +This session has been tested on Ubuntu 16.04 (Xenial) only. Clone devstack:: diff --git a/doc/source/dev/tempest_tests.rst b/doc/source/dev/tempest_tests.rst new file mode 100644 index 000000000..71d2bb92e --- /dev/null +++ b/doc/source/dev/tempest_tests.rst @@ -0,0 +1,64 @@ +.. + Licensed under the Apache License, Version 2.0 (the "License"); you may + not use this file except in compliance with the License. You may obtain + a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + License for the specific language governing permissions and limitations + under the License. + +========================= +Run tempest tests locally +========================= + +This is a guide for developers who want to run tempest tests in their local +machine. + +Zun contains a suite of tempest tests in the zun/tests/tempest directory. +Tempest tests are primary for testing integration between Zun and its +depending software stack (i.e. Docker, other OpenStack services). Any proposed +code change will be automatically rejected by the gate if the change causes +tempest test failures. If this happens, contributors are suggested to refer +this document to re-run the tests locally and perform any necessary +trouble-shooting. + +Prerequisite +============ + +You need to deploy Zun in a devstack environment. + +Clone devstack:: + + # Create a root directory for devstack if needed + sudo mkdir -p /opt/stack + sudo chown $USER /opt/stack + + git clone https://git.openstack.org/openstack-dev/devstack /opt/stack/devstack + +We will run devstack with minimal local.conf settings required. You can use the +sample local.conf as a quick-start:: + + git clone https://git.openstack.org/openstack/zun /opt/stack/zun + cp /opt/stack/zun/devstack/local.conf.sample /opt/stack/devstack/local.conf + +Run devstack:: + + cd /opt/stack/devstack + ./stack.sh + +**NOTE:** This will take a while to setup the dev environment. + +Run the test +============ + +Navigate to tempest directory:: + + cd /opt/stack/tempest + +Run this command:: + + tox -eall-plugin -- zun.tests.tempest.api --concurrency=1 diff --git a/doc/source/dev/unit_tests.rst b/doc/source/dev/unit_tests.rst new file mode 100644 index 000000000..23d7094b4 --- /dev/null +++ b/doc/source/dev/unit_tests.rst @@ -0,0 +1,74 @@ +.. + Licensed under the Apache License, Version 2.0 (the "License"); you may + not use this file except in compliance with the License. You may obtain + a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + License for the specific language governing permissions and limitations + under the License. + +============== +Run unit tests +============== + +This is a guide for developers who want to run unit tests in their local +machine. + +Prerequisite +============ + +Install OS-specific prerequisites:: + + # Ubuntu/Debian (recommend Ubuntu 16.04): + sudo apt-get update + sudo apt-get install -y libmysqlclient-dev build-essential python-dev \ + python3.5-dev git libssl-dev libffi-dev \ + python-gdbm + +Install pip:: + + curl -s https://bootstrap.pypa.io/get-pip.py | sudo python + +Install common prerequisites:: + + sudo pip install virtualenv flake8 tox testrepository git-review os-testr + +You may need to explicitly upgrade virtualenv if you've installed the one +from your OS distribution and it is too old (tox will complain). You can +upgrade it individually, if you need to:: + + sudo pip install -U virtualenv + +Zun source code should be pulled directly from git:: + + # from your home or source directory + cd ~ + git clone https://git.openstack.org/openstack/zun + cd zun + + +Running the tests +================= + +All unit tests should be run using tox. To run Zun's entire test suite:: + + # run all tests (unit and pep8) + tox + +To run a specific test, use a positional argument for the unit tests:: + + # run a specific test for Python 2.7 + tox -epy27 -- test_container + +You may pass options to the test programs using positional arguments:: + + # run all the Python 2.7 unit tests (in parallel!) + tox -epy27 -- --parallel + +To run only the pep8/flake8 syntax and style checks:: + + tox -epep8 diff --git a/doc/source/index.rst b/doc/source/index.rst index 4f129d77e..e86007b72 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -23,7 +23,10 @@ Contents :maxdepth: 1 dev/quickstart - dev/manual-devstack.rst + dev/unit_tests + dev/tempest_tests + dev/manual-devstack + osprofiler readme installation usage