summaryrefslogtreecommitdiff
path: root/nova/test.py
Commit message (Collapse)AuthorAgeFilesLines
* tests: Use GreenThreadPoolExecutor.shutdown(wait=True)melanie witt2023-05-171-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We are still having some issues in the gate where greenlets from previous tests continue to run while the next test starts, causing false negative failures in unit or functional test jobs. This adds a new fixture that will ensure GreenThreadPoolExecutor.shutdown() is called with wait=True, to wait for greenlets in the pool to finish running before moving on. In local testing, doing this does not appear to adversely affect test run times, which was my primary concern. As a baseline, I ran a subset of functional tests in a loop until failure without the patch and after 11 hours, I got a failure reproducing the bug. With the patch, running the same subset of functional tests in a loop has been running for 24 hours and has not failed yet. Based on this, I think it may be worth trying this out to see if it will help stability of our unit and functional test jobs. And if it ends up impacting test run times or causes other issues, we can revert it. Partial-Bug: #1946339 Change-Id: Ia916310522b007061660172fa4d63d0fde9a55ac
* testing: Reset affinity support global variablesmelanie witt2023-03-021-0/+7
| | | | | | | | | | | | | | | | | | | Ran into this randomly today, if a test sets CONF.scheduler.enabled_filters to a non-default value, the affinity support global variables will be set to False which can affect subsequent test runs that expect the default configuration (affinity filter support enabled). Example error: WARNING [nova.scheduler.utils] Failed to compute_task_build_instances: ServerGroup policy is not supported: ServerGroupAffinityFilter not configured This resets the global variables during base test setup, similar to how other globals are reset. Change-Id: Icbc75b1001c0a609280241f99a780313b244aa9d
* Protect against a deleted node id fileDan Smith2023-02-011-1/+8
| | | | | | | | | | | | | | | | If we are starting up for the first time, we expect to generate and write a node_uuid file if one does not exist. If we are upgrading, we expect to do the same. However, if we are starting up not after an upgrade and not for the first time, a missing compute_id file is an error, and we should abort. Because of the additional check that this adds, which is called from a variety of places that don't have the stable compute node singleton stubbed to make it happy, this mocks the check for any test that does not specifically aim to exercise it. Related to blueprint stable-compute-uuid Change-Id: If83ce14b96e7d84ae38eba9d798754557d5abdfd
* Fixup patch for stable-compute-uuid seriesDan Smith2023-01-301-2/+0
| | | | | | | | Minor cleanups from feedback on earlier patches. Related to blueprint stable-compute-uuid Change-Id: I00505f1df47b46ed36645c781354258e255f0dcc
* Add get_available_node_uuids() to virt driverDan Smith2023-01-201-0/+1
| | | | | | | | | | | | | | | | | This adds a get_available_node_uuids() method to the virt driver interface. This aims to eventually replace the nodename-based interface, but currently provides an implementation that will work for most drivers. Any driver that does not override this method will get the locally-persistent UUID from nova.virt.node. Ironic obviously needs to override this (which is easy), as well as the fake driver because it supports multiple nodes for testing. The libvirt driver overrides it only because we test multiple libvirt driver instances on a single host and we need each instantiation of it to "capture" the UUID we have mocked out at the time it is started. Change-Id: Ibe14d2b223c737d82c217a74bc94e41603271a9d
* Add virt/node module for stable uuidsDan Smith2023-01-201-0/+6
| | | | | | Related to blueprint stable-compute-uuid Change-Id: Ie8897a843fadf325c696b411923f075e237a7342
* Add mock to avoid loading guestfs in unit testmelanie witt2023-01-051-0/+4
| | | | | | | | | | | | | | | | | | | | | | | We recently discovered that when the perfect conditions are present where: * libguestfs-dev/el and guestfs python bindings are installed and * unit tests are not being run in a venv or guestfs python bindings are installed in the tox venv the test will end up loading the guestfs module and try to call the real guestfs and possibly libvirt and fail because of it. Our unit tests shouldn't be loading modules like guestfs, so this adds proper mocking to the test along with a poison fixture that will prevent future accidental imports of such modules. Closes-Bug: #1994913 Change-Id: I676ee1fd33cf053681a07448759c28f0f2ad79d1
* Unify placement client singleton implementationsDan Smith2022-08-181-0/+4
| | | | | | | | | | | | We have many places where we implement singleton behavior for the placement client. This unifies them into a single place and implementation. Not only does this DRY things up, but may cause us to initialize it fewer times and also allows for emitting a common set of error messages about expected failures for better troubleshooting. Change-Id: Iab8a791f64323f996e1d6e6d5a7e7a7c34eb4fb3 Related-Bug: #1846820
* Poison /sys access via various calls in testBalazs Gibizer2022-08-101-0/+1
| | | | | | | | | | | | Unit test should never depend on the file system of the machine it runs on. So this patch injects a poison to various std lib calls to catch these cases. We only selectively poison access to /sys fs as there are legitimate cases to access temp files. When I isolated the poisoned test cases I tried to add a meaningful mocking around the sysfs reads based on the meaning of the test. Change-Id: I66636ebfe627cba8c4470cd84faa78f69249aa05
* Remove double mockingBalazs Gibizer2022-08-021-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | In py310 unittest.mock does not allow to mock the same function twice as the second mocking will fail to autospec the Mock object created by the first mocking. This patch manually fixes the double mocking. Fixed cases: 1) one of the mock was totally unnecessary so it was removed 2) the second mock specialized the behavior of the first generic mock. In this case the second mock is replaced with the configuration of the first mock 3) a test case with two test steps mocked the same function for each step with overlapping mocks. Here the overlap was removed to have the two mock exists independently The get_connection injection in the libvirt functional test needed a further tweak (yeah I know it has many already) to act like a single mock (basically case #2) instead of a temporary re-mocking. Still the globalness of the get_connection mocking warrant the special set / reset logic there. Change-Id: I3998d0d49583806ac1c3ae64f1b1fe343cefd20d
* Use unittest.mock instead of third party mockStephen Finucane2022-08-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that we no longer support py27, we can use the standard library unittest.mock module instead of the third party mock lib. Most of this is autogenerated, as described below, but there is one manual change necessary: nova/tests/functional/regressions/test_bug_1781286.py We need to avoid using 'fixtures.MockPatch' since fixtures is using 'mock' (the library) under the hood and a call to 'mock.patch.stop' found in that test will now "stop" mocks from the wrong library. We have discussed making this configurable but the option proposed isn't that pretty [1] so this is better. The remainder was auto-generated with the following (hacky) script, with one or two manual tweaks after the fact: import glob for path in glob.glob('nova/tests/**/*.py', recursive=True): with open(path) as fh: lines = fh.readlines() if 'import mock\n' not in lines: continue import_group_found = False create_first_party_group = False for num, line in enumerate(lines): line = line.strip() if line.startswith('import ') or line.startswith('from '): tokens = line.split() for lib in ( 'ddt', 'six', 'webob', 'fixtures', 'testtools' 'neutron', 'cinder', 'ironic', 'keystone', 'oslo', ): if lib in tokens[1]: create_first_party_group = True break if create_first_party_group: break import_group_found = True if not import_group_found: continue if line.startswith('import ') or line.startswith('from '): tokens = line.split() if tokens[1] > 'unittest': break elif tokens[1] == 'unittest' and ( len(tokens) == 2 or tokens[4] > 'mock' ): break elif not line: break if create_first_party_group: lines.insert(num, 'from unittest import mock\n\n') else: lines.insert(num, 'from unittest import mock\n') del lines[lines.index('import mock\n')] with open(path, 'w+') as fh: fh.writelines(lines) Note that we cannot remove mock from our requirements files yet due to importing pypowervm unit test code in nova unit tests. This library still uses the mock lib, and since we are importing test code and that lib (correctly) only declares mock in its test-requirements.txt, mock would not otherwise be installed and would cause errors while loading nova unit test code. [1] https://github.com/testing-cabal/fixtures/pull/49 Change-Id: Id5b04cf2f6ca24af8e366d23f15cf0e5cac8e1cc Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* db: Don't pass strings to 'Connection.execute'Stephen Finucane2021-11-121-1/+1
| | | | | | | | | | | | Resolve the following RemovedIn20Warning warning: Passing a string to Connection.execute() is deprecated and will be removed in version 2.0. Use the text() construct, or the Connection.exec_driver_sql() method to invoke a driver-level SQL string. Change-Id: I44d6bf1ebfaf24f00a21389364456bceaae7c4d1 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* Add autopep8 to tox and pre-commitSean Mooney2021-11-081-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | autopep8 is a code formating tool that makes python code pep8 compliant without changing everything. Unlike black it will not radically change all code and the primary change to the existing codebase is adding a new line after class level doc strings. This change adds a new tox autopep8 env to manually run it on your code before you submit a patch, it also adds autopep8 to pre-commit so if you use pre-commit it will do it for you automatically. This change runs autopep8 in diff mode with --exit-code in the pep8 tox env so it will fail if autopep8 would modify your code if run in in-place mode. This allows use to gate on autopep8 not modifying patches that are submited. This will ensure authorship of patches is maintianed. The intent of this change is to save the large amount of time we spend on ensuring style guidlines are followed automatically to make it simpler for both new and old contibutors to work on nova and save time and effort for all involved. Change-Id: Idd618d634cc70ae8d58fab32f322e75bfabefb9d
* Prevent leaked eventlets to send notificationsBalazs Gibizer2021-10-141-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In out functional tests we run nova services as eventlets. Also those services can spawn there own eventlets for RPC or other parallel processing. The test case executor only sees and tracks the main eventlet where the code of the test case is running. When that is finishes the test executor considers the test case to be finished regardless of the other spawned eventlets. This could lead to leaked eventlets that are running in parallel with later test cases. One way that it can cause trouble is via the global variables in nova.rpc module. Those globals are re-initialized for each test case so they are not directly leaking information between test cases. However if a late eventlet calls nova.rpc.get_versioned_notifier() it will get a totally usable FakeVersionedNotifier object regardless of which test case this notifier is belongs to or which test case the eventlet belongs to. This way the late eventlet can send a notification to the currently running test case and therefore can make it fail. The current case we saw is the following: 1) The test case nova.tests.functional.test_servers.ServersTestV219.test_description_errors creates a server but don't wait for it to reach terminal state (ACTIVE / ERROR). This test case finishes quickly but leaks running eventlets in the background waiting for some RPC call to return. 2) As the test case finished the cleanup code deletes the test case specific setup, including the DB. 3) The test executor moves forward and starts running another test case 4) 60 seconds later the leaked eventlet times out waiting for the RPC call to return and tries doing things, but fails as the DB is already gone. Then it tries to report this as an error notification. It calls nova.rpc.get_versioned_notifier() and gets a fresh notifier that is connected to the currently running test case. Then emits the error notification there. 5) The currently running test case also waits for an error notification to be triggered by the currently running test code. But it gets the notification form the late eventlet first. As the content of the notification does not match with the expectations the currently running test case fails. The late eventlet prints a lot of error about the DB being gone making the troubleshooting pretty hard. This patch proposes a way to fix this by marking each eventlet at spawn time with the id of the test case that was directly or indirectly started it. Then when the NotificationFixture gets a notification it compares the test case id stored in the calling eventlet with the id of the test case initialized the NotificationFixture. If the two ids do not match then the fixture ignores the notification and raises an exception to the caller eventlet to make it terminate. Change-Id: I012dcf63306bae624dc4f66aae6c6d96a20d4327 Closes-Bug: #1946339
* db: Unify 'nova.db.api', 'nova.db.sqlalchemy.api'Stephen Finucane2021-08-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | Merge these, removing an unnecessary layer of abstraction, and place them in the new 'nova.db.main' directory. The resulting change is huge, but it's mainly the result of 's/sqlalchemy import api/main import api/' and 's/nova.db.api/nova.db.main.api/' with some necessary cleanup. We also need to rework how we do the blocking of API calls since we no longer have a 'DBAPI' object that we can monkey patch as we were doing before. This is now done via a global variable that is set by the 'main' function of 'nova.cmd.compute'. The main impact of this change is that it's no longer possible to set '[database] use_db_reconnect' and have all APIs automatically wrapped in a DB retry. Seeing as this behavior is experimental, isn't applied to any of the API DB methods (which don't use oslo.db's 'DBAPI' helper), and is used explicitly in what would appear to be the critical cases (via the explicit 'oslo_db.api.wrap_db_retry' decorator), this doesn't seem like a huge loss. Change-Id: Iad2e4da4546b80a016e477577d23accb2606a6e4 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* Make test_archive_task_logs deterministicmelanie witt2021-07-091-1/+4
| | | | | | | | | | | | | | | | | | | | | | The 'nova-manage db archive_deleted_rows --task-log' functional tests involve manipulating time to assert archive behaviors when the --before flag is also used. While timedelta was used, set_time_override was not, so depending on the date the test ran on + the number of days in the current month and next two months, the test could fail. Task log audit periods are one calendar month by default and the compute manager calls last_completed_audit_period() without specifying a unit. This changes the tests to use a time override to ensure predictable behavior with regard to the audit period boundaries. The tests were moved into their own test case classes in order to override the time before services were started, so that the "service up" calculations work as expected. Closes-Bug: #1934519 Change-Id: I9b16a3a849937aba5b90ed1ab9a80b7f0103f673
* Merge "Replace getargspec with getfullargspec"Zuul2021-06-011-3/+3
|\
| * Replace getargspec with getfullargspeclikui2021-05-121-3/+3
| | | | | | | | | | | | | | | | inspect.getargspec() is deprecated since py3 [1] https://docs.python.org/3/library/inspect.html#inspect.getargspec Change-Id: I6fbdf942dd192351e135430997c15ea92e7fb8af
* | tests: Move remaining non-libvirt fixturesStephen Finucane2021-05-121-2/+1
| | | | | | | | | | | | | | | | Move these to the central place. There's a large amount of test damage but it's pretty trivial. Change-Id: If581eb7aa463c9dde13714f34f0f1b41549a7130 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* | tests: Move ConfFixtureStephen Finucane2021-05-121-2/+1
|/ | | | | | | This can go into the 'nova.tests.fixture' module also. Change-Id: I31743a9e813e69f2342bcb148f632c8729ac7000 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* Drop support for SQLite < 3.7Stephen Finucane2021-04-211-9/+0
| | | | | | | | | | | Both Ubuntu 18.04 [1] and CentOS 8 [2] provide sufficiently new versions of SQLite that make this check unnecessary now. [1] https://packages.ubuntu.com/bionic/sqlite3 [2] http://mirror.centos.org/centos/7/os/x86_64/Packages/ Change-Id: I42900037e69f5cc49044dfbcbb27057b67e2056d Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* Reset global wsgi app state in unit testBalazs Gibizer2021-03-241-0/+5
| | | | | | | | | | Since I2bd360dcc6501feea7baf02d4510b282205fc061 there is a global state set during the wsgi_app init making our unit test cases non-deterministic based on the order of them. This patch makes sure that the global state is reset for each test case. Change-Id: Ie2ba746a7697a70fdbc6594f02257f78becfe962 Closes-Bug: #1921098
* Centralize sqlite FK constraint enforcementmelanie witt2021-02-121-0/+18
| | | | | | | | | | | | | There's a TODO in the code to centralize foreign key constraint enforcement for sqlite for unit and functional tests and we're missing enforcement of FK constraints in a couple of test classes that should have it. This resolves the TODO and turns on FK constraint enforcement where it is missing. Do this to enhance testing in preparation for a proposed change to the database archiving logic later in this patch series. Change-Id: Idcf026d020e63e4e6ece1db46e4cdc7b7742b76f
* Remove six.binary_type/integer_types/string_typesTakashi Natsume2020-12-131-3/+2
| | | | | | | | | | | | | | Replace the following items with Python 3 style code. - six.binary_type - six.integer_types - six.string_types Subsequent patches will replace other six usages. Change-Id: Ide65686cf02463045f5c32771ca949802b19636f Implements: blueprint six-removal Signed-off-by: Takashi Natsume <takanattie@gmail.com>
* Remove six.iteritems/itervalues/iterkeysTakashi Natsume2020-11-071-1/+1
| | | | | | | | | | | | | | Replace the following items with Python 3 style code. - six.iteritems - six.itervalues - six.iterkeys Subsequent patches will replace other six usages. Change-Id: Id55de3a105bedcf61bcfc797aabe86d6e75709c8 Implements: blueprint six-removal Signed-off-by: Takashi Natsume <takanattie@gmail.com>
* Remove six.movesTakashi Natsume2020-11-071-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Replace the following items with Python 3 style code. - six.moves.configparser - six.moves.StringIO - six.moves.cStringIO - six.moves.urllib - six.moves.builtins - six.moves.range - six.moves.xmlrpc_client - six.moves.http_client - six.moves.http_cookies - six.moves.queue - six.moves.zip - six.moves.reload_module - six.StringIO - six.BytesIO Subsequent patches will replace other six usages. Change-Id: Ib2c406327fef2fb4868d8050fc476a7d17706e23 Implements: blueprint six-removal Signed-off-by: Takashi Natsume <takanattie@gmail.com>
* Remove six.reraiseTakashi Natsume2020-08-151-1/+1
| | | | | | | | | Replace six.reraise with Python 3 style code. Subsequent patches will replace other six usages. Change-Id: Ib129cb399d1521ad6d18fcf0b8ac9fd793888c81 Implements: blueprint six-removal Signed-off-by: Takashi Natsume <takanattie@gmail.com>
* Remove six.add_metaclassTakashi Natsume2020-08-151-2/+1
| | | | | | | | Replace six.add_metaclass with Python 3 style code. Change-Id: Ifc3f2bcb8fcdd2b555864bd4e22a973a7858c272 Implements: blueprint six-removal Signed-off-by: Takashi Natsume <takanattie@gmail.com>
* Remove six.PY2 and six.PY3Takashi Natsume2020-08-151-5/+1
| | | | | | | | | Remove six.PY2 and six.PY3. Subsequent patches will replace other six usages. Change-Id: Iccce0ab50eee515e533ab36c8e7adc10cb3f7019 Implements: blueprint six-removal Signed-off-by: Takashi Natsume <takanattie@gmail.com>
* virt: Add 'context', drop 'network_info' parameters for 'unrescue'Stephen Finucane2020-07-081-2/+3
| | | | | | | | | | | | | | | | | | | | In a future change, we'll want access to this so that it's possible to retrieve vTPM data during the unrescue operation. While we're here, it seems nothing is using the 'network_info' argument anymore, presumably since the demise of nova-network, and this can and should be dropped. Resolve both issues in one go, adding the 'context' parameter, dropping the 'network_info' one, and updating the various callers and tests for same. Maintainers of out-of-tree drivers have been notified of these changes [1]. [1] http://lists.openstack.org/pipermail/openstack-discuss/2020-July/015824.html Part of blueprint add-emulated-virtual-tpm Change-Id: Id5e4b0f26d5a2a93db6a7d96555a2cff29d9a2cf Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* Merge "Remove hooks"Zuul2020-06-211-6/+0
|\
| * Remove hooksStephen Finucane2020-05-271-6/+0
| | | | | | | | | | | | | | | | | | | | This extension point was deprecated in 13.0.0 (Mitaka) as it was unmaintainable. Now, over four years later, it's finally time to remove them. A combination of notifications, versioned or otherwise, and dynamic vendordata should be used instead. Change-Id: Idb9a0c06d8abdb158bcee5be12c35dcb67257e60 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* | Poison netifaces.interfaces() in testsEric Fried2020-05-111-0/+2
|/ | | | | | | | | | | | | | While reviewing [1] it was noted that we've probably been invoking the real netifaces.interfaces() in some test paths. This isn't good, so introduce a fixture that blows up any test that does that. (NB: during development, the netifaces.interfaces()-specific poison fixture evolved into a generic fixture that can be extended in the future to poison anything in a similar fashion.) [1] https://review.opendev.org/#/c/671471/ Change-Id: I1fea14d5be10bb4e884f52e0ae8be722519ddd3f
* func tests: move _run_periodics() into base classArtom Lifshitz2020-03-241-4/+36
| | | | | | | | | | | | | | | | | | | | | | | There are two almost identical implementations of the _run_periodics() helper - and a third one would have joined them in a subsequent patch, if not for this patch. This patch moves the _run_periodics() to the base test class. In addition, _run_periodics() depends on the self.computes dict used for compute service tracking. The method that populates that dict, _start_compute(), is therefore also moved to the base class. This enables some light refactoring of existing tests that need either the _run_periodics() helper, or the compute service tracking. In addition, a needless override of _start_compute() in test_aggregates that provided no added value is removed. This is done to avoid any potential confusion around _start_compute()'s role. Change-Id: I36dd64dc272ea1743995b3b696323a9431666489 safdasdf Change-Id: I33d8ac0a1cae0b2d275a21287d5e44c008a68122
* Ensures that COMPUTE_RESOURCE_SEMAPHORE usage is fairBalazs Gibizer2020-03-161-0/+33
| | | | | | | | | This patch poisons the synchronized decorator in the unit test to prevent adding you synchronized methods without the fair=True flag. Change-Id: I739025dacbcaa0f7adbe612c064f979bf6390880 Related-Bug: #1864122
* nova-net: Make the security group API a moduleStephen Finucane2019-11-291-3/+0
| | | | | | | | | | | | | We're wrestling with multiple imports for this thing and have introduced a cache to avoid having to load the thing repeatedly. However, Python already has a way to ensure this doesn't happen: the use of a module. Given that we don't have any state, we can straight up drop the class and just call functions directly. Along the way, we drop the 'ensure_default' function, which is a no-op for neutron and switch all the mocks over, where necessary. Change-Id: Ia8dbe8ba61ec6d1b8498918a53a103a6eff4d488 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* nova-net: Kill itStephen Finucane2020-01-141-63/+6
| | | | | | | | | | | Finish the job by removing all the now-unused modules. This also allows us to - wait for it - kill mox at long last. It's a great day in the parish. Partial-Implements: blueprint remove-nova-network-ussuri Partial-Implements: blueprint mox-removal-ussuri Change-Id: Ia33ec2604b2fc2d3b6830b596cac669cc3ad6c96
* Cache security group driverMatt Riedemann2019-12-031-1/+1
| | | | | | | | | | | | | | | Change I0932c652fb455fe10239215a93e183ea947234e3 from Mitaka was a performance improvement to cache the loaded security group driver since the API calls get_openstack_security_group_driver a lot. That performance fix was regressed with change Ia4a8d9954bf456253101b936f8b4ff513aaa73b2 in Newton. This caches the loaded security group driver once again. This is pretty similar to the original change except simpler since we don't have to account for the skip_policy_check flag. Change-Id: Icacc763f19db6dc90e72af32e17d480775ad5edf Closes-Bug: #1825018
* Merge "test cleanup: Make base TestCase subclass oslotest"Zuul2019-11-231-15/+7
|\
| * test cleanup: Make base TestCase subclass oslotestEric Fried2019-11-221-15/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | oslotest.base.BaseTestCase already sets up many of the fixtures we want from nova.test.TestCase, so inherit from it and remove those setups. Note that oslotest has a logger fixture, but nova's is significantly different, so we preserve the latter. Fortunately, oslotest provides a granny switch to disable its logger fixture -- the OS_LOG_CAPTURE env var -- so we explicitly do that, even though it's not on in our tox.ini, in case we accidentally run in an env where that's enabled. Change-Id: Ic61c3db824ec811336423bd956f2f2f03e02d21e
* | Merge "test cleanup: Use oslotest's CaptureOutput fixture"Zuul2019-11-221-2/+2
|\ \ | |/
| * test cleanup: Use oslotest's CaptureOutput fixtureEric Fried2019-09-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Nova had its own copy of oslotest's CaptureOutput fixture called OutputStreamCapture (probably predating the oslotest one, actually). DRY it up. A future change should be able to remove references to this fixture from nova.test.TestCase by inheriting from oslotest.base.BaseTestCase instead of testtools.TestCase. But we may or may not want to do the same for TestOSAPIFixture since that would pull in fixtures we don't care about (timeout and tempfile/tempdir). Change-Id: I18a5d621c9e414452852d4aeb0379be0d30af5df
* | Merge "test cleanup: Use oslotest's Timeout fixture"Zuul2019-11-221-3/+4
|\ \ | |/
| * test cleanup: Use oslotest's Timeout fixtureEric Fried2019-09-271-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Nova had its own copy of oslotest's Timeout fixture (probably predating that one, actually). DRY it up. A future change should be able to remove references to this fixture from nova.test.TestCase by inheriting from oslotest.base.BaseTestCase instead of testtools.TestCase. But we may or may not want to do the same for NovaMigrationsCheckers subclasses (TestNovaMigrations*) since that would pull in fixtures we don't care about (output and tempfile/tempdir). Change-Id: I813a80fae306334abb653e6d3603eabe2d2332bf
* | Merge "test cleanup: Remove skipIf test decorator"Zuul2019-11-221-32/+0
|\ \ | |/
| * test cleanup: Remove skipIf test decoratorEric Fried2019-09-271-32/+0
| | | | | | | | | | | | | | | | | | We use this from time to time to skip tests for various reasons. It's not currently in use. But if it's needed, we should use testtools.testcase.skipIf, which does the same thing, rather than carrying our own copy around. Change-Id: I422fe0bc4d761a374daaf0bf1043d5b8fb41d449
* | Only allow one scheduler service in testsEric Fried2019-10-301-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There have been two recent issues [1][2] caused by starting multiple instances of the same service in tests. This can cause races when the services' (shared) state conflicts. With this patch, the nexus of nova service starting, nova.test.TestCase.start_service, is instrumented to keep track of how many of each service we are running. If we try to run the scheduler service more than once, we fail. We could probably do the same thing for conductor, though that's less important (for now) because conductor is stateless (for now). [1] https://bugs.launchpad.net/nova/+bug/1844174 [2] https://review.opendev.org/#/c/681059/ (not a nova service, but same class of problem) Change-Id: I56d3cb17260dad8b88f03c0a7b9688efb3258d6f
* | Add TODO note for mox removalTakashi NATSUME2019-09-271-0/+8
|/ | | | | | | | | | | MoxStubout fixture in nova/test.py and filtering warnings in nova/tests/fixtures.py will be removed after removing unit tests related to nova-network. So add notes for them. Change-Id: I20e51647e66467ebedde01e914484cd02fea6ef3 Implements: blueprint mox-removal-ussuri
* Tests: autospecs all the mock.patch usagesTakashi NATSUME2019-08-191-0/+7
| | | | | | | | | | | | | | By default, mock.patch's autospec argument is None, meaning that there's no signature checking for the patched methods and functions. oslotest.mock_fixture.patch_mock_module fixes a few issues within mock.patch functions, as well as setting autospec=True by default, unless otherwise specified or new_callable, create, spec arguments are passed in. Co-Authored-By: Claudiu Belu <cbelu@cloudbasesolutions.com> Change-Id: I4484e63c97bd1cdde3d88855eabe7545784f365e Closes-Bug: #1735588
* Allow assertXmlEqual() to pass options to matchers.XMLMatchesAdam Spiers2019-08-151-2/+2
| | | | | | | | | | | | | | | | | | | matchers.XMLMatches supports three options: - allow_mixed_nodes - skip_empty_text_nodes - skip_values However these are not accessible when using the matcher via assertXmlEqual(). So extend the latter with an *options dictionary to allow options to be passed through. This will be used by another commit in the SEV series in the near future which needs the allow_mixed_nodes option to be enabled to compare XML fragments with elements in different orders. blueprint: amd-sev-libvirt-support Change-Id: I31c60771891c3a2eb06fbc780ba2d369465498ec