34 Commits

Author SHA1 Message Date
Daniel P. Berrange
848ea5ff01 Add hacking test to block cross-virt driver code usage
The baremetal driver has been accessing some libvirt driver
private classes and config variables. Any code that is intended
to be shared across virt drivers should be in a common package
instead. Add a hacking file to enforce this for imports and
config options so that no further problems like this are made
in the future.

NB, this skips verification of the baremetal driver until
bugs 1261826 and 1261827 are fixed, or the baremetal driver is
removed, whichever comes first.

Change-Id: Ifbfe597795795a847830f9bd937dc459cd37d118
Closes-Bug: #1261842
2014-02-04 18:01:11 +00:00
liu-sheng
74f953a1d7 Remove vi modelines
We don't need to have the vi modelines in each source file,
it can be set in a user's vimrc if required.

Also a check is added to hacking to detect if they are re-added.

Change-Id: I347307a5145b2760c69085b6ca850d6a9137ffc6
Closes-Bug: #1229324
2014-02-03 14:19:44 +00:00
Keshava Bharadwaj
113b321eae Updates OpenStack Style Commandments link
The current link in the HACKING file is broken. This references the
correct location for contributors to view.

Change-Id: I3cd4841035400d09a3e3e3369bb3a2a8c4bdee30
2013-10-16 21:52:11 +05:30
Roman Podolyaka
2e83be17d1 Use timeutils.utcnow() throughout the code
timeutils.utcnow() should be used instead of direct calls to
datetime.datetime.utcnow() to make it easy to override its return
value in tests.

Add a hacking rule to prevent regressions.

Fixes bug 1200141.

Change-Id: I170dbd7c9093bd627e2a0d5984b7ad1bf105c8d5
2013-07-19 16:08:54 +03:00
Devananda van der Veen
f2b4419b9f Add HACKING check for db session param
Add a HACKING check to enforce that public db/api and db/sqlalchemy/api
methods to not accept a 'session' parameter.

This check is initially disabled, since it is failing ~24 times right
now, but will be enabled once bp/db-session-cleanup is complete.

Change-Id: Ib89eea58555032dd142d4e21e62d66e2726f0d06
2013-07-02 03:11:24 -07:00
Joe Gordon
958336e494 Clean up and make HACKING.rst DRYer
Reference the OpenStack hacking guide in HACKING.rst and remove
duplicated entries. Add new section for nova specific rules.

Change-Id: I704a49a0675acf1870953c76eba4978a1c4490eb
2013-07-01 15:48:46 +02:00
Jenkins
53f62b33ca Merge "Add notes about how doc generation works." 2013-06-13 02:33:10 +00:00
Thomas Bechtold
3100abbd9d Replace openstack-common with oslo in HACKING.rst
Change-Id: I8c6426983ec374e903c64108b990e5d4550e3fcc
2013-06-07 11:13:51 +02:00
Monty Taylor
c067e2dc13 Add notes about how doc generation works.
Change-Id: I562c743798aeae5e49bd2f96944c3cacd776a53d
2013-06-02 07:48:02 -04:00
Dirk Mueller
bf68a9592d Improve Python 3.x compatibility
Mechanical translation of the deprecated
except x,y: construct with except x as y:
The latter works with any Python >= 2.6.
Add Hacking check.

Change-Id: I845829d97d379c1cd9b3a77e7e5786586f263b64
2013-06-01 09:57:31 +02:00
Steven Dake
4ac268a4b6 docs should indicate proper git commit limit
The nova gate should recommend 50 characters or less for a git commit
but actually enforce 72 characters.

This patch changes the hacking.rst docs to indicate the actual limit
is 72 characters rather then 50 characters.

Change-Id: I47f1f1f1007f5744bf1fef419df7e033803b4a53
Fixes: Bug #1144840
2013-03-04 13:23:45 -07:00
Vishvananda Ishaya
7ca39a6039 Fix broken logging imports.
This fixes all of the files incorrectly importing logging directly
and removes the workaround in hacking.py that was due to improper
from nova.openstack.common.log import logging statements.

