Fix multiple things in CI

Disable irmc virtual media test_prepare_instance_with_secure_boot
and test_clean_up_instance_with_secure_boot
Related-Bug: #2025424

Explicitly close out test connection
When creating a test database, we should follow the same
pattern we know to be good, where an orphaned handler is not
left in memory to close out a connection.
Change connection style in dbTestBase to mirror how we do
database connections so they close out when we are done
with them.

Change migrations timeout to be >60 seoncds
In local testing, I found the migrations tended to take an
average of 70 seconds. Granted, my test machine is old, and slow
but the performance is very similar to a busy cloud provider.
As such, increase the timeout to a larger value so we can enable
the double migration test again.
Also use BASE_TEST_TIMEOUT as time limit for unit tests, failing
hard if that's passed.

Co-Authored-By: Julia Kreger <juliaashleykreger@gmail.com>
Change-Id: I84802be2e75751fe44ba2e1b60e60563cd276483
This commit is contained in:
Riccardo Pittau 2023-06-30 14:37:53 +02:00
parent 1d9e9b6e77
commit f69e9da1d0
4 changed files with 24 additions and 11 deletions

View File

@ -72,6 +72,9 @@ def _patch_mock_callable(obj):
return False
BASE_TEST_TIMEOUT = os.environ.get('BASE_TEST_TIMEOUT', 60)
class WarningsFixture(fixtures.Fixture):
"""Filters out warnings during test runs."""
@ -190,6 +193,9 @@ class TestCase(oslo_test_base.BaseTestCase):
self.policy = self.useFixture(policy_fixture.PolicyFixture())
self.useFixture(WarningsFixture())
self.useFixture(fixtures.Timeout(int(BASE_TEST_TIMEOUT),
gentle=False))
driver_factory.HardwareTypesFactory._extension_manager = None
for factory in driver_factory._INTERFACE_LOADERS.values():
factory._extension_manager = None

View File

@ -38,11 +38,10 @@ class Database(fixtures.Fixture):
dbapi_parent.LOAD_JOURNAL_MODE = False
self.engine = engine
self.engine.dispose()
conn = self.engine.connect()
self.setup_sqlite(db_migrate)
self.post_migrations()
self._DB = "".join(line for line in conn.connection.iterdump())
with self.engine.connect() as conn:
self.setup_sqlite(db_migrate)
self.post_migrations()
self._DB = "".join(line for line in conn.connection.iterdump())
self.engine.dispose()
def setup_sqlite(self, db_migrate):
@ -53,9 +52,8 @@ class Database(fixtures.Fixture):
def setUp(self):
super(Database, self).setUp()
conn = self.engine.connect()
conn.connection.executescript(self._DB)
with self.engine.connect() as conn:
conn.connection.executescript(self._DB)
self.addCleanup(self.engine.dispose)
def post_migrations(self):
@ -74,4 +72,5 @@ class DbTestCase(base.TestCase):
engine = enginefacade.writer.get_engine()
_DB_CACHE = Database(engine, migration,
sql_connection=CONF.database.connection)
engine.dispose()
self.useFixture(_DB_CACHE)

View File

@ -20,6 +20,7 @@ import io
import os
import shutil
import tempfile
import unittest
from unittest import mock
from ironic_lib import utils as ironic_utils
@ -1231,6 +1232,9 @@ class IRMCVirtualMediaBootTestCase(test_common.BaseIRMCTest):
self.assertRaises(ValueError, cfg.CONF.set_override,
'remote_image_share_type', 'fake', 'irmc')
# NOTE(TheJulia): https://bugs.launchpad.net/ironic/+bug/2025424
# Disabling until we can figure out what exactly is going on.
@unittest.skip("bug #2025424")
@mock.patch.object(irmc_common, 'set_secure_boot_mode', spec_set=True,
autospec=True)
@mock.patch.object(irmc_boot.IRMCVirtualMediaBoot,
@ -1238,7 +1242,8 @@ class IRMCVirtualMediaBootTestCase(test_common.BaseIRMCTest):
autospec=True)
@mock.patch.object(irmc_boot, '_cleanup_vmedia_boot', spec_set=True,
autospec=True)
def test_prepare_instance_with_secure_boot(self, mock_cleanup_vmedia_boot,
def test_prepare_instance_with_secure_boot(self,
mock_cleanup_vmedia_boot,
mock_configure_vmedia_boot,
mock_set_secure_boot_mode,
check_share_fs_mounted_mock):
@ -1312,6 +1317,9 @@ class IRMCVirtualMediaBootTestCase(test_common.BaseIRMCTest):
mock_configure_vmedia_boot.assert_called_once_with(mock.ANY, task,
"12312642")
# NOTE(TheJulia): https://bugs.launchpad.net/ironic/+bug/2025424
# Disabling until we can figure out what exactly is going on.
@unittest.skip("bug #2025424")
@mock.patch.object(irmc_boot, '_remove_share_file', autospec=True)
@mock.patch.object(irmc_common, 'set_secure_boot_mode', spec_set=True,
autospec=True)

View File

@ -10,11 +10,11 @@ setenv = VIRTUAL_ENV={envdir}
PYTHONDONTWRITEBYTECODE=1
LANGUAGE=en_US
LC_ALL=en_US.UTF-8
MIGRATIONS_TIMEOUT={env:MIGRATIONS_TIMEOUT:60}
BASE_TEST_TIMEOUT={env:BASE_TEST_TIMEOUT:60}
MIGRATIONS_TIMEOUT={env:MIGRATIONS_TIMEOUT:180}
OS_LOG_CAPTURE={env:OS_LOG_CAPTURE:true}
OS_STDOUT_CAPTURE={env:OS_STDOUT_CAPTURE:true}
OS_STDERR_CAPTURE={env:OS_STDERR_CAPTURE:true}
OS_TEST_TIMEOUT={env:OS_TEST_TIMEOUT:30}
PYTHONUNBUFFERED=1
SQLALCHEMY_WARN_20=true
deps =