This is an automated email from the ASF dual-hosted git repository. blambov pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/cassandra-dtest.git
commit b3c4d981d465f59de601425689015bcb323d32ad Author: Branimir Lambov <branimir.lam...@datastax.com> AuthorDate: Fri Dec 1 17:45:50 2023 +0200 Test generalizations for BTI format and SAI index defaults patch by Branimir Lambov; reviewed by Mick Semb Wever for CASSANDRA-18753 --- offline_tools_test.py | 4 +-- schema_metadata_test.py | 17 ++++++++-- scrub_test.py | 11 ++++++ secondary_indexes_test.py | 12 +++++++ sstable_generation_loading_test.py | 68 ++++++++++++++++++++++---------------- 5 files changed, 79 insertions(+), 33 deletions(-) diff --git a/offline_tools_test.py b/offline_tools_test.py index 26e0bf17..e69786ea 100644 --- a/offline_tools_test.py +++ b/offline_tools_test.py @@ -277,9 +277,9 @@ class TestOfflineTools(Tester): hashcomputed = False for line in outlines: if sstable in line: - if "Verifying BigTableReader" in line: + if re.search(re.compile(r"Verifying \w+TableReader"), line): verified = True - elif "Checking computed hash of BigTableReader" in line: + elif re.search(re.compile(r"Checking computed hash of \w+TableReader"), line): hashcomputed = True else: logger.debug(line) diff --git a/schema_metadata_test.py b/schema_metadata_test.py index e859ae21..6f901094 100644 --- a/schema_metadata_test.py +++ b/schema_metadata_test.py @@ -73,7 +73,11 @@ def verify_indexes_table(created_on_version, current_version, keyspace, session, assert 1 == len(meta.indexes) - assert {'target': 'd'} == meta.indexes[index_name].index_options + opts = dict(meta.indexes[index_name].index_options) + # we do not want the class name (set when SAI is the default index class) to break this + opts = { k : opts[k] for k in set(opts) - {'class_name'} } + + assert {'target': 'd'} == opts assert 3 == len(meta.primary_key) assert 'a' == meta.primary_key[0].name assert 'b' == meta.primary_key[1].name @@ -558,8 +562,15 @@ class TestSchemaMetadata(Tester): ix_meta = self._keyspace_meta().indexes['ix_born_to_die_name'] assert 'ix_born_to_die_name' == ix_meta.name - assert {'target': 'name'} == ix_meta.index_options - assert 'COMPOSITES' == ix_meta.kind + opts = dict(ix_meta.index_options) + # When SAI is the default index class, we get a somewhat different configuration. + if 'class_name' in opts: + opts = { k : opts[k] for k in set(opts) - {'class_name'} } + assert 'CUSTOM' == ix_meta.kind + else: + assert 'COMPOSITES' == ix_meta.kind + + assert {'target': 'name'} == opts self.session.execute("drop table born_to_die") assert self._keyspace_meta().tables.get('born_to_die') is None diff --git a/scrub_test.py b/scrub_test.py index 3d50d70c..69e77bde 100644 --- a/scrub_test.py +++ b/scrub_test.py @@ -10,6 +10,8 @@ import logging from ccmlib import common +from tools.misc import ImmutableMapping +from dtest_setup_overrides import DTestSetupOverrides from dtest import Tester, create_ks, create_cf from tools.assertions import assert_length_equal, assert_stderr_clean @@ -190,8 +192,17 @@ class TestHelper(Tester): class TestScrubIndexes(TestHelper): """ Test that we scrub indexes as well as their parent tables + Only valid for legacy secondary indexes """ + @pytest.fixture(scope='function', autouse=True) + def fixture_dtest_setup_overrides(self, dtest_config): + dtest_setup_overrides = DTestSetupOverrides() + + if dtest_config.cassandra_version_from_build >= '5.0': + dtest_setup_overrides.cluster_options = ImmutableMapping({'default_secondary_index': 'legacy_local_table'}) + return dtest_setup_overrides + def create_users(self, session): columns = {"password": "varchar", "gender": "varchar", "session_token": "varchar", "state": "varchar", "birth_year": "bigint"} create_cf(session, 'users', columns=columns) diff --git a/secondary_indexes_test.py b/secondary_indexes_test.py index 97f40483..1e14d636 100644 --- a/secondary_indexes_test.py +++ b/secondary_indexes_test.py @@ -17,6 +17,8 @@ from cassandra.protocol import ConfigurationException from cassandra.query import BatchStatement, SimpleStatement from bootstrap_test import BootstrapTester +from tools.misc import ImmutableMapping +from dtest_setup_overrides import DTestSetupOverrides from dtest import Tester, create_ks, create_cf, mk_bman_path from tools.assertions import assert_bootstrap_state, assert_invalid, assert_none, assert_one, assert_row_count, \ assert_length_equal, assert_all @@ -26,6 +28,16 @@ from tools.misc import new_node since = pytest.mark.since logger = logging.getLogger(__name__) +""" +This test is only valid for legacy secondary indexes. +""" +@pytest.fixture() +def fixture_dtest_setup_overrides(request, dtest_config): + dtest_setup_overrides = DTestSetupOverrides() + if dtest_config.cassandra_version_from_build >= '5.0': + dtest_setup_overrides.cluster_options = ImmutableMapping({'default_secondary_index': 'legacy_local_table'}) + return dtest_setup_overrides + class TestSecondaryIndexes(Tester): @staticmethod diff --git a/sstable_generation_loading_test.py b/sstable_generation_loading_test.py index 1a516b3d..490d1254 100644 --- a/sstable_generation_loading_test.py +++ b/sstable_generation_loading_test.py @@ -10,6 +10,8 @@ import logging from ccmlib import common as ccmcommon from ccmlib.node import ToolError +from tools.misc import ImmutableMapping +from dtest_setup_overrides import DTestSetupOverrides from dtest import Tester, create_ks, create_cf, mk_bman_path, MAJOR_VERSION_4, MAJOR_VERSION_5 from tools.assertions import assert_all, assert_none, assert_one @@ -370,6 +372,44 @@ class TestSSTableGenerationAndLoading(BaseSStableLoaderTester): self.load_sstable_with_configuration(ks='"Keyspace1"', create_schema=create_schema_with_mv) + @since("3.0") + def test_sstableloader_empty_stream(self): + """ + @jira_ticket CASSANDRA-16349 + + Tests that sstableloader does not throw if SSTables it attempts to load do not + intersect with the node's ranges. + """ + cluster = self.cluster + cluster.populate(2).start() + node1, node2 = cluster.nodelist() + session = self.patient_cql_connection(node1) + + create_ks(session, 'k', 1) + session.execute("CREATE TABLE k.t (k int PRIMARY KEY, v int)") + for i in range(10): + session.execute("INSERT INTO k.t (k, v) VALUES ({0}, {0})".format(i)) + node1.nodetool('flush') + + ret = self.load_sstables_from_another_node(cluster, node1, node2, "k") + assert len(ret) > 0, "Expected to stream at least 1 table" + for exit_status, _, stderr in ret: + assert exit_status == 0, "Expected exit code 0, got {}".format(exit_status) + # Below warning is emitted in trunk/4.1 because of CASSANDRA-15234. We exploit the backward compatibility + # framework with DTests instead of changing config in all old tests. + if len(stderr) > 0 and stderr is not "parameters have been deprecated. They have new names and/or value format": + "Expected empty stderr, got {}".format(stderr) + +class TestSSTableGenerationAndLoadingLegacyIndex(BaseSStableLoaderTester): + + @pytest.fixture(scope='function', autouse=True) + def fixture_dtest_setup_overrides(self, dtest_config): + dtest_setup_overrides = DTestSetupOverrides() + + if dtest_config.cassandra_version_from_build >= '5.0': + dtest_setup_overrides.cluster_options = ImmutableMapping({'default_secondary_index': 'legacy_local_table'}) + return dtest_setup_overrides + @since('4.0') def test_sstableloader_with_failing_2i(self): """ @@ -434,31 +474,3 @@ class TestSSTableGenerationAndLoading(BaseSStableLoaderTester): assert_one(session, """SELECT * FROM system."IndexInfo" WHERE table_name='k'""", ['k', 'idx', None]) assert_all(session, "SELECT * FROM k.t", [[0, 1, 8], [0, 2, 8]]) assert_all(session, "SELECT * FROM k.t WHERE v = 8", [[0, 1, 8], [0, 2, 8]]) - - @since("3.0") - def test_sstableloader_empty_stream(self): - """ - @jira_ticket CASSANDRA-16349 - - Tests that sstableloader does not throw if SSTables it attempts to load do not - intersect with the node's ranges. - """ - cluster = self.cluster - cluster.populate(2).start() - node1, node2 = cluster.nodelist() - session = self.patient_cql_connection(node1) - - create_ks(session, 'k', 1) - session.execute("CREATE TABLE k.t (k int PRIMARY KEY, v int)") - for i in range(10): - session.execute("INSERT INTO k.t (k, v) VALUES ({0}, {0})".format(i)) - node1.nodetool('flush') - - ret = self.load_sstables_from_another_node(cluster, node1, node2, "k") - assert len(ret) > 0, "Expected to stream at least 1 table" - for exit_status, _, stderr in ret: - assert exit_status == 0, "Expected exit code 0, got {}".format(exit_status) - # Below warning is emitted in trunk/4.1 because of CASSANDRA-15234. We exploit the backward compatibility - # framework with DTests instead of changing config in all old tests. - if len(stderr) > 0 and stderr is not "parameters have been deprecated. They have new names and/or value format": - "Expected empty stderr, got {}".format(stderr) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org