From fa40f139603095a512f9584c11a0b5c98ebe946a Mon Sep 17 00:00:00 2001 From: Nikhil Manchanda Date: Mon, 30 Mar 2015 12:52:27 -0700 Subject: [PATCH] Make integration-tests run quicker Attempt to make the integration tests run faster in the following ways: 1. Remove the duplication of restore tests: We test restore of both an incremental and a non-incremental backup, which really tests the same code path twice. Testing a restore of an incremental backup should be sufficient since it's a superset of the non-incremental case. In simpler words, there is no case when restore from a full backup will fail and restore from an incremental backup will succeed, so it is sufficient to test the latter scenario only. 2. Spend less time idly waiting for instances to go ACTIVE. The idea is to be able to run other tests during the waiting periods, so that we can parallelize tests and reduce the overall time taken to run the suite. Closes-bug: 1394972 Change-Id: Ia9f9c4198f2dcafdacefe46bc48ad20d4714a70e --- trove/tests/api/backups.py | 28 ++++------------------------ trove/tests/api/configurations.py | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 29 deletions(-) diff --git a/trove/tests/api/backups.py b/trove/tests/api/backups.py index c72d601f1e..654d5e718a 100644 --- a/trove/tests/api/backups.py +++ b/trove/tests/api/backups.py @@ -45,7 +45,7 @@ TIMEOUT_BACKUP_DELETE = 120 backup_info = None incremental_info = None incremental_db = generate_uuid() -restore_instance_id = None +incremental_restore_instance_id = None total_num_dbs = 0 backup_count_prior_to_create = 0 backup_count_for_instance_prior_to_create = 0 @@ -342,18 +342,15 @@ class RestoreUsingBackup(object): assert_equal("BUILD", result.status) return result.id - @test(depends_on=[WaitForBackupCreateToFinish]) - def test_restore(self): - global restore_instance_id - restore_instance_id = self._restore(backup_info.id) - @test(depends_on=[IncrementalBackups]) def test_restore_incremental(self): global incremental_restore_instance_id incremental_restore_instance_id = self._restore(incremental_info.id) -@test(groups=[GROUP, tests.INSTANCES]) +@test(depends_on_classes=[WaitForGuestInstallationToFinish], + runs_after_groups=['dbaas.api.configurations.define'], + groups=[GROUP, tests.INSTANCES]) class WaitForRestoreToFinish(object): @classmethod @@ -375,16 +372,6 @@ class WaitForRestoreToFinish(object): poll_until(result_is_active, time_out=TIMEOUT_INSTANCE_CREATE, sleep_time=10) - """ - Wait until the instance is finished restoring from full backup. - """ - @test(depends_on=[RestoreUsingBackup.test_restore]) - def test_instance_restored(self): - try: - self._poll(restore_instance_id) - except exception.PollTimeOut: - fail('Timed out') - """ Wait until the instance is finished restoring from incremental backup. """ @@ -442,13 +429,6 @@ class DeleteRestoreInstance(object): assert_raises(exceptions.NotFound, instance_info.dbaas.instances.get, instance_id) - @test(runs_after=[WaitForRestoreToFinish.test_instance_restored]) - def test_delete_restored_instance(self): - try: - self._delete(restore_instance_id) - except exception.PollTimeOut: - fail('Timed out') - @test(runs_after=[VerifyRestore.test_database_restored_incremental]) def test_delete_restored_instance_incremental(self): try: diff --git a/trove/tests/api/configurations.py b/trove/tests/api/configurations.py index e4f2b210a0..3c7297fddb 100644 --- a/trove/tests/api/configurations.py +++ b/trove/tests/api/configurations.py @@ -27,6 +27,7 @@ from proboscis.asserts import assert_true from proboscis.asserts import assert_not_equal from proboscis.decorators import time_out from trove.common.utils import poll_until +from trove.tests.api.backups import RestoreUsingBackup from trove.tests.api.instances import assert_unprocessable from trove.tests.api.instances import InstanceTestInfo from trove.tests.api.instances import instance_info @@ -44,6 +45,7 @@ from troveclient.compat import exceptions GROUP = "dbaas.api.configurations" +GROUP_CONFIG_DEFINE = "dbaas.api.configurations.define" CONFIG_NAME = "test_configuration" CONFIG_DESC = "configuration description" @@ -166,7 +168,9 @@ class ConfigurationsTestBase(object): return datastore_test_configs.get("configurations", {}) -@test(depends_on_classes=[WaitForGuestInstallationToFinish], groups=[GROUP]) +@test(depends_on_classes=[WaitForGuestInstallationToFinish], + runs_after=[RestoreUsingBackup], + groups=[GROUP, GROUP_CONFIG_DEFINE]) class CreateConfigurations(ConfigurationsTestBase): @test @@ -300,7 +304,8 @@ class CreateConfigurations(ConfigurationsTestBase): assert_equal(resp.status, 200) -@test(runs_after=[CreateConfigurations], groups=[GROUP]) +@test(runs_after=[CreateConfigurations], + groups=[GROUP, GROUP_CONFIG_DEFINE]) class AfterConfigurationsCreation(ConfigurationsTestBase): @test @@ -439,7 +444,8 @@ class AfterConfigurationsCreation(ConfigurationsTestBase): configuration_info.id) -@test(runs_after=[AfterConfigurationsCreation], groups=[GROUP]) +@test(runs_after=[AfterConfigurationsCreation], + groups=[GROUP, GROUP_CONFIG_DEFINE]) class ListConfigurations(ConfigurationsTestBase): @test @@ -556,7 +562,8 @@ class ListConfigurations(ConfigurationsTestBase): assert_equal(list_config[0].updated, details_config.updated) -@test(runs_after=[ListConfigurations], groups=[GROUP]) +@test(runs_after=[ListConfigurations], + groups=[GROUP, GROUP_CONFIG_DEFINE]) class StartInstanceWithConfiguration(ConfigurationsTestBase): @test @@ -590,7 +597,9 @@ class StartInstanceWithConfiguration(ConfigurationsTestBase): configuration_instance.id = result.id -@test(runs_after=[StartInstanceWithConfiguration], groups=[GROUP]) +@test(depends_on_classes=[StartInstanceWithConfiguration], + runs_after_groups=['dbaas.api.backups'], + groups=[GROUP]) class WaitForConfigurationInstanceToFinish(ConfigurationsTestBase): @test