Change-Id: Icfc25dc148c4a7b5fa7f6a7b609cd6c3d94efee1
2013-02-19 21:16:32 -08:00
Attila Fazekas
5dd5625d97 Module import style checking changes
* Implementing the * import detection (it is disabled for now)
* New style relative import testing based on syntax rules
* Old style relative import testing based on module search
* Inspection based solution replaced by PYTHONPATH search
  in order to avoid module compile and initialization steps
  (code execution) in a syntax checking phase.

This solution is faster and safer, but does not able to recognize
modules added dynamically to the module scope.

Change-Id: Ifc871f4fdbcd4a9a736170ceb4475f4f2cbe66bc
2013-02-13 17:05:09 +01:00
Monty Taylor
b7714e82fd Update docs about testing.
Add an entry to the HACKING file about testr. While in there, noticed a
reference to the now-defunct nova/testing dir. Fixed that, moved the testing
README into nova/tests and remove the nova/testing dir.

Change-Id: Ibf6fb82658ba73eee9123fa53b340d0b72afb292
2013-02-11 19:04:43 -08:00
Zhongyue Luo
896295844a Update HACKING.rst per recent changes
Added "is not" usage with examples
* https://review.openstack.org/#/c/20865/

Fixed "not in" usage description
* https://review.openstack.org/#/c/20875/

Fixed some "not X in Y" corner cases.

Change-Id: I7534ef73e6fd525fd8f4bee594a4b37524699c08
2013-02-04 11:12:25 +08:00
Zhongyue Luo
8485129704 Fixes 'not in' operator usage
Change-Id: I1e26a8fcb9fa564308e63c11a72aaa55119e4eee
2013-01-31 15:06:25 +08:00
Sean Dague
6556b8650f don't allow crs in the code
triggered by this slipping into quantum, now that we have more windows
developers we should ensure that \r\n doesn't land in the code as
a line ending. This check prevents it.

Change-Id: I0a82be0e74915d3c3c25203db110d279580c148b
2013-01-16 18:41:54 -05:00
Kurt Taylor
ebfa418e58 Changed 'OpenStack, LLC' message to 'OpenStack Foundation'
Change-Id: Iffad63690d2d7565c651ff3faec4443d0ed471c3
2013-01-07 14:41:18 -05:00
Dan Smith
9471282626 Ban db import from nova/virt
This makes hacking.py complain if someone adds something like:

  from nova import db

