123 Commits

Author SHA1 Message Date
Monty Taylor
307289c20a Pass testropts in to setup.py in run_tests.sh
Change-Id: Idba469fbd8c0488a308071de45e16eedcb1d6cc6
2013-01-30 11:43:43 +11:00
Joe Gordon
8af6c6b885 Make sure there are no unused import
Remove all currently unused imports
Prevent future unused imports

Change-Id: I6ac26d5c71b79952a7732db300355a00310c712e
2013-01-28 21:37:32 +00:00
Joe Gordon
8f394ee716 Enable N302: Import modules only
Fix all N302 issues, and re-enable.

Change-Id: Ic94d144c915b228b7ff2fd9c5951875e159ffcdd
2013-01-25 12:11:54 -05:00
Jenkins
f9012e39ee Merge "Fix hacking N302 import only modules" 2013-01-24 22:59:13 +00:00
Jenkins
b3b3f6ec7d Merge "Generate coverage even if tests failed." 2013-01-24 16:16:13 +00:00
Joe Gordon
4845fc2720 Fix hacking N302 import only modules
* Includes some general tools/hacking cleanup
* Fix several N302 cases
* Disable N302 until all cases are fixed

Change-Id: Iddba07ff13e10dc41a6930749044bb8c0572d279
2013-01-24 09:52:58 -05:00
Robert Collins
99575067ce Skip backup files when running pep8.
Backup files (foo~) are not interesting for a pep8 report.

Change-Id: Ib4a43271c8a0ec47d63e61c45125e3f282415927
2013-01-24 12:04:48 +13:00
Clark Boylan
7c5b098947 Use setup.py testr to run testr in run_tests.sh.
Using the setup.py testr command in run_tests.sh will sync run_tests.sh
up with the way tox currently runs the tests and collects coverage.

Change-Id: I21e3965280b3242a860c6be49c4dca44f197b03a
2013-01-21 19:10:53 -08:00
Clark Boylan
cc88380dfe Fix nova coverage.
Nova coverage was broken because additional coverage tests were added
that interfere with collecting coverage during unit testing. These new
tests were not properly excluded by the coverage unit test regex. Modify
the regex to exclude any tests of the form '.*test.*coverage.*'. This
allows `tox -ecover` and `run_tests.sh --coverage` to run properly.

Change-Id: Id35f50ec335707c9eadb0e7fb3aa0833661f7333
2013-01-21 19:05:51 -08:00
Robert Collins
abd8957650 Generate coverage even if tests failed.
A test failing doesn't make coverage useless, so we should always
generate it.

Change-Id: I3ed9e54213c7fb6756906553920d19c5075e1adb
2013-01-22 11:08:38 +13:00
Joe Gordon
2704a40e57 Fix multi line docstring tests in hacking.py
* Fixes N403, along with docstring test
* Adds N404, multi line start
* Disable N403 and N404 until all cases are fixed
* Remove obsolote '--repeat' flag from tox.ini

Change-Id: Ibf6371efc1cdc764e66f6f7c5c4362440101f963
2013-01-17 13:24:31 -05:00
Sean Dague
313279f99a enable hacking.py self tests
pep8 and hacking.py (by inheritance) have the ability to run self
tests via docstrings, if we format the comments correctly, and change
the docstring test regex. Include self testing in our normal pep8
tests.

fix the comments to actually be test case compliant

fix nova_import_alphabetical to pass on short import lists (only 2
lines, starting at the beginning of a file)

comment where it doesn't appear that hacking.py tests are working
(though there could be deeper black magic in some of them).

fix a doc string in pep8 self tests that breaks N301

fix the fact that pep8 error strings are supposed to start with
\w\d\d\d, we were just lucking out on some formatting because the
string NOVA happened to be only 4 chars long.

