Browse Source

Remove run_tests.sh

It is deprecated in favor of tox.

Closes-Bug: #1790470
Change-Id: If3b6a274dab0d035b9666b3b9876604cefbc2877
Tom Barron 6 months ago
parent
commit
772a64a871

+ 0
- 4
.zuul.yaml View File

@@ -67,7 +67,6 @@
67 67
       - ^manila/hacking/.*$
68 68
       - ^manila/tests/.*$
69 69
       - ^releasenotes/.*$
70
-      - ^run_tests.sh$
71 70
       - ^setup.cfg$
72 71
       - ^tools/.*$
73 72
       - ^tox.ini$
@@ -89,7 +88,6 @@
89 88
       - ^manila/hacking/.*$
90 89
       - ^manila/tests/.*$
91 90
       - ^releasenotes/.*$
92
-      - ^run_tests.sh$
93 91
       - ^setup.cfg$
94 92
       - ^tools/.*$
95 93
       - ^tox.ini$
@@ -390,7 +388,6 @@
390 388
       - ^manila/hacking/.*$
391 389
       - ^manila/tests/.*$
392 390
       - ^releasenotes/.*$
393
-      - ^run_tests.sh$
394 391
       - ^tools/.*$
395 392
       - ^tox.ini$
396 393
     required-projects:
@@ -413,7 +410,6 @@
413 410
       - ^manila/hacking/.*$
414 411
       - ^manila/tests/.*$
415 412
       - ^releasenotes/.*$
416
-      - ^run_tests.sh$
417 413
       - ^tools/.*$
418 414
       - ^tox.ini$
419 415
     required-projects:

+ 31
- 24
doc/source/contributor/development.environment.rst View File

@@ -121,15 +121,21 @@ Grab the code::
121 121
 
122 122
 Running unit tests
123 123
 ------------------
124
-The unit tests will run by default inside a virtualenv in the ``.venv``
125
-directory. Run the unit tests by doing::
124
+The preferred way to run the unit tests is using ``tox``. Tox executes tests in
125
+isolated environment, by creating separate virtualenv and installing
126
+dependencies from the ``requirements.txt`` and ``test-requirements.txt`` files,
127
+so the only package you install is ``tox`` itself::
126 128
 
127
-    ./run_tests.sh
129
+    sudo pip install tox
128 130
 
129
-The first time you run them, you will be asked if you want to create a virtual
130
-environment (hit "y")::
131
+Run the unit tests with::
131 132
 
132
-    No virtual environment found...create one? (Y/n)
133
+    tox -e py{python-version}
134
+
135
+Example::
136
+
137
+    tox -epy27
138
+    tox -epy36
133 139
 
134 140
 See :doc:`unit_tests` for more details.
135 141
 
@@ -138,38 +144,39 @@ See :doc:`unit_tests` for more details.
138 144
 Manually installing and using the virtualenv
139 145
 --------------------------------------------
140 146
 
141
-You can manually install the virtual environment instead of having
142
-``run_tests.sh`` do it for you::
147
+You can also manually install the virtual environment::
148
+
149
+  tox -epy27 --notest
143 150
 
144
-  python tools/install_venv.py
151
+or::
152
+
153
+  tox -epy36 --notest
145 154
 
146 155
 This will install all of the Python packages listed in the
147
-``requirements.txt`` file into your virtualenv. There will also be some
148
-additional packages (pip, distribute, greenlet) that are installed
149
-by the ``tools/install_venv.py`` file into the virtualenv.
156
+``requirements.txt`` file into your virtualenv.
157
+
158
+To activate the Manila virtualenv you can run::
159
+
160
+     $ source .tox/py27/bin/activate
150 161
 
151
-If all goes well, you should get a message something like this::
162
+or::
152 163
 
153
-  Manila development environment setup is complete.
164
+     $ source .tox/py36/bin/activate
154 165
 
155
-To activate the manila virtualenv for the extent of your current shell session
156
-you can run::
166
+To exit your virtualenv, just type::
157 167
 
158
-     $ source .venv/bin/activate
168
+     $ deactivate
159 169
 
160 170
 Or, if you prefer, you can run commands in the virtualenv on a case by case
161 171
 basis by running::
162 172
 
163
-     $ tools/with_venv.sh <your command>
173
+     $ tox -e venv -- <your command>
164 174
 
165 175
 Contributing Your Work
166 176
 ----------------------
167 177
 
168
-Once your work is complete you may wish to contribute it to the project.  Add
169
-your name and email address to the ``Authors`` file, and also to the ``.mailmap``
170
-file if you use multiple email addresses. Your contributions can not be merged
171
-into trunk unless you are listed in the Authors file. Manila uses the Gerrit
172
-code review system. For information on how to submit your branch to Gerrit,
173
-see GerritWorkflow_.
178
+Once your work is complete you may wish to contribute it to the
179
+project. Manila uses the Gerrit code review system. For information on
180
+how to submit your branch to Gerrit, see GerritWorkflow_.
174 181
 