into any of the files in nova/virt/* (aside from the fake.py file).
It also removes the rest of the dangling db imports that are no
longer needed.

Yay!

Change-Id: Iba3d53b87e65e33a55f8e5033b5d1d33b28d12f7
2012-11-12 12:37:33 -08:00
Rick Harris
701549ce0d hacking: Add driver prefix recommendation.
Prefixing the commit message's first line with the driver makes it
easier for reviewers, at a glance, to find reviews that relate to their
area of expertise as well as improving the overall readability of the
git history.

Change-Id: I376d2cdb5dc344717fb7749a80e33ee88603e68c
2012-08-29 18:48:43 +00:00
Joe Gordon
b0392d3017 OpenStack capitalization added to HACKING.rst
Along with capitalization fixes to comments in code

Change-Id: I72ddc582001f80d954ca5a121903c689f40d08d1
2012-08-17 15:59:32 -05:00
Joe Gordon
47a1bbe311 Add a 50 char git title limit test to hacking.
* add N802 to hacking.py

Change-Id: I8262531b4b3f8f3a1a2a37679904cf4864cae7b6
2012-08-08 14:53:38 -07:00
Daniel P. Berrange
7047d854f1 Add a link from HACKING to wiki GitCommitMessages page
The HACKING file contains a short example of an effective
commit message. For reasons for space, it cannot describe
the rationale behind this example. It also does not have
space to describe how to split up a patch into a series
of commits. Add a link from the HACKING file to the wiki

   http://wiki.openstack.org/GitCommitMessages

where further information can be found

Change-Id: I34d44485486b623b11743106f09d5ef631d35888
2012-07-30 11:08:03 +01:00
Brian Waldon
211328fb50 Expand HACKING with commit message guidelines
Add a 'Commit Messages' section to HACKING describing how a commit
message should be formed.

Change-Id: I29b69022dfbdac09523eaa5cef3fc1a4550a7c5f
2012-07-02 19:36:48 -07:00
Zhongyue Luo
61c5597a09 Backslash continuation removal (Nova folsom-2)
Fixes bug #938588

Backslash continuations removal for scripts in bin/, plugin/, and etc.

Change-Id: Idd17048b6e8db6e939946968e011e68da8585b8d
2012-05-31 11:26:37 +08: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
Yuriy Taraday
f7a6c58d92 HACKING fixes, sqlalchemy fix.
Add exceptions to hacking.py make sqlalchemy stuff legal and prevent
clutter.

Change-Id: I44b100b4c0c4dfcec81beea7aba2d8598d5a08d0
2012-04-09 18:00:40 +04:00
Andrew Bogott
d1409adb0c Reordered the alphabet.
Just putting this out there... I'm pretty sure that

   import nova.flags

comes after

   from nova.endpoint import cloud

Unless I'm totally misunderstanding how this is supposed to work,
which is likely.

Change-Id: I51096ab25dbca42d73a593872b83b25f2c451210
2012-03-23 16:30:01 -05:00
Rick Harris
66e152f718 Clarify HACKING's shadow built-in guidance.
Change-Id: Icf38d3ec3254e83d2289b7b17966ec44d9757b8c
2012-03-21 21:18:46 +00:00
Johannes Erdfelt
fb7d1fb825 Clear created attributes when tearing down tests
unittest will keep each test case around after completion pinning any
objects references by attributes on the test case. This can bloat
the memory used during a full test suite run to the point where
the test suite will require much more memory than running all of
the services does. On systems witout lots of memory, test suite
failures will occur as test cases cannot fork to execute programs.

Clearing out __dict__ of any attributes that don't start with a _
(since some are needed by unittest itself) reduces memory
significantly. This does require the super class tearDown to be
called last in some cases however.

Change-Id: I0e660b6c2a77c5613c5a523ba0a64c3d7f6dd128
2012-03-07 15:52:40 +00:00
Johannes Erdfelt
8813ab185d assertRaises(Exception, ...) considered harmful
Expecting that Exception is raised can end up passing an a test when an
unexpected error occurs. For instance, errors in the unit test itself
can be masked:

https://review.openstack.org/4848
https://review.openstack.org/4873
https://review.openstack.org/4874

Change a variety of unit tests to expect a more specific exception so
we don't run into false positive tests in the future.

Change-Id: Ibc0c63b1f6b5574a3ce93d9f02c9d1ff5ac4a8b0
2012-03-04 17:22:36 +00:00
Mark McLoughlin
259d3e356b Update cfg from openstack-common
Use openstack-common's update.py script to pull in some recent changes:

 * Add the Mapping interface to cfg.ConfigOpts
 * Add support to cfg for disabling interspersed args

Make use of both of these in nova/flags.py.

Add some dire warnings to HACKING about directly modifying the copy of
openstack-common code. I'm confident they won't be ignored :-)

Change-Id: I7ef75d18922c0bbb8844453b48cad0418034bc11
2012-02-07 21:35:30 +00:00
Kevin L. Mitchell
35e98d55db Update HACKING.rst.
Removes the requirement for a trailing blank line in multiline
docstrings, just before the closing '"""'.  This blank line is not
needed anymore, as the editors it was recommended for no longer
have the problem that this blank line was working around.

Change-Id: I4e532231f1d99e9f5048cbfcc791a4328fb1e8f5
2012-01-05 10:21:57 -06:00
Duncan McGreggor
f845891184 First steps towards consolidating testing infrastructure
This commit begins to implement blueprint consolidate-testing-infrastructure by
adding a 'testing' subpackage and moving some modules into it.

Change-Id: I04bf860bc386bd2016e7dbc5a6f6ef7379a855bb
2011-12-06 09:37:57 -08:00