Commit Graph

157 Commits

Author SHA1 Message Date
Sean Dague 2615ff0651 default tox cmd should also run 'functional' target
The default tox cmd should also run the 'functional' target, this got
missed in adding that sub target.

Change-Id: I9a10b0c9798d9f90db03991c45b9f2b285d1e4d0
2015-03-20 11:43:59 -04:00
Gary Kotton 6bc7e271b5 Tox: reduce complexity level to 35
The max-complexity is now set at 35. We are unable to lower this due to
the following offenders:
./nova/virt/xenapi/vmops.py:431:1: C901 'VMOps._spawn' is too complex (34)
./nova/network/manager.py:1226:1: C901 'NetworkManager._do_create_networks' is too complex (34)
./nova/network/neutronv2/api.py:370:1: C901 'API.allocate_for_instance' is too complex (34)

Change-Id: I6101dcb594b88d346edd72eea2ef2250c4e2891f
2015-03-18 09:06:35 -07:00
Matt Riedemann 3c65f3ae0e Force LANGUAGE=en_US in test runs
If your native locale is not en_US and you run tests, some will fail due
to the message translation that happens since the assertion messages are
in en_US (not translated, just hard-coded in the tests).

I recreated the bug by setting LANGUAGE=en_GB in my tox.ini and tested
against nova.tests.unit.api.openstack.test_wsgi.

Note that setting LANG=en_US had no effect.

Closes-Bug: #1427745

Change-Id: Ib1c71d0d4170ba1a7ed2fe3eaf0e2d8071ec01d6
2015-03-03 09:00:05 -08:00
Davanum Srinivas 066cfa3352 Revert : Switch off oslo.* namespace check temporarily
In I7033847bab82b6d3cd8f2bdb66c553fec93d7acb, we disabled
N333 to allow changes in flight to still mix up oslo_ and
oslo. based imports. We should revert the change and enforce
every review use just the oslo_ version from now on.

Change-Id: I1db83048c569bcdd62538cce9df076fc355f7b26
2015-02-25 08:56:34 -05:00
Davanum Srinivas c9e79ea94a Switch off oslo.* namespace check temporarily
There's lot of code in flight that will break if we switch
on the asserts to error out pep8/flake8 right now. So
we should temporarily switch it off. Doing this as a separate
review so it's easy to revery and stands out on its own.

Change-Id: I7033847bab82b6d3cd8f2bdb66c553fec93d7acb
2015-02-06 06:18:02 -05:00
Matt Riedemann 19e376a3f6 Remove H238 comment from tox.ini
Commit a8a87900cf removed
H238 from the flake8 ignore list but missed removing the
comment about why we were ignoring it in the first place.

Change-Id: I1fd89aafeea50bead18c8bf4ffdc7577ded2bde3
2015-01-26 09:04:16 -08:00
Davanum Srinivas aff3e8699a Cleanup bad JSON files
- Add missing commas
- Replace single quote with double quote
- events field contains a list of events (event-create-req.json)
- Remove empty files
- Adds a JSON validation test to the docs pipeline

Co-Authored-By: Nicolas Simonds <nic@metacloud.com>
Change-Id: I9a4a9b6b8e2da73b5f25145be3b2faa44ebdb340
2015-01-22 11:46:05 -08:00
Sergey Nikitin a8a87900cf Enable check for H238 rule
Fix H238 failures and enable check for H238

H238 old style class declaration, use new style
(inherit from `object`)

Change-Id: I71dd353ab260a513c5df5af0ee07754e23878570
2015-01-20 18:05:47 +03:00
EdLeafe f53183e2ac Reduce complexity of the _get_guest_config method.
The _get_guest_config() method of libvirt's driver.py is currently the
worst offender in nova. This patch refactors the method to reduce the
complexity of the method from 40 (originally; it has since been dropped
to 35 by other patches) down to 24. With this change, the highest
complexity method is 37, so we can lower the limit in tox.ini to 38.

