worker.py: Created new abstract test base class to fix broken test after

moving CopySchemaShard around.

CopySchemaShard cannot be part of the vtworker main test method because
for some test classes the source master is deliberately shut down and
CopySchemaShard will fail.

Instead, I added a new test base class "TestBaseSplitClone" which will
be inherited by the existing "TestBaseSplitCloneResiliency" test class.

Now, CopySchemaShard won't be executed as part of "TestBaseSplitClone"
because it's a step in the resharding process and e.g. the automation
will take care of it.
This commit is contained in:
Michael Berlin 2015-07-10 10:51:14 -07:00
Родитель 05dc5b6888
Коммит 3fdb8b9687
2 изменённых файлов: 24 добавлений и 12 удалений

Просмотреть файл

@ -18,7 +18,7 @@ def setUpModule():
def tearDownModule():
worker.tearDownModule()
class TestAutomationHorizontalResharding(worker.TestBaseSplitCloneResiliency):
class TestAutomationHorizontalResharding(worker.TestBaseSplitClone):
"""This test reuses worker.py because worker.py also covers the happy path
of the horizontal resharding code. Instead of running the different resharding
steps "manually" as part of the test, they will be run by the automation

Просмотреть файл

@ -133,9 +133,8 @@ def tearDownModule():
shard_1_replica.remove_tree()
shard_1_rdonly1.remove_tree()
class TestBaseSplitCloneResiliency(unittest.TestCase):
"""Tests that the SplitClone worker is resilient to particular failures."""
class TestBaseSplitClone(unittest.TestCase):
"""Abstract test base class for testing the SplitClone worker."""
def run_shard_tablets(self, shard_name, shard_tablets, create_db=True, create_table=True, wait_state='SERVING'):
"""Handles all the necessary work for initially running a shard's tablets.
@ -194,6 +193,14 @@ class TestBaseSplitCloneResiliency(unittest.TestCase):
'test_keyspace'],
auto_log=True)
def copy_schema_to_destination_shards(self):
for keyspace_shard in ('test_keyspace/-80', 'test_keyspace/80-'):
utils.run_vtctl(['CopySchemaShard',
'--exclude_tables', 'unrelated',
shard_rdonly1.tablet_alias,
keyspace_shard],
auto_log=True)
def _insert_values(self, tablet, id_offset, msg, keyspace_id, num_values):
"""Inserts values in the MySQL database along with the required routing comments.
@ -285,14 +292,6 @@ class TestBaseSplitCloneResiliency(unittest.TestCase):
self.run_shard_tablets('80-', shard_1_tablets, create_db=False,
create_table=False, wait_state='NOT_SERVING')
# Copy the schema to the destination shards
for keyspace_shard in ('test_keyspace/-80', 'test_keyspace/80-'):
utils.run_vtctl(['CopySchemaShard',
'--exclude_tables', 'unrelated',
shard_rdonly1.tablet_alias,
keyspace_shard],
auto_log=True)
logging.debug("Start inserting initial data: %s rows", utils.options.num_insert_rows)
self.insert_values(shard_master, utils.options.num_insert_rows, 2)
logging.debug("Done inserting initial data, waiting for replication to catch up")
@ -315,6 +314,16 @@ class TestBaseSplitCloneResiliency(unittest.TestCase):
for shard in ['0', '-80', '80-']:
utils.run_vtctl(['DeleteShard', 'test_keyspace/%s' % shard], auto_log=True)
class TestBaseSplitCloneResiliency(TestBaseSplitClone):
"""Tests that the SplitClone worker is resilient to particular failures."""
def setUp(self):
super(TestBaseSplitCloneResiliency, self).setUp()
self.copy_schema_to_destination_shards()
def tearDown(self):
super(TestBaseSplitCloneResiliency, self).tearDown()
def verify_successful_worker_copy_with_reparent(self, mysql_down=False):
"""Verifies that vtworker can successfully copy data for a SplitClone.
@ -432,6 +441,8 @@ class TestMysqlDownDuringWorkerCopy(TestBaseSplitCloneResiliency):
"""Shuts down MySQL on the destination masters (in addition to the base setup)"""
logging.debug("Starting base setup for MysqlDownDuringWorkerCopy")
super(TestMysqlDownDuringWorkerCopy, self).setUp()
self.copy_schema_to_destination_shards()
logging.debug("Starting MysqlDownDuringWorkerCopy-specific setup")
utils.wait_procs([shard_0_master.shutdown_mysql(),
shard_1_master.shutdown_mysql()])
@ -443,6 +454,7 @@ class TestMysqlDownDuringWorkerCopy(TestBaseSplitCloneResiliency):
utils.wait_procs([shard_0_master.start_mysql(),
shard_1_master.start_mysql()])
logging.debug("Finished MysqlDownDuringWorkerCopy-specific tearDown")
super(TestMysqlDownDuringWorkerCopy, self).tearDown()
logging.debug("Finished base tearDown for MysqlDownDuringWorkerCopy")