Commit Graph

21 Commits

Author SHA1 Message Date
Mike Bayer 0ce2857d0f db: update migrations to use SQLA 2.0 patterns
All tests in test_migration.py pass with either SQLAlchemy 1.4
or SQLAlchemy 2.0 installed.

Change-Id: Ie8831c04b7b4515deea27b1ceb472d07cda91ca0
2024-04-03 19:26:23 -04:00
Takashi Kajinami 696f9ea8a2 Drop reference to WalkVersionsMixin from oslo.db
The WalkVersionsMixin class was already removed from oslo.db, because
of removal of sqlalchemy-migrate support.

Change-Id: I952e0aed8705fd4fc0b89f6ee34f31da1b30c656
2024-02-26 18:50:27 +09:00
Goutham Pacha Ravi 51a0f20f76 [CI] Bump timeout for the migrations test case
We frequently face slow nodes on the CI, and tests
are timing out because new migrations were added
in this release and the test will likely need more
time on slow nodes.

Change-Id: I41fb3936cd302d958371e2b86dd2f32cab4d612a
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
2023-02-22 11:15:54 -08:00
Stephen Finucane 46f47a3f95 tests: Remove use of 'oslo_db.sqlalchemy.test_base'
The various test cases and mixins in 'oslo_db.sqlalchemy.test_base' have
been deprecated since oslo.db 4.34.0 (March 2018). Remove use of these.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I67eff8c9733500813435cde2dbda28a3c4a3ccf3
2021-07-28 18:07:56 +01:00
Goutham Pacha Ravi 598223985a Use unittest.mock instead of third party lib
mock was adopted into standard python
in version 3.3 [1]. Since manila no longer
supports python2.7, we can use the inbuilt
mock package rather than the third party
lib.

Fix some issues with imports that weren't
following our import conventions of grouping
imports [3]

Add a hacking test to ensure we don't regress
on this.

[1] https://docs.python.org/3/library/unittest.mock.html
[2] http://lists.openstack.org/pipermail/openstack-discuss/2020-March/013281.html
[3] https://docs.openstack.org/hacking/latest/user/hacking.html#imports

Co-Authored-By: Sean McGinnis <sean.mcginnis@gmail.com>
Change-Id: If857a49fbf526983e712282a25d7e8bef5093533
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
2020-04-17 16:24:27 -07:00
Goutham Pacha Ravi fdefb0e7bd [CI] Bump timeout for the migrations test case
We face slow nodes on the CI, and tests are timing
out with a sqllite backend in the gate.

Change-Id: I284b48facf633f54aa5a7ec024a1662a1d164daf
2019-05-17 10:47:13 -07:00
Goutham Pacha Ravi 79c12f5930 Bump timeout on sqlalchemy migration test
As we add more migrations in the database, the
time taken by the test increases. The test
`manila.tests.db.migrations.alembic.
test_migration.TestManilaMigrationsPostgreSQL.test_walk_versions`
runs upgrades, downgrades and database checks for
every migration. It has been timing out on numerous
occasions because it can't run under 5 minutes.

We feel the pinch of the timeouts because
the test itself is run as part of multiple
jobs (ex: unit test jobs on py2x, py3x, coverage,
requirements/lower-constraints check) and
can fail anywhere because it was running
on a "slow" node.

Change-Id: I1fdef6e907110681cb5ffb59f6f90f8eb67f118b
Partial-Bug: #1793364
2019-03-12 08:21:42 -07:00
Béla Vancsics f33ac181b0 Use assert(Not)In/Greater(Equal)/LessEqual/IsNotNone
Instead of using assertTrue(A * B) / assertFalse(A * B)
developers should use assertNotIn, assertIn, assertGreater,
assertGreaterEqual or assertLessEqual or assertIsNotNone.
They are compatible with Python 2.7[1] and 3.4[2]

[1]: https://docs.python.org/2.7/library/unittest.html
[2]: https://docs.python.org/3.4/library/unittest.html

Change-Id: I26ab3bc3cad5e1dddc812388b864d51c73f53f58
2016-09-30 09:43:49 +02:00
daiki kato ad6cdb6e10 Fix typos
This patch fixes several typos.

TrivialFix

Change-Id: I169e15a0fdfbbcbeb1f87e3022b01fbb9353df01
2016-03-23 15:55:35 +09:00
Valeriy Ponomaryov 37c6e3179f Fix unstable DB migration tests
Unit test 'test_walk_versions' in
'manila.tests.db.migrations.alembic.test_migration' module
takes abnormally very long time sometimes.
In common cases it takes about 5-10 seconds in CI for Mitaka set of
DB migrations.
In CI runs when this test fails, 'postgres' variant takes
about 47 seconds and mysql reaches common test timeout of 60 seconds.