175 182
 .. _GerritWorkflow: https://docs.openstack.org/infra/manual/developers.html#development-workflow

+ 23
- 100
doc/source/contributor/unit_tests.rst View File

@@ -8,128 +8,51 @@ Jenkins server if the change causes unit test failures.
8 8
 
9 9
 Running the tests
10 10
 -----------------
11
-Run the unit tests by doing::
12 11
 
13
-    ./run_tests.sh
12
+To run all unit tests simply run::
14 13
 
15
-This script is a wrapper around the `nose`_ testrunner and the `pep8`_ checker.
14
+    tox
16 15
 
17
-.. _nose: http://code.google.com/p/python-nose/
18
-.. _pep8: https://github.com/jcrocholl/pep8
16
+This will create a virtual environment, load all the packages from
17
+test-requirements.txt and run all unit tests as well as run flake8 and hacking
18
+checks against the code.
19 19
 
20
-Flags
21
------
20
+You may run individual test targets, for example only py27 tests, by running::
22 21
 
23
-The ``run_tests.sh`` script supports several flags. You can view a list of
24
-flags by doing::
22
+    tox -e py27
25 23
 
26
-    run_tests.sh -h
27
-
28
-This will show the following help information::
29
-
30
-    Usage: ./run_tests.sh [OPTION]...
31
-    Run manila's test suite(s)
32
-
33
-      -V, --virtual-env        Always use virtualenv.  Install automatically if not present
34
-      -N, --no-virtual-env     Don't use virtualenv.  Run tests in local environment
35
-      -s, --no-site-packages   Isolate the virtualenv from the global Python environment
36
-      -r, --recreate-db        Recreate the test database (deprecated, as this is now the default).
37
-      -n, --no-recreate-db     Don't recreate the test database.
38
-      -x, --stop               Stop running tests after the first error or failure.
39
-      -f, --force              Force a clean re-build of the virtual environment. Useful when dependencies have been added.
40
-      -p, --pep8               Just run pep8
41
-      -P, --no-pep8            Don't run pep8
42
-      -c, --coverage           Generate coverage report
43
-      -h, --help               Print this usage message
44
-      --hide-elapsed           Don't print the elapsed time for each test along with slow test list
45
-
46
-Because ``run_tests.sh`` is a wrapper around nose, it also accepts the same
47
-flags as nosetests. See the `nose options documentation`_ for details about
48
-these additional flags.
49
-
50
-.. _nose options documentation: http://readthedocs.org/docs/nose/en/latest/usage.html#options
24
+Note that you can inspect the tox.ini file to get more details on the available
25
+options and what the test run does by default.
51 26
 
52 27
 Running a subset of tests
53 28
 -------------------------
54
-
55 29
 Instead of running all tests, you can specify an individual directory, file,
56 30
 class, or method that contains test code.
57 31
 
58 32
 To run the tests in the ``manila/tests/scheduler`` directory::
59 33
 
