Commit Graph

34 Commits (6abb88befe2914040e3307b0bc5dfd13683db8b2)

Author SHA1 Message Date
Dan Smith 06a8518697 Fix up ec2 tests for flavors on instances
Change-Id: I5c5526a970e68bc067449cea2ac271233cf60970
8 years ago
Davanum Srinivas 2233675941 Remove openstack/common/versionutils module
Since versionutils has graduated, switch to the
is_compatible in oslo_utils.versionutils.py

Depends-On: I1c8fbe857fa7d30d7c74cd7b0e187cc9a2305882
Change-Id: Id0e483c662231f678bddff7ddf77cdb0b0e1a5db
8 years ago
Jenkins 41806d5cbd Merge "ec2: clean up in test_cinder_cloud" 8 years ago
Jenkins 4cf6ef6819 Merge "improve speed of some ec2 keypair tests" 8 years ago
Chris Friesen 70ba3314cf improve speed of some ec2 keypair tests
test_create_key_pair_quota_limit is one of nova's slowest tests,
because it creates 11 cryptographic keypairs.

Similarly, test_create_key_pair is slow because it creates 7 keypairs.

Neither test actually cares that the keypairs are cryptographically
secure, so mock out the actual generation of the keypairs.

Change-Id: Id4034e9e50b04f17f68b555074fc5b4ffb3a82d7
8 years ago
Victor Stinner b259659a22 Use six.moves.range for Python 3
The function xrange() was renamed to range() in Python 3.

Use "from six.moves import range" to get xrange() on Python 2 and range() on
Python 3 as the name "range", and replace "xrange()" with "range()".

The import is omitted for small ranges (1024 items or less).

This patch was generated by the following tool (revision 0c1d096b3903)
with the "xrange" operation:
https://bitbucket.org/haypo/misc/src/tip/python/sixer.py

Manual change:

* Replace range(n) with list(range(n)) in a loop of
  nova/virt/libvirt/driver.py which uses list.pop()

Blueprint nova-python3
Change-Id: Iceda35cace04cc8ddc6adbd59df4613b22b39793
8 years ago
Victor Stinner ccff53d521 Fix raise syntax for Python 3
The syntax "raise a, b, c" and "raise a, b" are invalid in Python 3.

To be compatible with Python 2 and Python 3, this change:

* Replace "raise exc[0], exc[1], exc[2]" with "six.reraise(*exc)"
* Replace "raise exc_type, exc_value, exc_tb" with
  "six.reraise(exc_type, exc_value, exc_tb)"
* Replace "raise exc, msg" with "raise exc(msg)"

This patch was generated by the sixer tool version 0.2 with the "raise"
operation:
https://pypi.python.org/pypi/sixer

Manual changes:

* Ignore changes on comments

Blueprint nova-python3
Change-Id: I9e75321776f7734604fb1b524684065e25510a03
8 years ago
Sergey Nikitin a6d036d199 Removed twice declared variables
Co-Author: Pavel Kholkin <pkholkin@mirantis.com>

Change-Id: If58247371bbc10b9694594dd5f01446f7e5b5921
8 years ago
Timofey Durakov bb6a7bda2a Fixed test to work with random PYTHONHASHSEED
to compare objects, that contains nested collections new method
assertJsonEqual was used. Its usage allows not to rely on constant
order of nested collections elements.

new method
assertJsonEqual was used
Partial-Bug: #1348818

Change-Id: I0857d3793fb7fca7c5fde3b87dc187088cf965ac
8 years ago
EdLeafe b798f7c711 Add the instance update calls from Compute
Now that the Scheduler has RPC calls to receive updates from compute
whenever a compute node's instances change significantly, we need to
add calls to compute to send those updates.

DocImpact
We add a new CONF option 'scheduler_instance_sync_interval'. This
option is an integer representing the interval (in seconds) that the
compute node waits between sending a sync message to the Scheduler. It
defaults to 120 (2 minutes). Of course, if the CONF option
'scheduler_tracks_instance_changes' is False, the sync calls will not
be made. If an operator notices in the logs that out-of-sync
situations are not very common, this value can be increased to lower
the number of RPC messages being sent. Likewise, if sync issues turn
out to be a problem, this can be lowered to check more frequently.

