summaryrefslogtreecommitdiff
path: root/ironic/tests/base.py
Commit message (Collapse)AuthorAgeFilesLines
* Remove support for creating and loading classic driversDmitry Tantsur2018-07-021-2/+0
| | | | | | | | | | | | | | | | * removes any bits related to loading classic drivers from the drivers factory code * removes exceptions that only happen when classic drivers can be loaded * removes the BaseDriver, moves the useful functionality to the BareDriver class * /v1/drivers/?type=classic now always returns an empty list * removes the migration updating classic drivers to hardware types The documentation will be updated separately. Change-Id: I8ee58dfade87ae2a2544c5dcc27702c069f5089d
* Completely stop using the "fake" classic driver in unit testsDmitry Tantsur2018-06-061-4/+20
| | | | | | | | | | | This change makes "fake-hardware" the default driver for test nodes and makes enabled_drivers empty in the base test class. Note that some unit test coverage for classic drivers is lost because of this change. It is fine, because the classic drivers themselves are deprecated and will be removed soon. Change-Id: I06acb5aed24ef952db3f9e6987e5a90c81e96401
* Remove excessive usage of mock_the_extension_manager in unit tests - part 2Dmitry Tantsur2018-05-241-0/+7
| | | | | | | | | Also fixes incorrect oneview tests that apparently used to be hidden by that. Similarly, insufficient mocking in the PXE boot interface tests was fixed. Now only test_manager uses mock_the_extension_manager. Change-Id: Iaef9555337919706cd165adbbb2e1be9322f80b7
* Resolve pep8 E402 errors and no longer ignore E402John L. Villalovos2018-04-101-3/+2
| | | | | | | | | | | | | | | | Fix the pep8 E402 (Module level import not at top of file) errors. For the Alembic files move the definitions of 'revision' and 'down_revision' below the imports. This is now done in Alembic [1] For other files fix as needed by moving the imports or lines before the imports. In a few cases add a "# noqa E402" to whitelist the issue. [1] https://bitbucket.org/zzzeek/alembic/commits/dc2aae0374b76ccab8494be6e103d84089bc449b Change-Id: I48c96d5da0cb747b3ca3fceea9b4ffa85a9ebe22
* Merge "Fix issue with double mocking of utils.execute functions"Zuul2018-03-071-16/+46
|\
| * Fix issue with double mocking of utils.execute functionsJohn L. Villalovos2018-02-231-16/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An issue was discovered if we mock an already mock-ed function. This was happening in our execute() detection code. Change it to not use a mock and instead a function. Fix a failing unit test. This was due to the fact that using 'autospec=True' causes assert_not_called() to not work. This is a known bug in the mock code[1]. Add test cases to ensure it works as expected. [1] https://bugs.python.org/issue28380 Change-Id: Ifa18df61d17750f9a37118a2ac8aaf13005a5159
* | tox.ini: flake8: Remove I202 from ignore listJohn L. Villalovos2018-02-261-1/+1
|/ | | | | | | | | | | | | | | Remove I202 (Additional newline in a group of imports) from the ignore list. I202 is a check from the flake8-import-order [1] package. There was a note to remove this check once the tempest plugin was removed. As the tempest plugin has been removed we can now remove the exclusion of this check. Update files which failed this test. [1] https://github.com/PyCQA/flake8-import-order Change-Id: I6018d5a90174b3d4b6b8d8e05cee1c1104ccfde9
* Add rescue related methods to network interfaceShivanand Tendulker2018-01-221-0/+2
| | | | | | | | | | | | | | | | | Adds methods `add_rescuing_network` and `remove_rescuing_network` to add/remove rescuing network to `network` interface. These methods are not added to `flat` network interface. The 'flat' network uses same network for tenant and provisioning. It makes sense to use the same for rescuing as well; as opposed to a separate network like we have for cleaning. Change-Id: I8f4123bfe7d293e8ff6f3bfc2f25445a39c94c73 Related-bug: #1526449 Co-Authored-By: Jay Faulkner <jay@jvf.cc> Co-Authored-By: Mario Villaplana <mario.villaplana@gmail.com> Co-Authored-By: Jesse J. Cook <jesse.j.cook@member.fsf.org> Co-Authored-By: Aparna <aparnavtce@gmail.com> Co-Authored-By: Shivanand Tendulker <stendulker@gmail.com>
* Remove unused IronicObjectIndirectionAPI from ironic-apiRuby Loo2017-11-021-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many moons ago, we thought that we would implement rolling upgrades using a similar model to nova. This included adding an instance of an IronicObjectIndirectionAPI to the ironic-api service. What it was meant to do was for ironic-api to invoke it if it received an IronicObject that it didn't know what to do with (because it didn't recognize that object's version). That API would have invoked the conductor service, asking it to generate a version of that object which ironic-api would understood. To use this mechanism, the assumption is that the conductor is the gateway to the DB. This mechanism doesn't work for ironic for a few reasons: - ironic API reads (and occasionally) writes directly to the database. We don't want to change it to get access to the DB via the conductor all the time, since for e.g. we don't want to slow down the conductor - Nova's rolling upgrade process is to initially take down all their conductor services (which handles their DB interactions) at the same time, while their other services are still running. Unless ironic changes to have a similar model, we cannot take down all the conductor services at the same time if ironic is to provide services during a rolling upgrade. Thus, this patch removes the unused IronicObjectIndirectionAPI from the ironic-api service. Note that the IronicObjectIndrectionAPI class itself (in ironic/objects/indirection.py) was left, in case things ever change in the future. (And because removing that would involve touching most, if not all, of the files in the objects/ subdirectory.) Change-Id: I1aa264a8619105939968c0b8128b358badf00210 Closes-Bug: #1586320
* Use oslotest for base test casePavlo Shchelokovskyy2017-10-051-23/+3
| | | | | | | oslotest already implements all the std, timeout and tempdirs mangling we do in our base test case, so let's just re-use it. Change-Id: Ibfbe772572f0ed80e19a85a70cfe2679a324c2b4
* Prevent tests from using utils.execute()John L. Villalovos2017-05-171-0/+24
| | | | | | | | | | | | | This change modifies the base test class so that it mocks out utils.execute() and similar functions and forces an exception if it gets called. If utils.execute() is mocked by the test case then it will work. What this does is prevent un-mocked access to utils.execute() / processutils.execute() and similar subprocess library functions. Inspired by Julian Edwards' patch to ironic-python-agent Change-Id: Id3a8e6c5fce44a1f5f6f936d2a35e0660adbf086
* Remove usage of parameter enforce_typeChangBo Guo(gcb)2017-05-051-1/+0
| | | | | | | | | | | | Oslo.config deprecated parameter enforce_type and change its default value to True in Ifa552de0a994e40388cbc9f7dbaa55700ca276b0. Remove the usage of it to avoid DeprecationWarning: "Using the 'enforce_type' argument is deprecated in version '4.0' and will be removed in version '5.0': The argument enforce_type has changed its default value to True and then will be removed completely." Related--Bug: #1517839 Change-Id: Ie3267df7e086e01eae6679cf01b3d9aa9b7a26cd
* Start enforcing config variables type in testsDmitry Tantsur2017-04-241-0/+1
| | | | | | | Otherwise we will miss changes that will break us once new oslo.config is out. Also fix already merged tests for Redfish. Change-Id: Iffd4c64c495fc3666527b41911a5a07601db7c9b
* Support defining and loading hardware typesDmitry Tantsur2016-12-141-3/+8
| | | | | | | | | | | | | | | | | This change introduces a new module ironic.drivers.hardware_types with AbstractHardwareType class. It also updates driver_factory code to support loading hardware types and creating dynamic drivers. Interfaces validation code extended to cover hardware types. This change also introduces the FakeHardware class for testing. It is special-cased to bypass compatibility validation completely. No hardware types are loaded on conductor start up yet, as hardware types still do not participate in the hash ring. Thus, nodes with hardware types cannot still be created via HTTP API. Change-Id: If8e3342baf818a9e37aa82b43aec71898d48c29b Partial-Bug: #1524745
* Support names for {cleaning,provisioning}_networkDmitry Tantsur2016-12-021-2/+2
| | | | | | | | | | | | | | | Names are easier to use for humans, so let's allow them. The actual name -> UUID convertion happens during validation and its result is cached for each interface instance. This change will allow recreating a network without changing Ironic configuration or setting a network name in advance (e.g. by an installer). Note that when names are used, an administrator is responsible for ensuring that no other networks have the same name (names are not unique in Neutron). Change-Id: I9905bdc3f778310ba191b2bed6eb11bad11a2846 Closes-Bug: #1614938
* Move interface validation from API to conductor sideDmitry Tantsur2016-12-011-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change moves the check on network interface to driver_factory.py and moves node creation from API to conductor side. A new exception InterfaceNotFoundInEntrypoint (similar to DriverNotFoundInEntrypoint) was introduced for the case when invalid interface is requested either during creation or during updating. The current approach already duplicates the check in two places. With the driver composition in place it will not be quite possible: different conductors may have different interfaces enabled as long as no hardware type ends up with different interfaces on different conductors. Also when calculating the defaults, we'll need access to a real hardware type object, which may not be possible on API side. Also there is a demand for driver-side validations on creation (e.g. detecting duplicating IPMI addresses), which also requires creation to happen on conductor side. Such features, however, are out of scope for this change. A side effect of this change is that objects.Node.network_interface is now defined the same way as other interfaces (i.e. nullable string). Also added more clean ups to base unit test class, as otherwise newly added tests randomly break other tests. Change-Id: Id1da20ccd5bb50e61a82449ef3d2ffce91822d71 Partial-Bug: #1524745
* Add power state change notificationsMario Villaplana2016-10-171-0/+17
| | | | | | | | | | | | | | | | | | | | This adds optional notifications emitted when ironic changes a node's power state or when ironic detects a change in a node's power state. These notifications can be consumed by any external service listening to the message bus to perform functions like tracking node power state changes over time or automatically responding to anomalous power states. The event_types of the new notifications are: * baremetal.node.power_set.{start,end,error} * baremetal.node.power_state_corrected.success This also adds a new NodePayload class for notification payloads related to nodes. Change-Id: I82702e7f959d666bb02b59d1fc53ab50b519cb74 Closes-Bug: 1526408
* Add notification base classes and docsMario Villaplana2016-08-231-0/+6
| | | | | | | | This adds base classes and documentation for creating notifications. Partial-Bug: 1526408 Change-Id: Ib1b1fa819e8ff0b93afacd0b3de6e6762168e230
* Centralize config options - [DEFAULT]Ramamani Yeleswarapu2016-07-151-4/+1
| | | | | | | Nova style refactor of config options in Ironic. Change-Id: I6baebf1bbc829238441ddd1399f6487fad33a15e Partial-Bug: #1561100
* Add 'neutron' network interfaceVasyl Saienko2016-07-131-1/+3
| | | | | | | | | This patch adds a 'neutron' network interface. This interface supports separate networks for provisioning and for cleaning of nodes. Partial-bug: #1526403 Co-Authored-By: Vladyslav Drok <vdrok@mirantis.com> Change-Id: Ia3442ab3536a1a8d8839b24dbfc640b818450350
* Add network interface to base driver classVasyl Saienko2016-07-121-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change also introduces two network interfaces: * flat: Copies current neutron DHCP provider logic to work with cleaning ports; * noop: noop interface. The default value of the network_interface is None, meaning that the node will be using the default network interface. The default network interface is determined the following way: * if [DEFAULT]default_network_interface configuration option is set (the default for it is None), the specified interface becomes the default for all nodes; * if it is not set, 'flat' interface will be used if the deployment currently uses 'neutron' DHCP provider, otherwise 'noop' interface will be used. create_cleaning_ports and delete_cleaning_ports methods of the DHCP providers are still being called in case of out-of-tree DHCP providers, but this possibility will be removed completely in the next release. If the DHCP provider logic is rewritten into a custom network interface, please remove those methods from the provider, so that network interface is called instead. Partial-bug: #1526403 Co-Authored-By: Om Kumar <om.kumar@hp.com> Co-Authored-By: Vasyl Saienko <vsaienko@mirantis.com> Co-Authored-By: Sivaramakrishna Garimella <sivaramakrishna.garimella@hp.com> Co-Authored-By: Vladyslav Drok <vdrok@mirantis.com> Co-Authored-By: Zhenguo Niu <Niu.ZGlinux@gmail.com> Change-Id: I0c26582b6b6e9d32650ff3e2b9a3269c3c2d5454
* Remove unnecessary calls to dict.keys()Edan David2016-06-271-1/+1
| | | | | | | | | It is preferred not to use the keys method when not needed because the keys() method of dict objects behaves differently under Python 2 and Python 3 and in most cases using keys is inefficient. Change-Id: Iee5b2822933ec1b91e847e47c71682cadc26967f
* Remove verbose optionJim Rollenhagen2016-05-171-1/+1
| | | | | | | | | This was deprecated in Liberty in oslo.log, and was recently removed. Remove it here so we're not completely broken when this releases. http://git.openstack.org/cgit/openstack/oslo.log/commit/?id=7c671ea77f4d7701d0def9a9e17b6c49310ca438 Change-Id: I8143cc1dfc52decef245b8b23740766dcf3456ad
* Adopt Ironic's own contextLin Tan2016-04-011-1/+1
| | | | | | | | | | | | | Adopt Ironic's own context in Ironic and add tests. Refactor ensure_thread_contain_context to Ironic's own context class, this will be more generical and not bind to TaskManager anymore. Explicitly call ensure_thread_contain_context() in Inspector driver for inspect hardware action. Change-Id: Ic2bb16a2deb02054b4fca795d431c965e30a246f Closes-Bug: #1560264
* Import host option in base test moduleYuriy Zveryanskyy2016-02-221-0/+1
| | | | | | | Import of this option fix problems with local unit tests in Ironic Staging Drivers project. Change-Id: I4a155ae734939b3917d35575591acecebdd78a6b
* Use oslo_config.fixture in unit testsPavlo Shchelokovskyy2016-02-151-9/+21
| | | | | | | | | | It provides cleaner per-tests config objects, with more options to configure the fixture. Also, allow overriding config fixture in particular test cases if needed. Change-Id: I288c5d661a4918feac15a169eaaa521fd2e69284
* Move ironic.tests.unit.base to ironic.tests.baseJohn L. Villalovos2015-10-221-0/+147
| | | | | | | | We will use the base.py file for both unit and functional testing, so move it under ironic/tests/base.py Change-Id: Ifc36d61be60c820dd8e5ee0f9b9dadb52d8b480a Partial-Bug: #1491670
* Prepare for functional testingJohn L. Villalovos2015-09-281-147/+0
| | | | | | | | | | | | | | | Prepare for functional testing by creating two new directories: * ironic/tests/unit * ironic/tests/functional Move all files currently in ironic/tests/* to ironic/tests/unit/ Update imports from 'ironic.tests.YYY' to 'ironic.tests.unit.YYY' Fix any PEP8 issues due to longer lines Partial-Bug: #1491670 Change-Id: I1166f20adf8c84b2042b62e348926502a4851e08
* Replace metaclass registry with explicit opt-in registry from osloLin Tan2015-09-161-2/+3
| | | | | | | | | | | | | | | Previously, objects are registered through metaclass, which is complicate to understand. So oslo.versionedobjects move this to ObjectRegistry class. Each object is registered with a decorator. This also includes registering some test-only classes, which use the register_if(False) scheme to do the object-building step, but without actually inserting the class into the registry. This prevents those test classes from ever being registered at runtime by accident (and thus send/receive-able over RPC). Co-Author: Dan Smith <dms@danplanet.com> Partial-Bug: #1461239 Change-Id: Ice4d47185b888d1b33e761d7d1437bb20abb3d93
* Reset tempdir config option after NestedTempfile fixture appliedVladyslav Drok2015-08-281-0/+2
| | | | | | | | | | | | When running unit tests, tempdir config option is set to tempfile.gettempdir() by default in ironic/common/utils, which happens before fixtures.NestedTempfile() is applied, which causes it to be a system tempdir. Reset its value after fixture is applied so that nested directory would be used as 'root' directory for temporary files. Change-Id: I1e717c6e7b421ff212f3ef3d30577d24362e1c44 Closes-bug: #1489796
* Enforce flake8 E123/6/7/8 in ironicSam Betts2015-06-041-1/+1
| | | | | | | | | | | | | | | | | This patch enforces the rules E123, E126, E127, and E128 in the ironic code base: E123 - closing bracket does not match indentation of opening bracket’s line E126 - continuation line over-indented for hanging indent E127 - continuation line over-indented for visual indent E128 - continuation line under-indented for visual indent This fixes any parts of the current code which fails these rules and removes these rules from the tox.ini flake8 ignore list. Change-Id: Ia96582b5e9abc088d6c1694afc93c59be4a4065c Closes-Bug: 1421522
* Run tests in py34 environmentVictor Sergeyev2015-05-061-1/+1
| | | | | | | | | | | | | | | | | A lot of fixes to be compatible with python 3: - fix encoding/decoding errors - fix issues with comparison - use `reload`, `reraise`, ext. modules from six - use items() instead of iteritems() - add a new file with py3 specific test requirements - drop passing the arbitrary arguments to object.__new__ method. See bug [1] for more details. - add a workaround to bug in `mock` library - add py33 and py34 test environment to tox.ini [1] http://bugs.python.org/issue1683368 Change-Id: I90936cb6b6eaaf4b5e1ce67732caec3c8bdc1cc2
* Use oslo_log libGhe Rivero2015-05-051-2/+3
| | | | | | Module 'log' from oslo-incubator was removed after release of oslo_log library. Change-Id: I4261083dae076cea66c42ad16eb82a5faaeb1a65
* Use oslo_context packageGhe Rivero2015-03-121-1/+1
| | | | | | | Use graduated library oslo_context and remove any reference to the context module from oslo.incubator Change-Id: I590f033c4b164cea9022cd951ded393b7406381e
* Move oslo.config references to oslo_configJim Rollenhagen2015-02-021-1/+1
| | | | | | | The oslo team is recommending changing to non-namespaced references. Implements: blueprint drop-namespace-packages Change-Id: I45462d9d49552044ad990f22bd6e6c5b37cf0649
* Enable H307 PEP8 checkDavid Shrewsbury2014-10-131-5/+3
| | | | | | | | | | | | | | | | | Fixes files with the PEP8 error: H307 like imports should be grouped together and enables the check in tox.ini. For the modified files, made sure the import order matches the template as described in: http://docs.openstack.org/developer/hacking/#import-order-template This order is currently: stdlib, 3rd-party, and project imports. Change-Id: I4538356c207535b778da1273aadcf3b4a7b20383
* Move database fixture to a separate test caseVladyslav Drok2014-10-081-74/+2
| | | | | | | | | | | This change moves database fixture from ironic.tests.base.TestCase to ironic.tests.db.base.DbTestCase and adds dbapi field there. Also it adds ironic admin context to ironic.tests.base.TestCase, as context may be used without db fixture. Closes-bug: #1376285 Change-Id: I008e44da315767afb6282000a01f0b39698f9768
* Add HashRingManager to wrap hash ring singletonGregory Haynes2014-09-291-0/+2
| | | | | | | | | | | | | | Currently, the API service creates a new hash ring on every request. Instead of that, we should cache the hash ring object -- but we should also expose a way to refresh it when necessary. This method will also be used by the ConductorManager to cache and refresh the hash ring when conductors join / leave the cluster. This patch preserves the existing API behavior by resetting the hash ring on every request. This should be addressed in a subsequent patch. Co-Authored-By: Devananda van der Veen <devananda.vdv@gmail.com> Change-Id: Ib7ab55452499d1e1c362e4cd127f1e6e38106d6c
* Use oslo.db libraryVictor Sergeyev2014-07-171-5/+0
| | | | | | | | | | | oslo.db library has been graduated from oslo-incubator, so now we can use it instead of ironic.openstack.common.db.* code. Co-Authored-By: Ghe Rivero <ghe.rivero@hp.com> Implements: blueprint oslo.db Change-Id: I250050a7dbd8735ba3af954223b54eabae793f59
* Merge "Sync common db code from Oslo"Jenkins2014-03-061-7/+8
|\
| * Sync common db code from OsloVictor Sergeyev2014-02-261-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This sync contains commit - ce69e7f Don't store engine instances in oslo.db - which removed global engine from oslo.db code. So, added code for work with sqla engines and sessions to Ironic - get_engine() and get_session() functions in ironic.db.sqlalchemy.api module. Also this remove database slave connection and tpool features, because they was removed from oslo code. Latest oslo.db commit - 7959826af1f36a4bbc4c466d0d1e0b9efd468649 Change-Id: I14c3b823a8b975d5cd097778f3514cfb1abe2e10
* | Remove extraneous vim configuration comments for ironicHe Yongli2014-02-261-2/+0
|/ | | | | | | | | | | | Remove vim setting: comment - # vim: tabstop=4 shiftwidth=4 softtabstop=4 at the top of source code files, except for files in openstack/common. Change-Id: Ie80f76f08e27b7f5f747227c4cca8d79ad98bec6 Partial-Bug: #1229324
* Merge "Improve help strings"Jenkins2014-02-251-1/+1
|\
| * Improve help stringsAndreas Jaeger2014-02-211-1/+1
| | | | | | | | | | | | | | | | | | Better follow oslo.config style guide for consistent help strings: * Capitalize help strings * End help strings with "." * Improve wording and capitalization. Change-Id: Ib647bd85e636b16f1d1a040bb9ba04cd319a8826
* | Merge "Removes use of timeutils.set_time_override"Jenkins2014-02-251-10/+0
|\ \ | |/ |/|
| * Removes use of timeutils.set_time_overrideMikhail Durnosvistov2014-02-131-10/+0
| | | | | | | | | | | | | | | | | | | | The set_time_override function in timeutils was written as a helper function to mock utcnow for unittests before 'mock' was generally used. Now that we have mock and fixture, we no longer need to use it. Change-Id: Ibcf6d4abee4a52bc459fc322e6a5268d39d70450 Partial-Bug: #1266962
* | alembic with initial migration and testsDima Shulyak2014-01-271-5/+14
|/ | | | | | | | | | | | | | | | | All sqlalchemy migrations and code associated with them was removed including tests Added all necessery alembic code to expose alembic specific features: like revision and stamp Added initial migration for alembic, that is fully in sync with models including: uniques, indexes and columns params Refactored test_versions to use alembic as migration api Refactored BaseTestCase and Database fixture to use alembic as migration api Change-Id: I8a91704d21ccea1b8135b9d724df5856ac21108c
* Removes stubs from unit testslinggao2013-10-161-4/+0
| | | | | | | | | self.stubs in TestCase and BaseTestCase classes use moxstubout module which uses mox. OpenStack is moving to python 3 which will not support mox. This patch removes the use of self.stubs for all the unit test cases. Change-Id: I0e5aa50edcbb1913c5143bb93efea965f5d5ebfb
* Use fixture from OsloYuriy Zveryanskyy2013-07-301-18/+2
| | | | | | | | | Replace MoxStubout class from tests/base.py with the one from Oslo. bug 1199535 Change-Id: I55051bc03f7810529d6c8737adf56eadcb6c1c05
* Import serialization and nesting from Nova ObjectsDevananda van der Veen2013-07-181-0/+13
| | | | | | | | | | | | This change mostly merges the following commits from Nova: e91c3d141c957485dcb66c73e84b41b775e4268b f1c4b8e5f34eb6b5e70da6711750dcf05cea8c0a 65f6c536fecd3c788b2e0dfa9d66ecd24ca550e1 92a3190128547403dc603e5a40e377c6eb0c8025 68cb4d53385821c3ffdc40c299a77d11a7f98f27 Change-Id: I0a16f45674f5d14f458e2bb490d909a9086ea8b4