Commit Graph

19 Commits

Author SHA1 Message Date
Anton Arefiev 3fe42b53fd SQLAlchemy 2.0 Support
Primarily remove the workaround added in
Ia6d512ff2ae417bab938cb095fbb0884d195010a which added
continued use of autocommit, which is incompatible with
SQLAlchemy 2.0.

Also set the environment for unit tests to report compatability
warnings, although it appears none are being reported at this time.

Also cuts out the db upgrade cruft to only use the online database
migration code through oslo_db's enginefacade, which has the smarts
to handle online or offline migrations.

And then, retools unit/functional test data storage to utlize sqlite,
and in that re-tooled the queries to prevent locking conditions
which could exist with queries, and some additional refactoring/cleanup.

Also, don't mock and test time.sleep().

Additionally, it looks like we have discovered the root cause of the
memory/connection leakage issue which has been observed, due to the
way lists of nodes are processed/returned.

This change was based upon the work in
I506da42a9891a245831f325e34bec92e0a3f33f0 which is included in
this commit as the entire database structure and interaction
has been modified for ironic-inspector.

Co-Authored-By: aarefiev <aarefiev@mirantis.com>
Story: 2009727
Task: 44132
Change-Id: Ic88eb9dec5fddc924a72d9a23c17a304954ebf46
2022-12-15 09:28:55 -08:00
Dmitry Tantsur 493cee3531 Fix compatibility with oslo.db 12.1.0
oslo.db 12.1.0 has changed the default value for the 'autocommit'
parameter of 'LegacyEngineFacade' from 'True' to 'False'. This is a
necessary step to ensure compatibility with SQLAlchemy 2.0. However, we
are currently relying on the autocommit behavior and need changes to
explicitly manage sessions. Until that happens, we need to override the
default.

Change-Id: Ia6d512ff2ae417bab938cb095fbb0884d195010a
Co-authored-by: Stephen Finucane <stephenfin@redhat.com>
2022-09-08 15:04:56 +01:00
Iury Gregory Melo Ferreira 4bc75327aa Fix sqlalchemy
Inplicit execution was deprecated in SQLAlhcemy, version 1.4 doesn't
support and we need to convert to explicit[1]

[1] https://docs.sqlalchemy.org/en/14/changelog/migration_20.html#implicit-and-connectionless-execution-bound-metadata-removed

Change-Id: I4a780567fb92c32cf55c54e2e134df9456e36165
2021-09-14 11:30:48 +02:00
Dmitry Tantsur cee5922674 Hacking: enforce usage of autospec=True in tests
Using autospec ensures that mocked functions are called with correct
arguments, so it's highly desired to have it.

Change-Id: I9c8395adf852495d2ef6db732d727990e8abd5d7
2020-04-28 12:27:41 +02:00
Sean McGinnis a9f7f67de5
Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: Ic67f09a223ae2d0cb460771a10a4122307afa05b
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-04-18 16:15:28 -05:00
Zuul 0b38536d1c Merge "Use oslo_db.sqlalchemy.test_fixtures" 2019-07-08 14:57:35 +00:00
Kaifeng Wang 59a4c64670 Move dbsync to the correct path
command line script should be placed in the cmd directory.

Change-Id: Ifc3a9c81b0c61d8b5c9d9f4009164ec3c91ce042
2019-07-05 15:44:34 +08:00
Kaifeng Wang 9d1c6a4e3b Use oslo_db.sqlalchemy.test_fixtures
Inheriting classes from oslo_db.tests.sqlalchemy.test_base was
deprecated, this patch switches test base to oslotest and use new
fixtures from test_fixtures of oslo.db. Unused functions were removed.

https://review.opendev.org/#/c/545874 is referenced to make this
change.

Change-Id: I4db805f6fceae6ffd530e69ba0a0f0c40b5b7979
2019-07-04 13:16:45 +08:00
Julia Kreger f3fd8e9a23 Comment out race prone sqlite db model sync test
The nature of the unit tests with sqlite means that it is
easy to get into a race condition with the tests where one
worker thread makes changes to the database that essentially
causes another test to fail.

Since we don't run these sorts of sync tests in ironic for
similar reasons, I've commented out the test that is causing
numerous false failures due to race conditions.

Change-Id: Ia4927fd8eca671414bd77f3d0ef188ba94cc0e2d
2019-07-02 06:01:53 -07:00
Kaifeng Wang a8c1d06bd0 introspection data backend: implements db
Configurable introspection data storage backend [1] is
proposed to provide flexible extension of introspection
data storage instead of the single support of Swift storage
backend.