60
-    ./run_tests.sh scheduler
61
-
62
-To run the tests in the ``manila/tests/test_libvirt.py`` file::
63
-
64
-    ./run_tests.sh test_libvirt
65
-
66
-To run the tests in the `HostStateTestCase` class in
67
-``manila/tests/test_libvirt.py``::
68
-
69
-    ./run_tests.sh test_libvirt:HostStateTestCase
70
-
71
-To run the `ToPrimitiveTestCase.test_dict` test method in
72
-``manila/tests/test_utils.py``::
73
-
74
-    ./run_tests.sh test_utils:ToPrimitiveTestCase.test_dict
75
-
76
-
77
-Suppressing logging output when tests fail
78
-------------------------------------------
79
-
80
-By default, when one or more unit test fails, all of the data sent to the
81
-logger during the failed tests will appear on standard output, which typically
82
-consists of many lines of texts. The logging output can make it difficult to
83
-identify which specific tests have failed, unless your terminal has a large
84
-scrollback buffer or you have redirected output to a file.
85
-
86
-You can suppress the logging output by calling ``run_tests.sh`` with the nose
87
-flag::
88
-
89
-    --nologcapture
90
-
91
-Virtualenv
92
-----------
93
-
94
-By default, the tests use the Python packages installed inside a
95
-virtualenv [#f1]_. (This is equivalent to using the ``-V, --virtualenv`` flag).
96
-If the virtualenv does not exist, it will be created the first time the tests are run.
97
-
98
-If you wish to recreate the virtualenv, call ``run_tests.sh`` with the flag::
99
-
100
-    -f, --force
101
-
102
-Recreating the virtualenv is useful if the package dependencies have changed
103
-since the virtualenv was last created. If the ``requirements.txt`` or
104
-``tools/install_venv.py`` files have changed, it's a good idea to recreate the
105
-virtualenv.
34
+    tox -epy27 -- manila.tests.scheduler
106 35
 
107
-By default, the unit tests will see both the packages in the virtualenv and
108
-the packages that have been installed in the Python global environment. In
109
-some cases, the packages in the Python global environment may cause a conflict
110
-with the packages in the virtualenv. If this occurs, you can isolate the
111
-virtualenv from the global environment by using the flag::
36
+To run the tests in the `ShareManagerTestCase` class in
37
+``manila/tests/share/test_manager.py``::
112 38
 
113
-    -s, --no-site packages
39
+    tox -epy27 -- manila.tests.share.test_manager.ShareManagerTestCase
114 40
 
115
-If you do not wish to use a virtualenv at all, use the flag::
41
+To run the `ShareManagerTestCase::test_share_manager_instance` test method in
42
+``manila/tests/share/test_manager.py``::
116 43
 
117
-    -N, --no-virtual-env
44
+  tox -epy27 -- manila.tests.share.test_manager.ShareManagerTestCase.test_share_manager_instance
118 45
 
119
-Database
120
---------
46
+For more information on these options and details about stestr, please see the
47
+`stestr documentation <http://stestr.readthedocs.io/en/latest/MANUAL.html>`_.
121 48
 
122
-Some of the unit tests make queries against an sqlite database [#f2]_. By
123
-default, the test database (``tests.sqlite``) is deleted and recreated each
124
-time ``run_tests.sh`` is invoked (This is equivalent to using the
125
-``-r, --recreate-db`` flag). To reduce testing time if a database already
126
-exists it can be reused by using the flag::
49
+Database Setup
50
+--------------
127 51
 
128
-    -n, --no-recreate-db
52
+Some unit tests will use a local database. You can use
53
+``tools/test-setup.sh`` to set up your local system the same way as
54
+it's setup in the CI environment.
129 55
 
130
-Reusing an existing database may cause tests to fail if the schema has
131
-changed. If any files in the ``manila/db/sqlalchemy`` have changed, it's a good
132
-idea to recreate the test database.
133 56
 
134 57
 Gotchas
135 58
 -------

+ 11
- 6
manila/testing/README.rst View File

@@ -34,12 +34,17 @@ is overridden.
34 34
 Running Tests
35 35
 -------------
36 36
 
37
-In the root of the Manila source code run the run_tests.sh script. This will
38
-offer to create a virtual environment and populate it with dependencies.
39
-If you don't have dependencies installed that are needed for compiling Manila's
40
-direct dependencies, you'll have to use your operating system's method of
41
-installing extra dependencies. To get help using this script execute it with
42
-the -h parameter to get options `./run_tests.sh -h`
37
+The preferred way to run the unit tests is using ``tox``. Tox executes tests in
38
+isolated environment, by creating separate virtualenv and installing
39
+dependencies from the ``requirements.txt`` and ``test-requirements.txt`` files,
40
+so the only package you install is ``tox`` itself::
41
+
42
+    sudo pip install tox
43
+
44
+Run the unit tests by doing::
45
+
46
+    tox -e py3
47
+    tox -e py27
43 48
 
44 49
 Tests and assertRaises
45 50
 ----------------------

+ 1
- 2
tools/enable-pre-commit-hook.sh View File

@@ -17,7 +17,7 @@
17 17
 PRE_COMMIT_SCRIPT=.git/hooks/pre-commit
18 18
 
19 19
 make_hook() {
20
-    echo "exec ./run_tests.sh -N -p" >> $PRE_COMMIT_SCRIPT
20
+    echo "exec tox -e fast8" >> $PRE_COMMIT_SCRIPT
21 21
     chmod +x $PRE_COMMIT_SCRIPT
22 22
 
23 23
     if [ -w $PRE_COMMIT_SCRIPT -a -x $PRE_COMMIT_SCRIPT ]; then
@@ -39,4 +39,3 @@ if [ ! -d ".git" ]; then
39 39
 else
40 40
     make_hook
41 41
 fi
42
-

+ 1
- 2
tox.ini View File

@@ -56,8 +56,7 @@ commands =
56 56
          devstack/upgrade/shutdown.sh \
57 57
          devstack/upgrade/upgrade.sh \
58 58
          tools/cover.sh \
59
-         tools/check_logging.sh \
60
-         run_tests.sh
59
+         tools/check_logging.sh
61 60
   {toxinidir}/tools/check_exec.py {toxinidir}/manila
62 61
   {toxinidir}/tools/check_logging.sh {toxinidir}/manila
63 62
 

Loading…
Cancel
Save