Change-Id: I05de301bc3dfd84ed15ce3cbb8a7c50f2d1385ed
2015-01-19 17:16:16 +00:00
EdLeafe 8a00ab4312 Reduce the complexity of the create() method.
This is a refactor designed to reduce the cyclomatic complexity of the
current worst offender in nova: the servers.create() method of the nova
API. The complexity of the method was 46; it is now 22.

No logic changes were made.

This builds on the effort started with Change 129125 by Joe Gordon.

Closes-Bug: 1403586

Change-Id: Ib102091773f786b8c8dc5b79c6d776418ed1d57d
2015-01-14 17:52:11 +00:00
Joe Gordon 0150222387 Enable W292
W292 no newline at end of file

W292 started failing with hacking 0.10.0, fix all cases and gate on the
rule.

Change-Id: I6196e8059e71730cc567d4dd211264cdd2272c40
2015-01-10 21:45:08 +00:00
Joe Gordon 3aaefad0d2 Fix and re-gate on H306
H306, alphabetical imports, was mistakenly skipped in
f96ec4411c

Change-Id: I16db4600107b1f8f54b9f46a8552331612859346
2015-01-10 21:45:08 +00:00
Joe Gordon b39df562c7 Move to hacking 0.10
Release notes:
http://git.openstack.org/cgit/openstack-dev/hacking/tag/?id=0.10.0

