diff options
author | alexbogo <alexbogo@ydb.tech> | 2022-08-22 08:39:54 +0300 |
---|---|---|
committer | alexbogo <alexbogo@ydb.tech> | 2022-08-22 08:39:54 +0300 |
commit | 2d3c4030b4383a8dd90f5300bb01951f0c6936f6 (patch) | |
tree | 0fa561260baa2a26b230fbba5f878d246cd1c232 | |
parent | 2c34e084dba881eb83cdbe230c20bb500f63c72c (diff) | |
download | ydb-2d3c4030b4383a8dd90f5300bb01951f0c6936f6.tar.gz |
[ymq] extend tests for tables format v1
init
9 files changed, 142 insertions, 60 deletions
diff --git a/ydb/tests/functional/sqs/common/test_account_actions.py b/ydb/tests/functional/sqs/common/test_account_actions.py index 74e1a4595d..539192febb 100644 --- a/ydb/tests/functional/sqs/common/test_account_actions.py +++ b/ydb/tests/functional/sqs/common/test_account_actions.py @@ -1,12 +1,17 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- + +import pytest from hamcrest import assert_that, not_none, has_item, is_not from ydb.tests.library.sqs.test_base import KikimrSqsTestBase, get_test_with_sqs_installation_by_path, get_test_with_sqs_tenant_installation +from ydb.tests.library.sqs.test_base import TABLES_FORMAT_PARAMS class AccountActionsTest(KikimrSqsTestBase): - def test_manage_account(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_manage_account(self, tables_format): + self._init_with_params(tables_format=tables_format) user_name = 'pupkin' create_user_result = self._sqs_api.create_user(user_name) assert_that( diff --git a/ydb/tests/functional/sqs/common/test_counters.py b/ydb/tests/functional/sqs/common/test_counters.py index 80149eac96..aebfd1b14f 100644 --- a/ydb/tests/functional/sqs/common/test_counters.py +++ b/ydb/tests/functional/sqs/common/test_counters.py @@ -6,7 +6,7 @@ import time import pytest from hamcrest import assert_that, equal_to, none, not_, greater_than, raises -from ydb.tests.library.sqs.test_base import KikimrSqsTestBase +from ydb.tests.library.sqs.test_base import KikimrSqsTestBase, TABLES_FORMAT_PARAMS class TestSqsCountersFeatures(KikimrSqsTestBase): @@ -26,7 +26,9 @@ class TestSqsCountersFeatures(KikimrSqsTestBase): self._execute_yql_query('UPSERT INTO `{}` (State, ShowDetailedCountersDeadline) VALUES (0, {})' .format(attributes_path, deadline)) - def test_creates_counter(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_creates_counter(self, tables_format): + self._init_with_params(tables_format=tables_format) queue_url = self._create_queue_and_assert(self.queue_name) self._sqs_api.get_queue_attributes(queue_url) # Ensure that counters structure is initialized. @@ -117,7 +119,9 @@ class TestSqsCountersFeatures(KikimrSqsTestBase): assert_that(counter, equal_to(0)) break - def test_removes_user_counters_after_user_deletion(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_removes_user_counters_after_user_deletion(self, tables_format): + self._init_with_params(tables_format=tables_format) self._sqs_api.list_queues() # init user's structure in server counter_labels = { 'subsystem': 'core', @@ -202,7 +206,9 @@ class TestSqsCountersFeatures(KikimrSqsTestBase): assert_that(queue_counter, not_(none())) break - def test_updates_status_code_counters_when_parsing_errors_occur(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_updates_status_code_counters_when_parsing_errors_occur(self, tables_format): + self._init_with_params(tables_format=tables_format) self._sqs_api.list_queues() # init user's structure in server counter_labels = { 'subsystem': 'core', @@ -238,7 +244,9 @@ class TestSqsCountersExportDelay(KikimrSqsTestBase): config_generator.yaml_config['sqs_config']['queue_counters_export_delay_ms'] = 2000 return config_generator - def test_export_delay(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_export_delay(self, tables_format): + self._init_with_params(tables_format=tables_format) counter_labels = { 'subsystem': 'core', 'user': self._username, diff --git a/ydb/tests/functional/sqs/common/test_queues_managing.py b/ydb/tests/functional/sqs/common/test_queues_managing.py index c4e6dae6be..198d38c2c5 100644 --- a/ydb/tests/functional/sqs/common/test_queues_managing.py +++ b/ydb/tests/functional/sqs/common/test_queues_managing.py @@ -50,7 +50,9 @@ class QueuesManagingTest(KikimrSqsTestBase): if is_fifo: assert_that(created_attributes.get('ContentBasedDeduplication'), 'true') - def test_create_fifo_queue_wo_postfix(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_create_fifo_queue_wo_postfix(self, tables_format): + self._init_with_params(tables_format=tables_format) def call_create(): self.called = True self._sqs_api.create_queue(self.queue_name, is_fifo=True) @@ -63,7 +65,9 @@ class QueuesManagingTest(KikimrSqsTestBase): ) ) - def test_create_queue_generates_event(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_create_queue_generates_event(self, tables_format): + self._init_with_params(tables_format=tables_format) pytest.skip("Outdated") self._create_queue_and_assert(self.queue_name, is_fifo=False) table_path = '{}/.Queues'.format(self.sqs_root) @@ -72,7 +76,9 @@ class QueuesManagingTest(KikimrSqsTestBase): table_path = '{}/.Events'.format(self.sqs_root) assert_that(self._get_table_lines_count(table_path), equal_to(1)) - def test_remove_queue_generates_event(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_remove_queue_generates_event(self, tables_format): + self._init_with_params(tables_format=tables_format) pytest.skip("Outdated") queue_url = self._create_queue_and_assert(self.queue_name) table_path = '{}/.Events'.format(self.sqs_root) @@ -82,7 +88,9 @@ class QueuesManagingTest(KikimrSqsTestBase): self._sqs_api.delete_queue(queue_url) assert_that(self._get_table_lines_count(table_path), greater_than(lines_count)) - def test_create_queue_with_invalid_name(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_create_queue_with_invalid_name(self, tables_format): + self._init_with_params(tables_format=tables_format) def call_create(): self._sqs_api.create_queue('invalid_queue_name!') @@ -165,7 +173,7 @@ class QueuesManagingTest(KikimrSqsTestBase): assert rows == count, f'in table `{table}` for queue_id_number={queue_id_number} rows {rows}, expected {count}' queues_to_remove = None - for i in range(40): + for i in range(90): queues_to_remove = get_rows_count('.RemovedQueues') if queues_to_remove == 0: break @@ -183,7 +191,9 @@ class QueuesManagingTest(KikimrSqsTestBase): row_count_must_be(common_dir + '/State', another_queue_id_number, 1 if is_fifo else 2) row_count_must_be(common_dir + '/Messages', another_queue_id_number, 1) - def test_delete_queue_batch(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_delete_queue_batch(self, tables_format): + self._init_with_params(tables_format=tables_format) existing_queues = self._sqs_api.list_queues() assert_that( existing_queues, empty() @@ -249,7 +259,9 @@ class QueuesManagingTest(KikimrSqsTestBase): message_ids = self._send_messages(created_queue_url, 1, self._msg_body_template, is_fifo=is_fifo, group_id=group_id) self._read_messages_and_assert(created_queue_url, 1, matcher=ReadResponseMatcher().with_message_ids(message_ids)) - def test_purge_queue_batch(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_purge_queue_batch(self, tables_format): + self._init_with_params(tables_format=tables_format) created_queue_url1 = self._create_queue_and_assert(self.queue_name) created_queue_url2 = self._create_queue_and_assert(self.queue_name + '1') created_queue_url3 = to_bytes(created_queue_url2) + to_bytes('_nonexistent_queue_url') @@ -315,7 +327,9 @@ class QueuesManagingTest(KikimrSqsTestBase): created_queue_url, 10, ReadResponseMatcher().with_message_ids([msg_id, ]) ) - def test_ya_count_queues(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_ya_count_queues(self, tables_format): + self._init_with_params(tables_format=tables_format) assert_that(self._sqs_api.private_count_queues(), equal_to('0')) q_url = self._create_queue_and_assert('new_q') self._create_queue_and_assert('new_q_2') @@ -328,7 +342,9 @@ class QueuesManagingTest(KikimrSqsTestBase): time.sleep(2.1) assert_that(self._sqs_api.private_count_queues(), equal_to('1')) - def test_queues_count_over_limit(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_queues_count_over_limit(self, tables_format): + self._init_with_params(tables_format=tables_format) urls = [] for i in range(10): urls.append(self._create_queue_and_assert('queue_{}'.format(i), shards=1, retries=1)) diff --git a/ydb/tests/functional/sqs/messaging/test_fifo_messaging.py b/ydb/tests/functional/sqs/messaging/test_fifo_messaging.py index 5d22717c00..dbc269bc0a 100644 --- a/ydb/tests/functional/sqs/messaging/test_fifo_messaging.py +++ b/ydb/tests/functional/sqs/messaging/test_fifo_messaging.py @@ -8,7 +8,8 @@ from hamcrest import assert_that, equal_to, not_none, greater_than, less_than_or from ydb.tests.library.sqs.matchers import ReadResponseMatcher, extract_message_ids -from ydb.tests.library.sqs.test_base import KikimrSqsTestBase, get_test_with_sqs_installation_by_path, get_test_with_sqs_tenant_installation, VISIBILITY_CHANGE_METHOD_PARAMS +from ydb.tests.library.sqs.test_base import KikimrSqsTestBase, get_test_with_sqs_installation_by_path, get_test_with_sqs_tenant_installation +from ydb.tests.library.sqs.test_base import VISIBILITY_CHANGE_METHOD_PARAMS, TABLES_FORMAT_PARAMS class SqsFifoMicroBatchTest(KikimrSqsTestBase): @@ -18,8 +19,9 @@ class SqsFifoMicroBatchTest(KikimrSqsTestBase): config_generator.yaml_config['sqs_config']['group_selection_batch_size'] = 2 return config_generator - def test_micro_batch_read(self): - self.queue_name = self.queue_name + '.fifo' + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_micro_batch_read(self, tables_format): + self._init_with_params(is_fifo=True, tables_format=tables_format) created_queue_url = self._create_queue_and_assert(self.queue_name, is_fifo=True) seq_no = 0 max_number_of_messages = 3 @@ -85,7 +87,9 @@ class SqsFifoMessagingTest(KikimrSqsTestBase): } assert_that(self._get_counter_value(counters, delete_counter_labels, 0), equal_to(1)) - def test_write_and_read_to_different_groups(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_write_and_read_to_different_groups(self, tables_format): + self._init_with_params(tables_format=tables_format) seq_no = 1 self._create_queue_and_assert(self.queue_name, is_fifo=True) message_ids = [] @@ -104,7 +108,9 @@ class SqsFifoMessagingTest(KikimrSqsTestBase): sorted(received_message_ids), equal_to(sorted(message_ids)) ) - def test_can_read_from_different_groups(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_can_read_from_different_groups(self, tables_format): + self._init_with_params(tables_format=tables_format) seq_no = 1 self._create_queue_and_assert(self.queue_name, is_fifo=True) message_ids = [] @@ -134,7 +140,9 @@ class SqsFifoMessagingTest(KikimrSqsTestBase): self.queue_url, 10, visibility_timeout=1000, matcher=ReadResponseMatcher().with_n_messages(0) ) - def test_send_and_read_multiple_messages(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_send_and_read_multiple_messages(self, tables_format): + self._init_with_params(tables_format=tables_format) queue_url = self._create_queue_and_assert(self.queue_name, is_fifo=True) first_message_id = self._send_message_and_assert( queue_url, self._msg_body_template.format('0'), seq_no=1, group_id='group' @@ -148,7 +156,9 @@ class SqsFifoMessagingTest(KikimrSqsTestBase): matcher=ReadResponseMatcher().with_message_ids([first_message_id, ]) ) - def test_read_dont_stall(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_read_dont_stall(self, tables_format): + self._init_with_params(tables_format=tables_format) queue_url = self._create_queue_and_assert(self.queue_name, is_fifo=True) pack_size = 5 first_pack_ids = self._send_messages( @@ -176,7 +186,9 @@ class SqsFifoMessagingTest(KikimrSqsTestBase): matcher=ReadResponseMatcher().with_message_ids(third_pack_ids[:1]) ) - def test_visibility_timeout_works(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_visibility_timeout_works(self, tables_format): + self._init_with_params(tables_format=tables_format) self._create_queue_send_x_messages_read_y_messages( self.queue_name, send_count=5, read_count=1, visibility_timeout=10, msg_body_template=self._msg_body_template, is_fifo=True, group_id='1' @@ -193,7 +205,9 @@ class SqsFifoMessagingTest(KikimrSqsTestBase): ) ) - def test_delete_message_works(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_delete_message_works(self, tables_format): + self._init_with_params(tables_format=tables_format) self._create_queue_send_x_messages_read_y_messages( self.queue_name, send_count=10, read_count=1, visibility_timeout=1, msg_body_template=self._msg_body_template, is_fifo=True @@ -230,7 +244,9 @@ class SqsFifoMessagingTest(KikimrSqsTestBase): raises(RuntimeError, pattern='InternalFailure') ) - def test_write_read_delete_many_groups(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_write_read_delete_many_groups(self, tables_format): + self._init_with_params(tables_format=tables_format) queue_url = self._create_queue_and_assert(self.queue_name, is_fifo=True) message_ids = {} for i in range(10): @@ -258,7 +274,9 @@ class SqsFifoMessagingTest(KikimrSqsTestBase): ) self._read_messages_and_assert(queue_url, 10, matcher=matcher, visibility_timeout=1000) - def test_queue_attributes(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_queue_attributes(self, tables_format): + self._init_with_params(tables_format=tables_format) queue_url = self._create_queue_and_assert(self.queue_name, is_fifo=True) attributes = self._sqs_api.get_queue_attributes(queue_url) assert_that(attributes, has_items( @@ -280,7 +298,9 @@ class SqsFifoMessagingTest(KikimrSqsTestBase): attributes = self._sqs_api.get_queue_attributes(queue_url) assert_that(attributes['VisibilityTimeout'], equal_to('2')) - def test_validates_group_id(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_validates_group_id(self, tables_format): + self._init_with_params(tables_format=tables_format) queue_url = self._create_queue_and_assert(self.queue_name, is_fifo=True) def send_caller(group_id): @@ -299,7 +319,9 @@ class SqsFifoMessagingTest(KikimrSqsTestBase): check('') check(None) # without - def test_validates_deduplication_id(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_validates_deduplication_id(self, tables_format): + self._init_with_params(tables_format=tables_format) queue_url = self._create_queue_and_assert(self.queue_name, is_fifo=True) def send_caller(deduplication_id): @@ -318,7 +340,9 @@ class SqsFifoMessagingTest(KikimrSqsTestBase): check('') check(None) # without - def test_validates_receive_attempt_id(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_validates_receive_attempt_id(self, tables_format): + self._init_with_params(tables_format=tables_format) queue_url = self._create_queue_and_assert(self.queue_name, is_fifo=True) def receive_caller(receive_request_attempt_id): @@ -336,7 +360,9 @@ class SqsFifoMessagingTest(KikimrSqsTestBase): check('ยง') @pytest.mark.parametrize('content_based', [True, False], ids=['content_based', 'by_deduplication_id']) - def test_deduplication(self, content_based): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_deduplication(self, content_based, tables_format): + self._init_with_params(tables_format=tables_format) attributes = {} if content_based: attributes['ContentBasedDeduplication'] = 'true' @@ -377,7 +403,9 @@ class SqsFifoMessagingTest(KikimrSqsTestBase): self._read_messages_and_assert(queue_url, 10, visibility_timeout=1000, matcher=ReadResponseMatcher().with_n_messages(2), wait_timeout=3) @pytest.mark.parametrize('after_crutch_batch', [False, True], ids=['standard_mode', 'after_crutch_batch']) - def test_receive_attempt_reloads_same_messages(self, after_crutch_batch): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_receive_attempt_reloads_same_messages(self, after_crutch_batch, tables_format): + self._init_with_params(tables_format=tables_format) queue_url = self._create_queue_and_assert(self.queue_name, is_fifo=True) groups_selection_batch_size = self.config_generator.yaml_config['sqs_config']['group_selection_batch_size'] @@ -414,7 +442,9 @@ class SqsFifoMessagingTest(KikimrSqsTestBase): assert_that(len(message_set_1 & message_set_3), equal_to(0)) @pytest.mark.parametrize(**VISIBILITY_CHANGE_METHOD_PARAMS) - def test_visibility_change_disables_receive_attempt_id(self, delete_message): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_visibility_change_disables_receive_attempt_id(self, delete_message, tables_format): + self._init_with_params(tables_format=tables_format) queue_url = self._create_queue_and_assert(self.queue_name, is_fifo=True) groups_count = 5 for group_number in range(groups_count): @@ -438,7 +468,9 @@ class SqsFifoMessagingTest(KikimrSqsTestBase): message_set_2 = set([res['MessageId'] for res in read_result_2]) assert_that(len(message_set_1 & message_set_2), equal_to(0)) - def test_crutch_groups_selection_algorithm_selects_second_group_batch(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_crutch_groups_selection_algorithm_selects_second_group_batch(self, tables_format): + self._init_with_params(tables_format=tables_format) queue_url = self._create_queue_and_assert(self.queue_name, is_fifo=True) groups_selection_batch_size = self.config_generator.yaml_config['sqs_config']['group_selection_batch_size'] groups_count = groups_selection_batch_size + 50 diff --git a/ydb/tests/functional/sqs/messaging/test_generic_messaging.py b/ydb/tests/functional/sqs/messaging/test_generic_messaging.py index 05a6db6b32..a597c8d285 100644 --- a/ydb/tests/functional/sqs/messaging/test_generic_messaging.py +++ b/ydb/tests/functional/sqs/messaging/test_generic_messaging.py @@ -976,7 +976,9 @@ class SqsGenericMessagingTest(KikimrSqsTestBase): attributes = self._sqs_api.get_queue_attributes(queue_url, ['MaximumMessageSize']) assert_that(int(attributes['MaximumMessageSize']), equal_to(256 * 1024)) - def test_queue_attributes_batch(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_queue_attributes_batch(self, tables_format): + self._init_with_params(tables_format=tables_format) # Create > 10 queues to check that private commands for UI will work queue_urls = [self._create_queue_and_assert("{}-{}".format(self.queue_name, i)) for i in range(10)] created_queue_url2 = self._create_queue_and_assert(self.queue_name + '1.fifo', is_fifo=True) diff --git a/ydb/tests/functional/sqs/multinode/test_multinode_cluster.py b/ydb/tests/functional/sqs/multinode/test_multinode_cluster.py index e06dceed88..1dbe9bff74 100644 --- a/ydb/tests/functional/sqs/multinode/test_multinode_cluster.py +++ b/ydb/tests/functional/sqs/multinode/test_multinode_cluster.py @@ -11,7 +11,7 @@ from ydb.tests.library.common.types import Erasure from ydb.tests.library.sqs.matchers import ReadResponseMatcher -from ydb.tests.library.sqs.test_base import KikimrSqsTestBase, STOP_NODE_PARAMS, IS_FIFO_PARAMS +from ydb.tests.library.sqs.test_base import KikimrSqsTestBase, STOP_NODE_PARAMS, IS_FIFO_PARAMS, TABLES_FORMAT_PARAMS class TestSqsMultinodeCluster(KikimrSqsTestBase): @@ -26,9 +26,9 @@ class TestSqsMultinodeCluster(KikimrSqsTestBase): return config_generator @pytest.mark.parametrize(**IS_FIFO_PARAMS) - def test_sqs_writes_through_proxy_on_each_node(self, is_fifo): - if is_fifo: - self.queue_name = self.queue_name + '.fifo' + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_sqs_writes_through_proxy_on_each_node(self, is_fifo, tables_format): + self._init_with_params(is_fifo, tables_format) self._create_queue_and_assert(self.queue_name, is_fifo=is_fifo) message_ids = [] for i in range(self.cluster_nodes_count * 3): @@ -59,8 +59,7 @@ class TestSqsMultinodeCluster(KikimrSqsTestBase): @pytest.mark.parametrize(**IS_FIFO_PARAMS) @pytest.mark.parametrize(**STOP_NODE_PARAMS) def test_has_messages_counters(self, is_fifo, stop_node): - if is_fifo: - self.queue_name = self.queue_name + '.fifo' + self._init_with_params(is_fifo) self._create_queue_and_assert(self.queue_name, is_fifo=is_fifo) node_index = self._get_queue_master_node_index() logging.debug('Master node for queue "{}" is {}'.format(self.queue_name, node_index)) @@ -144,7 +143,9 @@ class TestSqsMultinodeCluster(KikimrSqsTestBase): check_master_node_counters(new_node_index) @pytest.mark.parametrize(**STOP_NODE_PARAMS) - def test_reassign_master(self, stop_node): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_reassign_master(self, stop_node, tables_format): + self._init_with_params(tables_format=tables_format) self._create_queue_and_assert(self.queue_name) node_index = self._get_queue_master_node_index() proxy_node_index = self._other_node(node_index) diff --git a/ydb/tests/functional/sqs/multinode/test_recompiles_requests.py b/ydb/tests/functional/sqs/multinode/test_recompiles_requests.py index ac721a57f5..fe7eada741 100644 --- a/ydb/tests/functional/sqs/multinode/test_recompiles_requests.py +++ b/ydb/tests/functional/sqs/multinode/test_recompiles_requests.py @@ -5,7 +5,7 @@ from hamcrest import assert_that, not_none from ydb.tests.library.common.types import Erasure -from ydb.tests.library.sqs.test_base import KikimrSqsTestBase, IS_FIFO_PARAMS +from ydb.tests.library.sqs.test_base import KikimrSqsTestBase, IS_FIFO_PARAMS, TABLES_FORMAT_PARAMS class TestSqsRecompilesRequestsForOtherQueue(KikimrSqsTestBase): @@ -18,9 +18,9 @@ class TestSqsRecompilesRequestsForOtherQueue(KikimrSqsTestBase): return config_generator @pytest.mark.parametrize(**IS_FIFO_PARAMS) - def test_recompiles_queries(self, is_fifo): - if is_fifo: - self.queue_name = self.queue_name + '.fifo' + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_recompiles_queries(self, is_fifo, tables_format): + self._init_with_params(is_fifo, tables_format) queue_url = self._create_queue_and_assert(self.queue_name, is_fifo=is_fifo) def send(node_index): diff --git a/ydb/tests/functional/sqs/with_quotas/test_quoting.py b/ydb/tests/functional/sqs/with_quotas/test_quoting.py index f750f28d3d..60d08cc378 100644 --- a/ydb/tests/functional/sqs/with_quotas/test_quoting.py +++ b/ydb/tests/functional/sqs/with_quotas/test_quoting.py @@ -8,7 +8,7 @@ from hamcrest import assert_that, raises, greater_than, contains_string, equal_t from ydb.tests.library.sqs.requests_client import SqsSendMessageParams -from ydb.tests.library.sqs.test_base import KikimrSqsTestBase, IS_FIFO_PARAMS +from ydb.tests.library.sqs.test_base import KikimrSqsTestBase, IS_FIFO_PARAMS, TABLES_FORMAT_PARAMS from ydb import issues as ydb_issues @@ -31,9 +31,9 @@ class TestSqsQuotingWithKesus(KikimrSqsTestBase): self._sqs_api.delete_user(self._username) @pytest.mark.parametrize(**IS_FIFO_PARAMS) - def test_properly_creates_and_deletes_queue(self, is_fifo): - if is_fifo: - self.queue_name = self.queue_name + '.fifo' + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_properly_creates_and_deletes_queue(self, is_fifo, tables_format): + self._init_with_params(is_fifo, tables_format) created_queue_url = self._create_queue_and_assert(self.queue_name, is_fifo=is_fifo) self._sqs_api.delete_queue(created_queue_url) @@ -91,9 +91,9 @@ class TestSqsQuotingWithLocalRateLimiter(KikimrSqsTestBase): self._sqs_api.delete_user(self._username) @pytest.mark.parametrize(**IS_FIFO_PARAMS) - def test_does_actions_with_queue(self, is_fifo): - if is_fifo: - self.queue_name = self.queue_name + '.fifo' + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_does_actions_with_queue(self, is_fifo, tables_format): + self._init_with_params(is_fifo, tables_format) self._create_queue_send_x_messages_read_y_messages(self.queue_name, send_count=1, read_count=1, @@ -115,7 +115,9 @@ class TestSqsQuotingWithLocalRateLimiter(KikimrSqsTestBase): throttling_times += 1 return throttling_times - def test_send_message_rate(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_send_message_rate(self, tables_format): + self._init_with_params(tables_format=tables_format) self._create_queue_and_assert(self.queue_name) counters = self._get_sqs_counters() @@ -144,7 +146,9 @@ class TestSqsQuotingWithLocalRateLimiter(KikimrSqsTestBase): throttling_counter_value = self._get_counter_value(counters, throttling_counter_labels, 0) assert_that(throttling_counter_value - prev_throttling_counter_value, equal_to(throttling_times)) - def test_create_queue_rate(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_create_queue_rate(self, tables_format): + self._init_with_params(tables_format=tables_format) queue_urls = [] def call_create_queue(i): @@ -168,7 +172,9 @@ class TestSqsQuotingWithLocalRateLimiter(KikimrSqsTestBase): len(delete_queue_batch_result['DeleteQueueBatchResultEntry']), equal_to(6) # no errors, all items are results ) - def test_other_requests_rate(self): + @pytest.mark.parametrize(**TABLES_FORMAT_PARAMS) + def test_other_requests_rate(self, tables_format): + self._init_with_params(tables_format=tables_format) self._create_queue_and_assert(self.queue_name) def call(i): diff --git a/ydb/tests/library/sqs/test_base.py b/ydb/tests/library/sqs/test_base.py index 9f78bde482..e1abfbb2e2 100644 --- a/ydb/tests/library/sqs/test_base.py +++ b/ydb/tests/library/sqs/test_base.py @@ -163,6 +163,9 @@ class KikimrSqsTestBase(object): cls.sqs_port = cls.sqs_ports[0] cls.server_fqdn = get_fqdn() + def _before_test_start(self): + pass + def setup_method(self, method=None): logging.debug('Test started: {}'.format(str(method.__name__))) logging.debug("Kikimr logs dir: {}".format(self.cluster.slots[1].cwd if self.slot_count else self.cluster.nodes[1].cwd)) @@ -180,11 +183,18 @@ class KikimrSqsTestBase(object): grpc_port = self.cluster.slots[1].grpc_port if self.slot_count else self.cluster.nodes[1].grpc_port self._sqs_server_opts = ['-s', 'localhost', '-p', str(grpc_port)] test_name = str(method.__name__)[5:] - self._username = 'U_' + test_name - self.queue_name = 'Q_{}_{}'.format(test_name, str(uuid.uuid1())) - max_queue_name_length = 80 - len('.fifo') - if len(self.queue_name) > max_queue_name_length: - self.queue_name = self.queue_name[:max_queue_name_length] + + def create_unique_name(user=False): + max_length = 80 - (0 if user else len('.fifo')) + name = '{subject}_{test}_{uid}'.format( + subject=('U' if user else 'Q'), + test=test_name[:60], + uid=uuid.uuid1() + ) + return name[:max_length] + + self._username = create_unique_name(user=True) + self.queue_name = create_unique_name() self._msg_body_template = self._username + '-{}' self._setup_user(self._username) self._sqs_apis = [] @@ -221,6 +231,8 @@ class KikimrSqsTestBase(object): self.seq_no = 0 + self._before_test_start() + def teardown_method(self, method=None): self.check_no_queues_table(self._username) self._driver.stop() |