Partially-Implements: blueprint isolate-scheduler-db
(https://blueprints.launchpad.net/nova/+spec/isolate-scheduler-db)

Change-Id: I5e93ec949e2fa0e29c52beb20201696caad85776
8 years ago
Sean Dague c943cbbc40 ensure DatabaseFixture removes db on cleanup
The DatabaseFixture was previously just ensuring that tests which used
it had a clean database when they started. It did not ensure there was
no working database around when it wasn't being used, so tests which
leaked into the database might pass even if they were listed as a
NoDBTest, because there was an in memory test db from a prior run.

This adds a cleanup path to the fixture which blows away the db at the
end of the test (which itself is tested). There were 46 tests which
failed when we got this isolation correct, and this changes all those
test classes containing those tests to require a db. Many of these
could have narrower fixes, but this returns us to an isolated state.

Change-Id: Id0480035d8e615ae602da9737cd2c94bc7967067
Closes-Bug: #1431519
Closes-Bug: #1431551
8 years ago
Eli Qiao d5e10543a6 ec2: clean up in test_cinder_cloud
_fake_bdm_get() is never been called in this unit
test case. remove it.

Change-Id: I2f4646f0938f92882850f294a97114ecbc920b20
8 years ago
Mike Durnosvistov 92074e0fde Make unit tests inherit from test.NoDBTestCase
This patch changes, where it's posible, tests-package
to using test.NoDBTestCase saving test case running time.

Co-Authored-By: yuntongjin <yuntongjin@gmail.com>
Change-Id: I95945f0bf23c9ef963a4b8634ac4ed6236d97ac7
8 years ago
Davanum Srinivas a412e038dd Switch to uuidutils from oslo_utils library
Get rid of our copy of uuidutils.py from oslo-incubator

Change-Id: Idca3581475bcd4a04ce8d3420a1b7763db15b390
8 years ago
Davanum Srinivas 97d63d8745 Use oslo.log
Convert the use of the incubated version of the log module
to the new oslo.log library.

Sync oslo-incubator modules to update their imports as well.

Co-Authored-By: Doug Hellmann <doug@doughellmann.com>
Change-Id: Ic4932e3f58191869c30bd07a010a6e9fdcb2a12c
8 years ago
Matthew Booth 5cbe247e21 Fix DB access by FormatMappingTestCase
Change I682a377d769312e8f37f874aa4548665b3b52ed3 made this test
inherit from NoDBTestCase. However, this test does access the db if
ec2utils.get_int_id_from_snapshot_uuid() can't return a value from its
memo cache. That is, it was only passing due to fortunate test
ordering which populated this cache in a previous test. If you ran the
test isolated, it failed.

This change mocks ec2utils.id_to_ec2_snap_id to return expected values
without touching the db.

Change-Id: I9e44f93dba5d56bf8c3dd3fda28a9b54eb95507f
8 years ago
Jenkins ce9a5b74fc Merge "Typos fixed" 8 years ago
Davanum Srinivas af2d6c9576 Switch to using oslo_* instead of oslo.*
The oslo team is recommending everyone to switch to the
non-namespaced versions of libraries. Updating the hacking
rule to include a check to prevent oslo.* import from
creeping back in.

This commit includes:
- using oslo_utils instead of oslo.utils
- using oslo_serialization instead of oslo.serialization
- using oslo_db instead of oslo.db
- using oslo_i18n instead of oslo.i18n
- using oslo_middleware instead of oslo.middleware
- using oslo_config instead of oslo.config
- using oslo_messaging instead of "from oslo import messaging"
- using oslo_vmware instead of oslo.vmware

Change-Id: I3e2eb147b321ce3e928817b62abcb7d023c5f13f
8 years ago
sarvesh-ranjan 9a6ee67268 Typos fixed
Change-Id: I2ac91358c91b6c5a487ebabe010f0de26daf7d0c
8 years ago
Hans Lindgren 30dde3a2e1 Make ec2/cloud.py use get_instance_availability_zone() helper
Commit 488fcb4ad3 added a helper
for getting the AZ for a instance. This patch makes use of that
helper method.

This also removes the now unused get_availability_zone_by_host()
method from ec2utils and adds a reset_cache() call to the class
setup of CloudTestCase in test_cloud.py to reset the cache now
used between tests.

Change-Id: I2dd6a54fcc7cefe17816d0fb2875d8da0ec57eba
8 years ago
Jenkins b1674e2ea6 Merge "Fix EC2 volume attachment state at attaching stage." 8 years ago
Jenkins efe19fab90 Merge "Added hacking rule for assertTrue/False(A in B)" 9 years ago
Jenkins 68e417f1b1 Merge "ec2: Change FormatMappingTestCase to NoDBTestCase" 9 years ago
Daniel P. Berrange 5e20018fbd remove pylint source code annotations
Since pylint testing has been removed, there is little need to
keep the source code annotations for it. If anyone wishes to
re-add pylint later, they'll have to audit all the 10's of
1000's of pylint warnings and decide which to skip. So removing
the ~20 existing annotations is no real burden.

Change-Id: Ib48a81cdf4653a0b8c5f84e2614f54419272b731
9 years ago
Sergey Nikitin b6d30549c6 Added hacking rule for assertTrue/False(A in B)
The following replacements were done in tests to have
clearer messages in case of failure:
- assertTrue(a in b) with assertIn(a, b)
- assertTrue(a not in b) with assertNotIn(a, b)
- assertFalse(a in b) with assertNotIn(a, b)

The error message would now be like:
   'abc' not in ['a', 'b', 'c']
rather than:
   'False is not True'.

Change-Id: I92d039731f17b731d302c35fb619300078b8a638
9 years ago
Matt Riedemann b06d665cf7 ec2: Change FormatMappingTestCase to NoDBTestCase
The test doesn't hit the database at all so make it
a NoDBTestCase.

As far as I can tell this is the last ec2 API unit test
class that isn't a trivial convert to NoDBTestCase, all
the rest require some mocking of the objects or DB API
layers to convert them to NoDBTestCase, which I plan to
work on in later patches.

Change-Id: I682a377d769312e8f37f874aa4548665b3b52ed3
9 years ago
Jenkins 8c3271cbfc Merge "Stop neutron.api relying on base neutron package" 9 years ago
Jenkins 041963a10d Merge "Check for floating IP pool in nova-network" 9 years ago
Jamie Lennox 4bab641e9a Stop neutron.api relying on base neutron package
There is a weird namespacing issue happening here where the
nova.network.neutronv2.api package is relying on nova.network.neutronv2.
This is backwards from standard design and results in strange sharing
patterns when trying to do clean up.

Change-Id: I5e890c7b72c398e9625e590994d8c2afb9ce8897
9 years ago
melanie witt cff14b3763 replace httplib.HTTPSConnection in EC2KeystoneAuth
httplib.HTTPSConnection is known to not verify SSL certificates
in Python 2.x. This change replaces use of httplib.HTTPSConnection
with the requests module. It imports config settings related to SSL
verification: ssl.key_file, ssl.cert_file, and ssl.ca_file. It also
adds one config setting: keystone_ec2_insecure. By default, SSL
verification is on, but can be disabled by setting:

keystone_ec2_insecure=true

This patch is based on the keystone middleware ec2 token patch:

https://review.openstack.org/#/c/76476

SecurityImpact
DocImpact
Closes-Bug: #1373992

Change-Id: I8e46d41164e9478b820cad569ba82f25de244620
9 years ago
Thang Pham b13be2cd56 Check for floating IP pool in nova-network
There are no checks in nova-network to see if a specified
floating IP pool exists or not before attempting to allocate
an IP address. If a pool does not exist, nova throws an
unrelated error - 'No more floating ips available'. The
following patch adds a check for the existence of the IP pool
and throws a FloatingIpPoolNotFound if it is not found.

Change-Id: I72cb8dd044f7ac094287bad7df9167b8e77a4b5b
Related-Bug: #1355623
9 years ago
Davanum Srinivas f9c96e1d35 Switch to moxstubout and mockpatch from oslotest
The fixtures in nova/openstack/common will be removed as
they have been removed from oslo-incubator. We should use
the fixtures from oslotest.

Note that oslotest uses mox3 instead of mox and some of the
tests were failing as a result which have been fixed in this
review. Only the failing tests have been fixed, so you will
see some tests use a mix of mock and mox3 as a result.

Based on feedback from Nova core, all existing references
to 'import mox' have been switched over to mox3 as well.

Change-Id: Ifa9dbb6f9bb1a358d815ae80cf928b65d5dcf5bd
9 years ago
Feodor Tersin c1f9ab8d3d Fix EC2 volume attachment state at attaching stage.
While volume is still attaching/detaching, AWS reports 'attaching'/
'detaching' states in the volume attachment info and instance bdm.
But Nova EC2 reports None, 'attached', or 'detached' states.

This fix set 'attaching'/'detaching' states in output results when
it's possible and while corresponding process is still active.

Change-Id: I61ef5afb2c3dea2a931dbf18a8a428460ce9cc2e
Closes-Bug: #1355285
9 years ago
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
9 years ago