Note, that this test becomes slower with each
addition of new DB migration. Also, 'pymysql' works much slower
on slow nodes than 'psycopg2'.

So, add new test decorator that sets individual test timeout.
And make it be 5 minutes for mentioned test. In worst case of Mitaka
DB migrations set it can take about 2 minutes, but make it bigger
to have a margin for future releases.

Change-Id: I233f96f29fe62231c2e7013b74c06396dd923f27
Closes-Bug: #1501272
2016-03-10 22:03:16 +02:00
Yusuke Hayashi d3e50fd70f Fix order of arguments in assertEqual
Fix incorrect order assertEqual(observed, expected) as below.
  assertEqual(observed, expected) => assertEqual(expected, observed)

Target of this patch:
  manila/tests/cmd/*
  manila/tests/compute/*
  manila/db/*
  manila/network/*

Change-Id: I6dd4f8057facc68e716b57229cbc4096af8bb152
Partial-Bug: #1259292
2015-10-03 10:05:41 +09:00
Igor Malinovskiy fa15378140 Fix data copying issue in DB migration 1f0bd302c1a6
Fix data copying issue and add data checks in unit
tests for this migration.

Change-Id: I50429e07d108dae75026b8370f7df056362f4b4e
Closes-Bug: #1489827
2015-09-01 12:31:01 +03:00
vponomaryov de1dcc5b14 Enable downgrade migrations in unit tests
Our downgrade migrations were not tested. Enable it.

Change-Id: I3b330f99adb4054701d218d7e9a671b46741809d
Closes-Bug: #1431823
2015-03-13 19:12:40 +02:00
Bob Callaway d7993fc8ae Rename volume_type to share_type
This change adds support for share_type, share_types, and share_type_id
along side the corresponding volume_type, volume_types and
volume_type_id fields in the API. This change was made as share_type and
its references are more intuitive in comparison to volume_type.
Both entries are returned to ensure API compatibility but preference is
given to share_type[s,_id].

The database migration introduced in this change should work on MySQL
and Postgres, but will not work on SQLite. Because there is no point
in supporting SQLite, tests for it are removed.

Implements blueprint: rename-volume-type-to-share-type

Change-Id: Ifa23ee6520b5238c7de3d5bce7b7bbde02a4a61d
2015-02-14 17:41:22 +00:00
Valeriy Ponomaryov 63a0504c21 Use oslo_log lib
Module 'log' from oslo-incubator was removed after release of oslo_log library.
So, start using oslo_log, but keep oslo-incubator code yet other common modules
within Manila codebase use it.

Implements bp use-oslo-log-lib

Change-Id: I88224f7c2bd99adb78140dfc3fa73cea437f29cd
2015-02-08 10:42:40 +00:00
Igor Malinovskiy 8c75493ebd Implement additional test for db migrations
Currently Manila unit tests doesn't check how many
branches exist in db migrations, but this is extremely
important, because multiple branches break
'manila db sync' command.

Implement test, which checks that db migrations has
only one branch.

Change-Id: I4125500126ba46594a636fea38480abd0c97b519
2015-02-04 10:08:33 +00:00
Thomas Bechtold 071d0b59c1 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.
oslo.messaging is the only exception because this package doesn't
currently support non-namespaced imports.

Change-Id: I3987e651bc880c8ffa7c0105df0298679dcd3a43
2015-01-27 09:19:50 +01:00
Andreas Jaeger 0056e4f8bc Don't translate LOG messages in testsuite
There's no need to translate LOG messages in the testsuite since those
will never be run in production.

Change-Id: Ifd5a427a01cdd773b83fb0a5bee0e59348650936
2014-10-28 19:46:09 +01:00
Andreas Jaeger 7b659fc4e0 Use oslo.i18n
oslo.i18n provides the i18n function that were provided by
oslo-incubator's gettextutils module

Import _ where needed, oslo.i18n deprecated the builtin method.

Closes-Bug: #1382187
Change-Id: I12aa1c725aa4bb52a9aa46e9c3d2b303839de48b
2014-10-19 19:21:03 +02:00
Marc Koderer ecf603bc05 Remove vim headers
As discussed in [1] remove all vim headers from manila files.

[1]: http://lists.openstack.org/pipermail/openstack-dev/2013-October/017353.html

Change-Id: I341486c66ffe4dad7db8608fdc66868ceb7ad95a
Closes-Bug: #1229324
2014-10-06 15:00:27 +02:00
vponomaryov 113ddb42ba Move db related unittests to proper places
It is expected, that unittests cover project modules in relation 1:1 and
placed in appropriate tree as main modules do.

It should be like in example:
manila/[tests/]foo/bar/[test_]modulename.py

Change-Id: I890deaeb41b87a6ae82868905144fd7477272058
Partial-Bug: #1348633
2014-09-09 10:43:12 +00:00