From 6ea816312e48b9ea05e497147e488bc6ec7ac24d Mon Sep 17 00:00:00 2001 From: Lingxian Kong Date: Wed, 27 Mar 2019 21:57:27 +1300 Subject: [PATCH] Fix tests for Ubuntu Bionic migration of CI jobs Change-Id: I2fee668c3774f7e87ce3478ca998f8b366c6cd41 --- devstack/settings | 2 +- integration/scripts/conf/test_begin.conf | 1 + integration/scripts/trovestack | 5 +++- integration/scripts/trovestack.rc | 3 +++ trove/tests/api/backups.py | 27 ++++++++++++++-------- trove/tests/api/instances.py | 11 +++++++-- trove/tests/api/mgmt/datastore_versions.py | 4 ++-- trove/tests/api/replication.py | 19 +++++++++------ trove/tests/config.py | 1 + 9 files changed, 50 insertions(+), 23 deletions(-) diff --git a/devstack/settings b/devstack/settings index 5462654dc0..35852c7a4d 100644 --- a/devstack/settings +++ b/devstack/settings @@ -31,7 +31,7 @@ TROVE_LOCAL_API_PASTE_INI=${TROVE_LOCAL_API_PASTE_INI:-${TROVE_LOCAL_CONF_DIR}/a TROVE_LOCAL_POLICY_JSON=${TROVE_LOCAL_POLICY_JSON:-${TROVE_LOCAL_CONF_DIR}/policy.json} TROVE_DATASTORE_TYPE=${TROVE_DATASTORE_TYPE:-"mysql"} -if [ "$DISTRO" == "xenial" ]; then +if [[ "$DISTRO" == "xenial" || "$DISTRO" == "bionic" ]]; then TROVE_DATASTORE_VERSION=${TROVE_DATASTORE_VERSION:-"5.7"} TROVE_DATASTORE_PACKAGE=${TROVE_DATASTORE_PACKAGE:-"mysql-server-5.7"} else diff --git a/integration/scripts/conf/test_begin.conf b/integration/scripts/conf/test_begin.conf index 534341c6a7..18ffc2fcbe 100644 --- a/integration/scripts/conf/test_begin.conf +++ b/integration/scripts/conf/test_begin.conf @@ -97,6 +97,7 @@ "dbaas_datastore": "%datastore_type%", "dbaas_datastore_version": "%datastore_version%", "neutron_enabled": %neutron_enabled%, + "swift_enabled": %swift_enabled%, "shared_network": "%shared_network%", "shared_network_subnet": "%shared_network_subnet%", "instance_fault_1_flavor_name": "test.fault_1-1", diff --git a/integration/scripts/trovestack b/integration/scripts/trovestack index a1ceafc707..9caff297e9 100755 --- a/integration/scripts/trovestack +++ b/integration/scripts/trovestack @@ -537,7 +537,7 @@ function set_mysql_pkg() { MYSQL_PKG="mysql-community-server" MYSQL_VER="5.6" else - if [ "$RELEASE" == "xenial" ]; then + if [[ "$RELEASE" == "xenial" || "$RELEASE" == "bionic" ]]; then MYSQL_PKG="mysql-server-5.7" MYSQL_VER="5.7" else @@ -734,6 +734,9 @@ function mod_confs() { # Enable neutron tests if needed sed -i "s/%neutron_enabled%/$ENABLE_NEUTRON/g" $TEST_CONF + # Enable backup related tests if Swift is enabled + sed -i "s/%swift_enabled%/$ENABLE_SWIFT/g" $TEST_CONF + # If neutron is enabled, the devstack plugin will have created an alt_demo # network - write this info to the confs so that the integration tests can # use it. diff --git a/integration/scripts/trovestack.rc b/integration/scripts/trovestack.rc index 921e6b2693..928f08b2a7 100644 --- a/integration/scripts/trovestack.rc +++ b/integration/scripts/trovestack.rc @@ -13,6 +13,9 @@ REGION_NAME=${REGION_NAME:-${OS_REGION_NAME:-RegionOne}} # Enable Neutron ENABLE_NEUTRON=$(get_bool ENABLE_NEUTRON true) +# Enable Swift +ENABLE_SWIFT=$(get_bool ENABLE_SWIFT true) + # Enable osprofiler - note: Enables Ceilometer as well ENABLE_PROFILER=$(get_bool ENABLE_PROFILER false) PROFILER_TRACE_SQL=$(get_bool PROFILER_TRACE_SQL false) diff --git a/trove/tests/api/backups.py b/trove/tests/api/backups.py index ddb7dc1497..d3e147a315 100644 --- a/trove/tests/api/backups.py +++ b/trove/tests/api/backups.py @@ -52,7 +52,8 @@ backup_count_for_instance_prior_to_create = 0 @test(depends_on_classes=[WaitForGuestInstallationToFinish], - groups=[GROUP, tests.INSTANCES]) + groups=[GROUP, tests.INSTANCES], + enabled=CONFIG.swift_enabled) class CreateBackups(object): @test @@ -142,7 +143,8 @@ class BackupRestoreMixin(object): @test(runs_after=[CreateBackups], - groups=[GROUP, tests.INSTANCES]) + groups=[GROUP, tests.INSTANCES], + enabled=CONFIG.swift_enabled) class WaitForBackupCreateToFinish(BackupRestoreMixin): """ Wait until the backup create is finished. @@ -156,7 +158,8 @@ class WaitForBackupCreateToFinish(BackupRestoreMixin): @test(depends_on=[WaitForBackupCreateToFinish], - groups=[GROUP, tests.INSTANCES]) + groups=[GROUP, tests.INSTANCES], + enabled=CONFIG.swift_enabled) class ListBackups(object): @test @@ -244,7 +247,8 @@ class ListBackups(object): @test(runs_after=[ListBackups], depends_on=[WaitForBackupCreateToFinish], - groups=[GROUP, tests.INSTANCES]) + groups=[GROUP, tests.INSTANCES], + enabled=CONFIG.swift_enabled) class IncrementalBackups(BackupRestoreMixin): @test @@ -271,7 +275,7 @@ class IncrementalBackups(BackupRestoreMixin): assert_equal(backup_info.id, incremental_info.parent_id) -@test(groups=[GROUP, tests.INSTANCES]) +@test(groups=[GROUP, tests.INSTANCES], enabled=CONFIG.swift_enabled) class RestoreUsingBackup(object): @classmethod @@ -297,7 +301,8 @@ class RestoreUsingBackup(object): @test(depends_on_classes=[WaitForGuestInstallationToFinish], runs_after_groups=['dbaas.api.configurations.define'], - groups=[GROUP, tests.INSTANCES]) + groups=[GROUP, tests.INSTANCES], + enabled=CONFIG.swift_enabled) class WaitForRestoreToFinish(object): @classmethod @@ -330,7 +335,7 @@ class WaitForRestoreToFinish(object): fail('Timed out') -@test(enabled=(not CONFIG.fake_mode), +@test(enabled=(not CONFIG.fake_mode and CONFIG.swift_enabled), groups=[GROUP, tests.INSTANCES]) class VerifyRestore(object): @@ -356,7 +361,7 @@ class VerifyRestore(object): fail('Timed out') -@test(groups=[GROUP, tests.INSTANCES]) +@test(groups=[GROUP, tests.INSTANCES], enabled=CONFIG.swift_enabled) class DeleteRestoreInstance(object): @classmethod @@ -385,7 +390,8 @@ class DeleteRestoreInstance(object): @test(runs_after=[DeleteRestoreInstance], - groups=[GROUP, tests.INSTANCES]) + groups=[GROUP, tests.INSTANCES], + enabled=CONFIG.swift_enabled) class DeleteBackups(object): @test @@ -432,7 +438,8 @@ class DeleteBackups(object): @test(depends_on=[WaitForGuestInstallationToFinish], - runs_after=[DeleteBackups]) + runs_after=[DeleteBackups], + enabled=CONFIG.swift_enabled) class FakeTestHugeBackupOnSmallInstance(BackupRestoreMixin): report = CONFIG.get_report() diff --git a/trove/tests/api/instances.py b/trove/tests/api/instances.py index 1715ee708b..d4a6c457a9 100644 --- a/trove/tests/api/instances.py +++ b/trove/tests/api/instances.py @@ -37,6 +37,7 @@ from proboscis import test import six from troveclient.compat import exceptions +from trove.common import cfg from trove.common import exception as rd_exceptions from trove.common.utils import poll_until from trove.datastore import models as datastore_models @@ -53,6 +54,8 @@ from trove.tests.util import test_config from trove.tests.util.usage import create_usage_verifier from trove.tests.util.users import Requirements +CONF = cfg.CONF + FAKE = test_config.values['fake_mode'] GROUP = "dbaas.guest" @@ -972,7 +975,9 @@ class SecurityGroupsTest(object): def setUp(self): self.testSecurityGroup = dbaas.security_groups.get( instance_info.id) - self.secGroupName = "SecGroup_%s" % instance_info.id + self.secGroupName = ( + "%s_%s" % (CONF.trove_security_group_name_prefix, instance_info.id) + ) self.secGroupDescription = "Security Group for %s" % instance_info.id @test @@ -1018,7 +1023,9 @@ class SecurityGroupsRulesTest(object): def setUp(self): self.testSecurityGroup = dbaas.security_groups.get( instance_info.id) - self.secGroupName = "SecGroup_%s" % instance_info.id + self.secGroupName = ( + "%s_%s" % (CONF.trove_security_group_name_prefix, instance_info.id) + ) self.secGroupDescription = "Security Group for %s" % instance_info.id self.orig_allowable_empty_sleeps = (event_simulator. allowable_empty_sleeps) diff --git a/trove/tests/api/mgmt/datastore_versions.py b/trove/tests/api/mgmt/datastore_versions.py index 5ae4770c08..aa9f535eb9 100644 --- a/trove/tests/api/mgmt/datastore_versions.py +++ b/trove/tests/api/mgmt/datastore_versions.py @@ -68,8 +68,8 @@ class MgmtDataStoreVersion(object): def test_mgmt_ds_version_list_original_count(self): """Tests the mgmt datastore version list method.""" self.ds_versions = self.client.mgmt_datastore_versions.list() - # By default we create two datastore-versions for mysql - assert_equal(2, len(self.ds_versions)) + # datastore-versions should exist for a functional Trove deployment. + assert_true(len(self.ds_versions) > 0) @test(depends_on=[test_mgmt_ds_version_list_original_count]) def test_mgmt_ds_version_list_fields_present(self): diff --git a/trove/tests/api/replication.py b/trove/tests/api/replication.py index 89b70d079f..e3475d68cc 100644 --- a/trove/tests/api/replication.py +++ b/trove/tests/api/replication.py @@ -120,7 +120,8 @@ def validate_master(master, slaves): @test(depends_on_classes=[WaitForGuestInstallationToFinish], - groups=[GROUP]) + groups=[GROUP], + enabled=CONFIG.swift_enabled) class CreateReplicationSlave(object): @test @@ -152,7 +153,7 @@ class CreateReplicationSlave(object): slave_instance.id = create_slave() -@test(groups=[GROUP]) +@test(groups=[GROUP], enabled=CONFIG.swift_enabled) class WaitForCreateSlaveToFinish(object): """Wait until the instance is created and set up as slave.""" @@ -162,7 +163,7 @@ class WaitForCreateSlaveToFinish(object): poll_until(lambda: instance_is_active(slave_instance.id)) -@test(enabled=(not CONFIG.fake_mode), +@test(enabled=(not CONFIG.fake_mode and CONFIG.swift_enabled), depends_on=[WaitForCreateSlaveToFinish], groups=[GROUP]) class VerifySlave(object): @@ -217,7 +218,8 @@ class VerifySlave(object): @test(groups=[GROUP], depends_on=[WaitForCreateSlaveToFinish], - runs_after=[VerifySlave]) + runs_after=[VerifySlave], + enabled=CONFIG.swift_enabled) class TestInstanceListing(object): """Test replication information in instance listing.""" @@ -232,7 +234,8 @@ class TestInstanceListing(object): @test(groups=[GROUP], depends_on=[WaitForCreateSlaveToFinish], - runs_after=[TestInstanceListing]) + runs_after=[TestInstanceListing], + enabled=CONFIG.swift_enabled) class TestReplicationFailover(object): """Test replication failover functionality.""" @@ -332,7 +335,8 @@ class TestReplicationFailover(object): @test(groups=[GROUP], depends_on=[WaitForCreateSlaveToFinish], - runs_after=[TestReplicationFailover]) + runs_after=[TestReplicationFailover], + enabled=CONFIG.swift_enabled) class DetachReplica(object): @test @@ -370,7 +374,8 @@ class DetachReplica(object): @test(groups=[GROUP], depends_on=[WaitForCreateSlaveToFinish], - runs_after=[DetachReplica]) + runs_after=[DetachReplica], + enabled=CONFIG.swift_enabled) class DeleteSlaveInstance(object): @test diff --git a/trove/tests/config.py b/trove/tests/config.py index 8aa489c8a2..c0b9fda6d7 100644 --- a/trove/tests/config.py +++ b/trove/tests/config.py @@ -123,6 +123,7 @@ class TestConfig(object): "volume_support": True, }, "redis": {"volume_support": False}, + "swift_enabled": True, } self._frozen_values = FrozenDict(self._values) self._users = None