Add a couple of escapes so that we don't recursively fail on our
own fail self tests for comments. (boy that's fun)

Change-Id: I14d5e04cfc092b37ec4967cd7485e9975a5eb820
2013-01-14 14:39:49 -05:00
Jenkins
7529e513e2 Merge "make runtests -p act more like tox" 2013-01-10 19:22:29 +00:00
Sean Dague
edca0c2a3d make runtests -p act more like tox
now that all the N402 fixes are in, start enforcing it

Change-Id: I9d495849bf698e5af142d0ccafe551ac0e8a600c
2013-01-10 08:57:49 -05:00
Alessio Ababilov
7d04a2dce3 Fix bash syntax error in run_tests.sh
Spaces are not allowed in bash assignments.

Change-Id: Ib80b10802259f5bff2ad0489f9efd763e5995056
2013-01-10 12:07:23 +02:00
Jenkins
fa4696ff03 Merge "fix N401 errors, stop ignoring all N4* errors" 2013-01-09 01:01:57 +00:00
Sean Dague
37bfdd3b38 fix N401 errors, stop ignoring all N4* errors
We had previously been ignoring all our custom N4xx hacking.py
errors. This fixes all the N401 errors "doc strings
should not start with a space" and reduces the ignore set down
to N402 only "single line docstrings should end with period".

It also fixes the N401 parser to catch only docstrings, and
not tripple quoted string blocks used later on in a function.

Clean up a few of the more crazy uses of """ in our code

Clean up additional funky comments to make indents a bit more
consistent, and pull in lines when possible.

Change-Id: I9040a1d2ca7efda83bd5e425b95d1408b5b63577
2013-01-07 21:39:58 -05:00
Clark Boylan
7224fde0f0 Invert test stream capture logic for debugging.
Previously the default test behavior was to capture stdout and stderr.
Make the new default to not capture stdout and stderr then set
.testr.conf to always capture these streams when running tests under
testr.

The motiviation behind this change is that you will want these streams
to be captured when running under testr, but when not running under
testr you may not want to capture them. An example of this would be
running `python -m testtools.run test_name` with a change to test_name
to invoke the python debugger (capturing stdout and stderr interferes
with normal debugger functionality).

Also, only invoke the test timeout by default when running under testr.
This is done for the same reason as above. When running a test under the
debugger the timeout interferes with debugging.

Change-Id: I42cbbdadb2f221ec439e92a6800d14e8436bb77b
2013-01-07 11:03:30 -08:00
Sean Dague
0323a744e6 allow for the ability to run partial coverage
the way the coverage exclusion was made previously meant that
if you ran coverage, it would always run all the tests. Fix
this so you can run a subset.

Change-Id: I057587204728d379e2a43b5c5ee14fe91f83f64b
2012-12-18 11:33:01 -05:00
Clark Boylan
4abc8cc64f Use testr to run nova unittests.
Convert nova from using nosetests to testr for its test runner. Some
tests had to be modified to get them to run properly under testr.

run_tests.sh has been updated to run testr instead of nosetests.

Coverage is collected by running subunit.run under coverage.py when the
coverage environment is selected.

Note that you will need to rebuild your virtualenvs as nose is being
removed from the dependency lists and is being replaced by testr. Tests
will run in different processes once this test is merged so you cannot
use test classes to pass information between tests. Each test should be
a proper independent unit. Additionally the -x and -d flags to
run_tests.sh have been removed as there are currently no decent
approximations for those functions.

Change-Id: I019ca098972ca749b195f59968cf21edd5ba9109
2012-12-14 14:22:20 -08:00
Hengqing Hu
7d89fdf544 Clean up run_tests.sh
Remove obsolete lines.

Change-Id: Id6c868c857733dc4cbeceacab4d3a817b43b77b1
2012-12-13 15:46:37 +08:00
Mauro S. M. Rodrigues
48f43fd4e9 Enable debug in run_tests using pdb
When you try to debug some test using nose.tools.set_trace the pdb prompt
is 'trapped' inside tee manipulation of stdout.
    Since debug mode is not supposed to be used in the gates we don't need to
concern about the lack of a log to analyze the output.

Change-Id: I7daebe7267b04d41f2ca383f826419f0dfb544ab
2012-11-29 17:18:51 -05:00
Chuck Short
6f562bbe09 Display errors when running nosetests
During Ubuntu builds we run the run_test.sh script
during the package build process, so that we can catch
regressions in our packaging before uploading to the archive.

However a recent change writes the output of the nosetests
to an error log so we don't see why the package fail to build.

This patch also displays the output of the nosetests so we
can see why the tests fail without having to look at the nosetests.log.

This patch add the '-v', for a verbose display of nosetests.

Change-Id: Id21d53df356de344a8577282c5a82f3ff927bc11
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2012-11-27 07:49:33 -06:00
Chuck Short
560e5cd84e Pin pep8 to 1.3.3
Apart of making pep8 version standard across all openstack
projects.

With this change we ignore E712 since it is normal to use
"column == True" in sqlalchemy.

Change-Id: I73a162847a79558cb158112878033edf18039805
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2012-11-19 21:20:42 -06:00
Jenkins
6581a6cdc9 Merge "Fix the fail-on-zero-tests case so that it is tolerant of no output" 2012-10-24 19:31:25 +00:00
Dan Smith
51cc2eb3a7 Fix the fail-on-zero-tests case so that it is tolerant of no output
Some ways of running run_tests.sh will not output a line for us to
parse the count from. Treat no "Ran X tests" as "Ran 0 tests".

Change-Id: I96ba13e797ceaf9b9fa2b60ccb558510b5e32a88
2012-10-22 15:52:22 -07:00
Joe Gordon
c39dbb53bc Fix and enable pep8 E502, E712
pep8 E502 and E712 were temporarily disabld when upgrading to pep8 1.2

Change-Id: If5158304cb8e73ef844dea9f726df6f8fe305269
2012-10-22 13:47:36 -07:00
Jenkins
0c45f2a13b Merge "Make run_tests.sh fail if no tests are actually run" 2012-10-12 21:06:53 +00:00
Dan Smith
bd30d411c4 Make run_tests.sh fail if no tests are actually run
Right now, run_tests seems to report test success if there is a
catastrophic failure early in the process. This can happen if you
have a python file that fails to parse, or if something else in
the test environment setup fails to initialize (such as creating
the empty database for the test run). Nosetests will report
success, but indicate that zero tests were run.

This patch snatches the output of nosetests and, if zero tests
ran, reports to the user that something is broken and offers a few
suggestions.

Change-Id: Ide6fd8b212f0650cb227f60b25d4b4e62ee150ac
2012-10-12 07:10:39 -07:00
Joe Gordon
43b198c5ee Update run_tests.sh pep8 ignore list for pep8 1.2
Patch I32a8808c6c9cccfedcc4d2a26649333aca1cd713 changed pep8 to 1.2
but did not update the ignore list in run_tests.sh

Change-Id: I9d2cab79197ba3cdd7103d4532e28a999c9454f4
2012-10-11 19:34:41 +00:00
Jenkins
c1abf87fec Merge "Disable I18N in Nova's test suites" 2012-08-20 07:53:47 +00:00
Vishvananda Ishaya
10e25db4be Makes sure tests don't leave lockfiles around
Our new lockfile code works fine if the locks already exist, but
it is annoying to pollute the source tree with lockfiles in the
tests.

This modifies the lockfile code slightly to use a tempdir if
lock_path is none. Note that a tempdir will not work in production
but it is fine for testing. We set the lock_path to None in the
testing flags.

Also removes the explicit cleanup in run_tests.sh. The new solution
works with tox and will work even if we add new locks.

Fixes bug 1035426

Change-Id: I613926e4288442e79df50ea5f5bd8f9eafdfe7e7
2012-08-17 17:26:42 +00:00
Jian Wen
55b37bef9b Disable I18N in Nova's test suites
Messages translated into other language like Chinese cause some
unit tests to fail.

Fixes LP bug #1037946.

Change-Id: I01d04333d28bab52d6f424432524b206f3845fba
2012-08-18 00:00:00 +08:00
Stanislaw Pitucha
2c1524866a Improve external lock implementation
Remove a number of limitations from the external locks.
- They can be nested now
- They do not need external cleanup in case of failures
- They do not rely on lockfile or greenlet internal implementation

New implementation is based on fcntl locks and any crashing process
will drop the lock. It does not have to rely on any cleanup code or
handling exceptions. Because no cleanup is needed, a number of tests
have been removed.
This implementation is not portable outside of POSIX/BSD/SVR4 systems.

Fcntl locks should work correctly with NFS mounts.

Locks are cleaned up after the tests finish running via run_tests.sh,
even though it's not strictly needed.

This change requires eventlet >= 0.9.17.

bp improve-external-locking

Change-Id: Idf5424c04645f25097733848a007b150145b0b27
2012-08-04 12:52:50 +01:00
Dan Prince
1ef88fdd5b Exclude openstack-common from pep8 checks.
Updates tox.ini and run_tests.sh to exclude openstack-common code
from pep8 checks.

Fixes LP Bug #1020792

Change-Id: I6bb9747f86f7677f0e9c4169c04d6f3fbd4b3480
2012-07-13 13:59:56 -04:00
Yun Mao
3b6744786c Make pep8 test work on Mac
find . -executable is not available on Mac OS X. We switch back to
the old -perm syntax to find files to test.

Change-Id: Iea58a249f282c98ae6cffbe8e6359f70f8b1d63f
2012-07-10 01:05:22 -04:00
Rick Harris
8a10d6bade Add PEP8 checks back for Dom0 plugins.
Fixes bug 1018641

Change-Id: Id61947252fe4d3f5b93279518128ba90100f3748
2012-06-28 22:57:24 +00:00
Monty Taylor
cf34a60157 Finalize tox config.
Shrink tox.ini to the new short version.
Fix the test cases to be able to be run in nosetets plus the
openstack.nose_plugin, which finally removes the need for
nova/testing/runner.py
Also, now we'll just output directly to stdout, which will
make nose collect the trace logging directly and either output
it at the end of the run, or inject it into the xunit output
appropriately.

Change-Id: I1456e18a11a840145492038108bdfe812c8230d1
2012-06-07 12:15:42 -04:00
Joe Gordon
f8437e37d4 Enable checking for imports in alphabetical order
And fix existing alphabetical ordering problems

Change-Id: I3ab887e118adc8022c84ff7230e7cc2d261804f6
2012-05-22 10:44:00 -07:00
Lorin Hochstein
190b4e27c8 Ignore common code in coverage calculations.
Ignore nova/openstack/common code when calculating coverage.

We do this because the unit tests for the common code are in a
different repository.

Change-Id: I0103b8acfc4cdaace68a18b1d1723a13595debe2
2012-04-28 22:06:07 -04:00
Jenkins
9bd0504bd3 Merge "Scope coverage report generation to nova module." 2012-04-25 07:09:13 +00:00
Joe Gordon
7ee0d7848d Improved tools/hacking.py
* cleaner output
* fix bug 980009
* Fix N201
* N306: alphabetical order imports
* N401: docstring start
* N402: one line docstring start
* N403: multi line docstring end
* Until fixed, N40* will be disabled by default

Change-Id: I9addafdaa7a1f8fb950e14a5409f661dec6c7b87
2012-04-24 09:29:43 -07:00
Renier Morales
bcb53dfc6a Scope coverage report generation to nova module.
Coverage report generation was not using --include filters.
This resulted in generating a report that included all external
dependencies. Some of these may include problematic characters for
utf8 decoding. In the odd case this was found, coverage would fail
with a UnicodeDecodeError.

Fixes bug #987077.

Change-Id: I276698e65ac1037972209a406058168433cd826b
2012-04-24 07:58:25 -04:00
Dan Prince
2b490fd2ef Exclude xenapi plugins from pep8/hacking checks.
Fixes LP Bug #987055.

Change-Id: I7132b88c5e0a90b16d0f8e35df45b82e7991280f
2012-04-22 21:11:03 -04:00
Johannes Erdfelt
c808df7005 Make run_tests.sh just a little bit less verbose
Change-Id: I9d4dc11083cb51040677eeda2d28d4b23539a304
2012-04-12 17:01:58 +00:00
Yuriy Taraday
07bbe57754 Run tools/hacking.py instead of pep8 mandatory.
Change-Id: I81db73588ece36dec4dba90b9841ed6d0fac6a8f
2012-04-10 13:18:32 +04:00
Rick Harris
203d51f0e4 Remove unecessary --repeat option for pep8.
Fixes bug 977489

--repeat became the default in 0.7; since we're now requiring 1.0 or
above, this can go away.

Change-Id: I85ee8ab274594ce96ece6610247dfd8a6f082af5
2012-04-09 20:43:50 +00:00
Brian Elliott
549616d122 bug 968452
Update test-requires to use pep8>=1.0.  Removed PEP8 warning suppression
around 3-arg raises.

Change-Id: Ib4ed42adc167aa1e8078619a36b409b76b9f5d73
2012-04-09 19:06:03 +00:00
Hengqing Hu
9a042d3c50 Remove trailing whitespaces in regular file
Fixes bug #945346

Change-Id: I07a303c2e503e50d7138585c683e0d1310339276
2012-03-07 13:43:37 +08:00
Jason Kölker
a7df900895 Monkey patch migrate < 0.7.3
* Works around migrate issue 72 [1] by monkey patching migrate prior
  to import.
* Removes previous workaround
* Refactor test config to work under nosetests directly
* Fixes LP940407

1: https://code.google.com/p/sqlalchemy-migrate/issues/detail?id=72

Change-Id: I219e4cecf8bb2e34ae238ac270428f496378ee61
2012-02-24 21:55:52 -06:00