diff options
author | Zhao Chao <zhaochao1984@gmail.com> | 2018-03-08 21:38:17 +0800 |
---|---|---|
committer | Zhao Chao <zhaochao1984@gmail.com> | 2018-03-09 00:17:38 +0800 |
commit | a25a290a76629838aa3ec216232a4a0d553b6bec (patch) | |
tree | c33298c0568fa273fab152f37e1e36980d2338a9 /trove/tests/scenario | |
parent | f218974296816f2ff32228dde89cade2b3dd7752 (diff) | |
download | trove-a25a290a76629838aa3ec216232a4a0d553b6bec.tar.gz |
Register all replicas in replication scenario test
In the replication scenario tests, two replicas will be created by a
instance create with replica_count equals to 2, but only one of them
will be returned in the reponse, so if the testing fails, the debugging
logs of the the other one will not be gathered. This patch will fix.
The 'replica_2_id' property of ReplicationRunner is also removed in this
patch as it's not used at all.
Change-Id: I05fca265e6e5f06b515c009203865f0d48acf4dd
Signed-off-by: Zhao Chao <zhaochao1984@gmail.com>
Diffstat (limited to 'trove/tests/scenario')
-rw-r--r-- | trove/tests/scenario/runners/replication_runners.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/trove/tests/scenario/runners/replication_runners.py b/trove/tests/scenario/runners/replication_runners.py index f798e1c0..e80ebc19 100644 --- a/trove/tests/scenario/runners/replication_runners.py +++ b/trove/tests/scenario/runners/replication_runners.py @@ -29,7 +29,6 @@ class ReplicationRunner(TestRunner): self.master_id = self.instance_info.id self.replica_1_id = 0 - self.replica_2_id = 0 self.master_host = self.get_instance_host(self.master_id) self.replica_1_host = None self.master_backup_count = None @@ -78,12 +77,16 @@ class ReplicationRunner(TestRunner): self.master_backup_count = len( self.auth_client.instances.backups(self.master_id)) self.replica_1_id = self.assert_replica_create( - self.master_id, 'replica1', 1, expected_http_code) + self.master_id, 'replica1', 1, expected_http_code)[0] def assert_replica_create( self, master_id, replica_name, replica_count, expected_http_code): + # When creating multiple replicas, only one replica info will be + # returned, so we should compare the replica set members before and + # after the creation to get the correct new replica ids. + original_replicas = self._get_replica_set(master_id) client = self.auth_client - replica = client.instances.create( + client.instances.create( self.instance_info.name + '_' + replica_name, self.instance_info.dbaas_flavor_href, self.instance_info.volume, replica_of=master_id, @@ -92,8 +95,9 @@ class ReplicationRunner(TestRunner): nics=self.instance_info.nics, replica_count=replica_count) self.assert_client_code(client, expected_http_code) - self.register_debug_inst_ids(replica.id) - return replica.id + new_replicas = self._get_replica_set(master_id) - original_replicas + self.register_debug_inst_ids(new_replicas) + return list(new_replicas) def run_wait_for_single_replica(self, expected_states=['BUILD', 'ACTIVE']): self.assert_instance_action(self.replica_1_id, expected_states) @@ -113,7 +117,9 @@ class ReplicationRunner(TestRunner): def _get_replica_set(self, master_id): instance = self.get_instance(master_id) - return set([replica['id'] for replica in instance._info['replicas']]) + # Return an empty set before the first replia is created + return set([replica['id'] + for replica in instance._info.get('replicas', [])]) def _assert_is_replica(self, instance_id, master_id): client = self.admin_client @@ -158,8 +164,8 @@ class ReplicationRunner(TestRunner): self.register_debug_inst_ids(self.non_affinity_repl_id) def run_create_multiple_replicas(self, expected_http_code=200): - self.replica_2_id = self.assert_replica_create( - self.master_id, 'replica2', 2, expected_http_code) + self.assert_replica_create(self.master_id, + 'replica2', 2, expected_http_code) def run_wait_for_multiple_replicas( self, expected_states=['BUILD', 'ACTIVE']): |