* Remove references in tox.ini to removed rules
* Fix minor changes (H501)
* Clarify that H306 (imports in alphabetical order shouldn't be skipped)
* Ignore H238: check for old style class declarations
* Temporary skip W292, fix in next patch.

Change-Id: I6d990a564df6a312bd09b2a152315bbdba732082
2015-01-10 21:45:08 +00:00
Daniel P. Berrange 72de6ac4f0 remove all traces of pylint testing infrastructure
The pylint tests have been broken for several months and
the Jenkins job has also been disabled. There has been
no sign of attempts to address this, so just delete what
remains of the pylint support so developers don't mistakenly
think it is supposed to work with patches they are submitting.

Change-Id: Ifacc99e45acb0e9a72be6c31113e0cf073354f02
2015-01-08 11:56:45 +00:00
Sean Dague f96ec4411c extract fixtures from nova.test to nova.test.fixtures
Start extracting all the setup code in note.test into fixtures which
will let us decompose test setup (and have test base classes that
don't setup everything).

This creates new OutputStreamCapture fixture and StandardLogging
fixture and unit tests for both of them plus tests for the exiting
Conf fixture.

H305/306 have to be turned off because hacking import rules are broken
and continue to believe that fixtures is a nova module not the
absolute one.

Change-Id: I97fdacdf5a6ad2957b0efa1e21ae084d4eb04ab9
2014-12-09 14:05:45 -05:00
Jenkins e8b085293c Merge "Enable pep8 on ./tools directory" 2014-12-01 16:50:04 +00:00
Sean Dague 16f73c8a43 move the integrated tests into the functional tree
This moves the integrated tests into the functional tree as an initial
seed for the functional tests. It was agreed to as an early step at
the design summit. Work on cleaning these up will happen after the
move.

PYTHON_HASH_SEED=0 is needed because these tests apparently remain
order dependent.

Also remove the use of test.ReplaceModule, which is an untested
mocking system in the nova tree that doesn't seem to reliably
work. Use stubs instead for the time being, as this will ensure
repeatability of the code.

Part of bp:functional-tests-for-nova

Change-Id: I742c487dd7bca9de3e811c545de477367fff112c
2014-11-26 13:17:20 -05:00
Sean Dague 2c2ccdcfc8 dummy patch to let tox functional pass
Tox functional job currently will fail because there are no tests,
which is makes it a little hard to atomically turn on voting with the
test move. To trick the system we can make tox functional always pass,
then change the tox definition to the real thing during the sideways
move.

Part of bp:functional-tests-for-nova

Change-Id: Ic276522851fba6d1d95dd1f3bdde1d48935568a3
2014-11-25 10:45:08 -05:00
Balazs Gibizer 687e8664a2 Enable pep8 on ./tools directory
This patch fixes the pep8 issues of the tool scripts and
configures tox to run pep8 on the tools directory.

Two hacking rules have been modified to ignore the tool directory as both
rules are checking oslo usage which is not critical in case of tools
- N310 use timeutils instead of datetime module
- N324 use jsonutils instead of json module

The tools/xenserver directory is still excluded from pep8 as it contains
scripts that are expected to run on dom0 with python2.4 therefore the
following rules cannot be meaningfully followed
- H231  Python 3.x incompatible 'except x,y:' construct
- H233  Python 3.x incompatible use of print operator

Change-Id: Icfd9e708a2ca1e421676b410e41807b2e630718f
2014-11-25 11:42:02 +01:00
Sean Dague 89cd6a0c49 move all tests to nova/tests/unit
As part of the split of functional and unit tests we need to isolate
the unit tests into a separate directory for having multiple test
targets in a sane way.

Part of bp:functional-tests-for-nova

Change-Id: Id42ba373c1bda6a312b673ab2b489ca56da8c628
2014-11-12 15:31:08 -05:00
Sean Dague 5c8bbaafef Add tox -e functional
Provide a tox -e functional stub, as a place for functional tests to
migrate to. This will allow us to write a zuul test configuration for this
environment.

Part of bp:functional-tests-for-nova

Change-Id: I8a1107beab151f9bf574cfbae1d4dc18400fd74e
2014-11-12 15:31:06 -05:00
Jenkins 70ad74c778 Merge "Drop max-complexity to 47" 2014-11-11 21:20:43 +00:00
Joe Gordon f455cbcbcb Drop max-complexity to 47
Now that we fixed the two worst offenders, drop the mccabe
max-complexity setting in flake8 to 47.

Add note explaining how to generate a list of functions that are too
'complex'.

Change-Id: I44000e9e95c457ae9000c428460b5825d8ad3f92
2014-11-11 09:42:30 -08:00
Davanum Srinivas 06e4919a45 Switch Nova to use oslo.concurrency
Let's switch to the newly released oslo library for the
processutils and lockutils. We use the config fixture(s) to
specify disable_process_locking and lock_path in the CONF
variable of oslo.concurrency library for correctly setting the
flags.

The previous attempt at updating nova to use oslo.concurrency
was reverted as it stopped running any tests. lockutils-wrapper
should have been used in ini/shell scripts
instead of lockutils.py module as the the module is
no longer runnable (__main__ has been removed).  In this
review we use lockutils-wrapper correctly. The test harness
has since been updated to bail out if 0 tests are run as
well for additional insurance.

Change-Id: I14c75ef2196fd08c9465d648e5cd53777bd9c7d1
Co-Authored-By: Nikola Dipanov <ndipanov@redhat.com>
Co-Authored-By: Corey Wright <corey.wright@rackspace.com>
2014-10-30 00:19:14 +00:00
Sean Dague cef1fea688 Revert "Switch Nova to use oslo.concurrency"
This patch made unit tests stop running (always runs 0 unit tests) we
should revert and put a check in place to prevent that from happening
so that we don't regress the rest of Nova trying to figure out the
oslo.concurrency issue.

This reverts commit 382294762b.

Change-Id: I98b04ac2a0ba67ba8af44867799317fdf95b8aff
2014-10-28 08:51:21 -04:00
Jenkins 6a04e1b2c1 Merge "Switch Nova to use oslo.concurrency" 2014-10-28 05:18:57 +00:00
Joe Gordon 053b3ab611 Drop python26 support for Kilo nova
Now that we have stopped running python26 jobs in the gate, remove
python26 from the list of jobs in tox

project-config patch: Ib495467e00e4b6abf2b3c2b9445b51652ba25167

Change-Id: I18262e91c9f5fc2381c6f5b37eb45b5f27aa81db
2014-10-27 10:17:06 -07:00
Davanum Srinivas 382294762b Switch Nova to use oslo.concurrency
Let's switch to the newly released oslo library for
the processutils and lockutils.

Change-Id: Icf7831261322abd0a6fc5439fe09b1d4cb614cb7
2014-10-27 16:56:13 +00:00
Joe Gordon 95681b98f7 Put a cap on our cyclomatic complexity
flake8 has support for cyclomatic complexity (Mccabe) currently our
worst offender has a complexity of 67 (25 is considered very bad). So
set our max-complexity to 68 so we at least don't make things any worse.

This is the first step in bringing this number down to 25 or so.

https://github.com/flintwork/mccabe

Change-Id: I5117ca58ad28888e24c16251aa5e92084ead97ca
2014-10-16 21:04:08 -07:00
Jenkins 05a564dc80 Merge "support TRACE_FAILONLY env variable" 2014-10-03 17:29:26 +00:00
Sean Dague 9c448bfb5f support TRACE_FAILONLY env variable
In order to get similar behavior to the way testr out of the box
works, only displaying failing results, all the user to define
TRACE_FAILONLY environment variable (any value will do). After this
point only failures, and things leaking out of stderr will end up on
the screen.

We also need to remove the suppression of the inline fail dumps for
this to have the impact that you'd expect.

Change-Id: I72911adc8a03450522429c52db661ec0a1bc4678
2014-10-01 15:08:03 -04:00
Sean Dague eb49e0aedb remove scary error message in tox
Found an interesting cantrip in the devstack tox.ini that gets rid of
the scary can't find bash error message at the beginning of test
runs. Reducing non error looking error things make it easier to see
real errors.

Change-Id: I4e1b826626063bf8d5a15531f5768f9ce0eea6a5
2014-10-01 06:25:52 -04:00
Jeremy Stanley fd297c108a Remove unused py33 tox env
It's apparent that Nova is quite a ways from Py3K support, and
developers are not expected to run the py33 tox env. Rather than add
more envs for later Python interpreter versions which will be
equally broken, just remove it for now.

Change-Id: I885e6e8899f771cc52a2bf6282fd7bc1ed3083aa
2014-09-22 13:06:56 +00:00
Jenkins f4c780618c Merge "bring over pretty_tox.sh from tempest" 2014-09-18 13:57:18 +00:00
Jenkins e1e9459888 Merge "Check requirements.txt files for missing (used) requirements" 2014-09-17 03:31:53 +00:00
Sean Dague c805613d90 bring over pretty_tox.sh from tempest
Tempest developed a set of wrappers around testr to print out tests as
they are running through using the subunit stream. This also displays
which workers the various tests are running on. Adapted for nova's
need for loading the locking.

I expect that the needs of nova will diverge this over time,
especially what's displayed during tracing, as such I think it's fine
to just do a transplant and not try to turn this into some external
repo.

Change-Id: Ied1708515fc49f4e18cd8dbb7b2cd821f85e1966
2014-09-16 11:57:20 -04:00
Jenkins 1b683c1771 Merge "Remove exclude coverage regex from coverage job" 2014-09-16 02:44:08 +00:00
Sean Dague a2530ed1e3 delete python bytecode before every test run
Bring over the cleaning line from run_tests.sh for the pyc files to
all the tox runs.

This should eliminate the need to clean -x -i to kill pyc files in
your local directory to get tests to pass.

Closes-Bug: #1368661

Change-Id: Idf3a46d8c95806f2d2ce28ce84ced12b625e53df
2014-09-12 17:35:28 -04:00
Matthew Treinish abf8f1928e Remove exclude coverage regex from coverage job
This commit removes the regex to exclude the coverage extension from
the tox coverage job. The regex was needed for the unit tests on the
coverage extension, (which would mock out coverage) however that
extension has since been removed from nova. So we no longer need to
exclude tests that don't exist anymore.

Change-Id: I45685b1113ecc78eda92f13755ff2274ff517829
2014-09-09 17:53:18 -04:00
Richard Jones 26b1db57ce Check requirements.txt files for missing (used) requirements
Invoke the pip-missing-reqs tool to find packages used by nova but
not explicitly included in its requirements.txt file.

Add simplejson to the requirements to fix the failing check.

Change-Id: Ia90416c613c0acea04f3d4ab4898f550cb702a49
2014-09-09 12:11:07 +10:00
Jenkins 01a56d6436 Merge "Stop depending on sitepackages libvirt-python" 2014-07-28 17:29:15 +00:00
Clark Boylan 4f3e3cd188 Set python hash seed to 0 in tox.ini
New tox (>=1.7.0) sets a random python hash seed by default. This is
generally good for testing because it will help keep projects working
regardless of the hash seed, but nova unittests don't currently pass
with a random hash seed so set it to the python default seed.

This change will allow us to use new tox again and remove the
restriction on tox<=1.6.1 to run unittests.

Redundant setenvs for specific test envs are removed to prevent them
from overriding the PYTHONHASHSEED value.

Note this change will need to be backported to the stable branches to
keep unittests there working with new tox as well.

Change-Id: Ib54364877a251db48c54dfdc43c503281ea1f04a
2014-07-25 13:27:03 -07:00
Clark Boylan 8f505b8526 Stop depending on sitepackages libvirt-python
We can install libvirt-python bindings from pypi now because the libvirt
devs are supporting pypi packages and the version of libvirt we are
testing nova master against is new enough to link against that pypi
package.

Making this switch will better isolate nova test environments as all
dependencies can be installed without any site packages leaking into
virtualenvs. It will also make the dependency on libvirt-python a bit
more explicit.

Change-Id: I2890702869f05a02ad5e2ecb419db06433231b36
2014-07-25 12:36:46 -07:00
Joe Gordon 855fe98ef4 Fix and Gate on E265
pep8 E265 makes sure block comment start with '# '. Fix and gate on this
new rule as it helps improve comment readability.

In the few cases where the comment was just commented out code, remove
the comment.

Change-Id: Iea1c445df8ddc2b6c17a4ab697ad756eef2f91fa
2014-07-24 08:11:00 -04:00
Joe Gordon c03c90ea5d Re-add H803 to flake8 ignore list.
I6c2537dd27c947e36ebf37eb3b5c8a1ab8b026a1 mistakenly removed H803 since
running flake8 had no hits for this test, but H803 is the period in the
commit message which we are explicitly ignoring until the next version
of hacking is released (which will remove this check).

Change-Id: I22860cc61336ef5bf8ce4509fe130160bdf7e45b
2014-07-21 16:56:05 -07:00
Davanum Srinivas e25ca68709 Gate on F402/pep8
rename instances of loop variables to prevent them from shadowing
imports. This strict check was added in hacking 0.9

Change-Id: Ib5e162b85e3c6931f213731c3febd3dd8ba0b4b1
2014-07-21 16:15:57 -04:00
Davanum Srinivas 284e5ac022 Cleanup and gate on hacking E711 and E712 rule
Fix the offending instances of the rule
and removes it from the ignore list in tox.ini
so that we can gate on E711 and E712 rules.

Most violations were in DB queries. Replace as follows:
  False -> sqlalchemy.sql.false()
  None  -> sqlalchemy.sql.null()
  True  -> sqlalchemy.sql.true()

Change-Id: Id84aa04697d1b3c23dc03195113e296c6715379d
2014-07-19 13:07:59 +00:00
Jenkins 8aade96d8f Merge "Use oslo.i18n" 2014-07-19 01:06:23 +00:00
Davanum Srinivas 826aed0ec7 Use oslo.i18n
oslo.i18n provides the i18n functions that were provided by
oslo-incubator's gettextutils module. Some tests that were
using internal details of the library were removed.

Change-Id: I44cfd5552e0dd86af21073419d31622f5fdb28e0
2014-07-18 14:28:09 -04:00
Davanum Srinivas 0550ae806a update ignore list for pep8
Remove H803 as Nova does not run into that issue. Sort
the rest of the items (E129 was out of place).

Change-Id: I6c2537dd27c947e36ebf37eb3b5c8a1ab8b026a1
2014-07-18 07:42:43 -04:00