This patch adds database support for using ironic-inspector
database as the storage backend.

A table named ``introspection_data`` is created to serve as
the storage for introspected data.

[1] http://specs.openstack.org/openstack/ironic-inspector-specs/specs/configurable-introspection-data-backends.html

Change-Id: I8b29b7b86d90823d29b921ebf64acddbcd2d8d0d
Story: 1726713
Task: 11373
2018-12-04 10:54:32 +08:00
Dmitry Tantsur e7c3218f71 Add manage_boot parameter to introspection API
Adds a new node field "manage_boot" to store this value. When it is set
to False, neither boot device nor power state are touched for this node.
Instead, we expect a 3rd party to handle them.

We still manage the PXE filter because the node may need DHCP.

Change-Id: Id3585bd32138a069dfcfc0ab04ee4f5f10f0a5ea
Story: #1528920
Task: #11338
2018-06-25 12:09:17 +02:00
Anton Arefiev fcec378594 Use new oslo db EngineFacade
Legacy EngineFacade was deprecated a while ago, using new
EngineFacade system is the recommended way to work with
db engine and session.

The new system has a lot of notable changes[1]:

 * Thread-safe initialization of EngineFacade;
 * Declarative reader/writer transactions separation;
 * Transaction scope defined by developer-specified context.

[1] http://specs.openstack.org/openstack/oslo-specs/specs/kilo/make-enginefacade-a-facade.html

Closes-Bug: #1475182
Change-Id: Ia03f35a1f3b22b2eda74263e319469cf2391e7b5
2017-06-15 14:25:55 +03:00
Annie Lezil c06a9a7f24 Remove translation of log messages Part-1
The i18n team has decided not to translate the logs because it seems
like it not very useful.

This are the files as of now do not have merge conflicts.

Change-Id: I082f6302f120a8c0c81482b73be301e83fe3a3a8
Partial-Bug: #1674374
2017-03-24 21:45:04 +00:00
dparalen 0ce5cdb7c8 Find a node by multiple attributes
This patch modifies current attributes matching from a single
name-value->node hit to a best-match score.

Also using an UUID as the attributes table primary key to allow exposing
attributes in API later (bug 1525231).

Change-Id: I205e31652b21b9e030b9530149e533b29c52a387
Closes-Bug: 1651719
Partial-Bug: 1525231
2017-02-10 17:24:27 +01:00
Anton Arefiev 500623f989 Fix updating rows in d00d6e3f38c4 migration
Add `where` clause to timestamp update, otherwise existing nodes
will contain timestamp of the last node.

Change-Id: I6a729522e2d077ecf84e48fedb0bf92c16cde838
Closes-Bug: #1662504
2017-02-08 14:57:49 +02:00
Anton Arefiev 71099c9248 Change (started|finished)_at column type
Db column started_at and finished_at are defined as float type, but
float time doesn't fit into default db Float size. This change migrates
columns type to DateTime.

Closes-Bug: 1658975
Change-Id: I13bbb3c9a3e6e8bc744473437a378453ebc81318
2017-01-25 09:23:00 +00:00
dparalen 3ddc0615e5 Introducing node introspection state management
Currently, state of a node introspection isn't kept in the database.
This change introduces:

* a new database column to keep the node introspection state
* an automaton to manage the node introspection state
* a decorator to declare a function performing an introspection state
  transition
* a version_id column is added, to enhance database consistency, that
  is consulted whenever node_info is committed

This change is part of the HA_Inspector effort[1]

[1] https://specs.openstack.org/openstack/ironic-inspector-specs/specs/HA_inspector.html

Closes-Bug: #1618835
Partial-Bug: #1525218
Change-Id: I18cb45f0d1194414715ccbe826d8a95610ec718d
2016-12-15 00:20:27 +01:00
Luong Anh Tuan 375661ee23 Change asserts with more specific assert methods.
This patch replaces assertTrue(isinstance(a, b))
by native assert function assertIsInstance/assertNotIsInstance.

Change-Id: Ia3e34167a1c454fde1b28079c1742b99e1d40ff1
2016-08-31 11:52:48 +00:00
Anton Arefiev 30ae1e72f1 Move unit tests to "unit" directory
This refoctor is needed for tempest test work as tempest tests
will placed in test dir. So move unit tests to separate directory
"unit" under test.

Change-Id: Ic99df6111ef30947148a9e38b9435a54f3d37064
2016-04-05 11:15:29 +03:00