You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ad...@apache.org on 2020/10/13 15:45:08 UTC
[cassandra-dtest] branch master updated: Update compact storage
related tests
This is an automated email from the ASF dual-hosted git repository.
adelapena pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cassandra-dtest.git
The following commit(s) were added to refs/heads/master by this push:
new 1c8e5bc Update compact storage related tests
1c8e5bc is described below
commit 1c8e5bcd5040af279205cd69bb5276ed854540e6
Author: Ekaterina Dimitrova <ek...@datastax.com>
AuthorDate: Tue Oct 13 16:42:17 2020 +0100
Update compact storage related tests
patch by Ekaterina Dimitrova; reviewed by Andrés de la Peña and Sylvain Lebresne for CASSANDRA-16063
---
upgrade_tests/drop_compact_storage_upgrade_test.py | 58 ++++++++++++++++++
upgrade_tests/upgrade_compact_storage.py | 69 +++++++++++++++++++++-
2 files changed, 124 insertions(+), 3 deletions(-)
diff --git a/upgrade_tests/drop_compact_storage_upgrade_test.py b/upgrade_tests/drop_compact_storage_upgrade_test.py
new file mode 100644
index 0000000..695e82f
--- /dev/null
+++ b/upgrade_tests/drop_compact_storage_upgrade_test.py
@@ -0,0 +1,58 @@
+import pytest
+import logging
+
+from cassandra.protocol import InvalidRequest
+
+from dtest import Tester
+
+since = pytest.mark.since
+logger = logging.getLogger(__name__)
+
+
+@pytest.mark.upgrade_test
+@since('3.0', max_version='3.11')
+class TestDropCompactStorage(Tester):
+ def test_drop_compact_storage(self):
+ """
+ Test to verify that dropping compact storage is not possible prior running `nodetool upgradesstables`. The
+ current solution and test take care only about the local sstables. Global check of the sstables will be added as
+ part of CASSANDRA-15897.
+ @jira_ticket CASSANDRA-16063
+ """
+ cluster = self.cluster
+ cluster.populate(2)
+ node1, node2 = cluster.nodelist()
+ cluster.set_install_dir(version="2.1.14")
+ cluster.start(wait_for_binary_proto=True)
+
+ session = self.patient_exclusive_cql_connection(node1)
+ session.execute(
+ "CREATE KEYSPACE drop_compact_storage_test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '2'};")
+ session.execute(
+ "CREATE TABLE drop_compact_storage_test.test (a text PRIMARY KEY, b text, c text) WITH COMPACT STORAGE;")
+
+ for i in range(1, 100):
+ session.execute(
+ "INSERT INTO drop_compact_storage_test.test (a, b, c) VALUES ('{}', '{}', '{}');".format(i, i + 1,
+ i + 2))
+
+ logging.debug("Upgrading to current version")
+ for node in [node1, node2]:
+ node.drain()
+ node.watch_log_for("DRAINED")
+ node.stop(wait_other_notice=False)
+
+ self.set_node_to_current_version(node)
+ node.start(wait_for_binary_proto=True)
+
+ session = self.patient_exclusive_cql_connection(node1)
+ try:
+ session.execute("ALTER TABLE drop_compact_storage_test.test DROP COMPACT STORAGE")
+ self.fail("No exception has been thrown")
+ except InvalidRequest as e:
+ assert "Cannot DROP COMPACT STORAGE until all SSTables are upgraded, please run `nodetool upgradesstables` first." in str(e)
+
+ for node in [node1, node2]:
+ node.nodetool("upgradesstables")
+
+ session.execute("ALTER TABLE drop_compact_storage_test.test DROP COMPACT STORAGE")
diff --git a/upgrade_tests/upgrade_compact_storage.py b/upgrade_tests/upgrade_compact_storage.py
index 559ffef..6732285 100644
--- a/upgrade_tests/upgrade_compact_storage.py
+++ b/upgrade_tests/upgrade_compact_storage.py
@@ -6,7 +6,7 @@ from cassandra.query import dict_factory
from ccmlib.node import NodeError
from dtest import Tester
-from cassandra.protocol import ConfigurationException
+from cassandra.protocol import SyntaxException, ConfigurationException
since = pytest.mark.since
logger = logging.getLogger(__name__)
@@ -89,7 +89,7 @@ class TestUpgradeSuperColumnsThrough(Tester):
thrown = False
try:
session.execute("CREATE TABLE ks.compact_table (pk int PRIMARY KEY, col1 int, col2 int) WITH COMPACT STORAGE")
- except ConfigurationException:
+ except (ConfigurationException, SyntaxException):
thrown = True
assert thrown
@@ -140,7 +140,7 @@ class TestUpgradeSuperColumnsThrough(Tester):
node.set_install_dir(version=VERSION_TRUNK)
try:
node.start(wait_other_notice=False, wait_for_binary_proto=False, verbose=False)
- except (NodeError):
+ except NodeError:
print("error") # ignore
time.sleep(5)
# After restart, it won't start
@@ -178,3 +178,66 @@ class TestUpgradeSuperColumnsThrough(Tester):
[{'col1': '50', 'column1': None, 'pk': '5', 'value': None}])
assert (list(session.execute("SELECT * FROM ks.compact_table WHERE pk = '5'")) ==
[{'col1': '50', 'column1': None, 'pk': '5', 'value': None}])
+
+ def test_downgrade_after_failed_upgrade(self):
+ """
+ The purpose of this test is to show that after verifying early in the startup process in Cassandra 4.0 that
+ COMPACT STORAGE was not removed prior start of an upgrade, users can still successfully downgrade, remove the
+ COMPACT STORAGE, and restart the upgrade process.
+ @jira_ticket CASSANDRA-16063
+ """
+ self.prepare(cassandra_version=VERSION_311)
+ node = self.cluster.nodelist()[0]
+ session = self.patient_cql_connection(node, row_factory=dict_factory)
+
+ session.execute("CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy','replication_factor': '1' };")
+ session.execute("CREATE TABLE ks.compact_table (pk ascii PRIMARY KEY, col1 ascii) WITH COMPACT STORAGE")
+ session.execute("CREATE INDEX ON ks.compact_table(col1)")
+
+ for i in range(1, 10):
+ session.execute("INSERT INTO ks.compact_table (pk, col1) VALUES ('{pk}', '{col1}')".format(pk=i, col1=i * 10))
+
+ assert (list(session.execute("SELECT * FROM ks.compact_table WHERE col1 = '50'")) ==
+ [{'pk': '5', 'col1': '50'}])
+ assert (list(session.execute("SELECT * FROM ks.compact_table WHERE pk = '5'")) ==
+ [{'pk': '5', 'col1': '50'}])
+
+ logging.debug("Upgrading to current version")
+
+ self.fixture_dtest_setup.allow_log_errors = True
+
+ node.stop(wait_other_notice=False)
+ node.set_install_dir(version=VERSION_TRUNK)
+ try:
+ node.start(wait_other_notice=False, wait_for_binary_proto=False, verbose=False)
+ except NodeError:
+ print("error") # ignore
+ time.sleep(5)
+ # After restart, it won't start
+ errors = len(node.grep_log("Compact Tables are not allowed in Cassandra starting with 4.0 version"))
+ assert errors > 0
+
+ logging.debug("Downgrading to 3.11")
+ node.set_install_dir(version=VERSION_311)
+ logger.debug("Set new cassandra dir for %s: %s" % (node.name, node.get_install_dir()))
+ self.cluster.set_install_dir(version=VERSION_311)
+ self.fixture_dtest_setup.reinitialize_cluster_for_different_version()
+ node.start(wait_other_notice=False, wait_for_binary_proto=False)
+ logger.debug('Starting %s on new version (%s)' % (node.name, VERSION_311))
+
+ session = self.patient_cql_connection(node, row_factory=dict_factory)
+
+ assert (list(session.execute("SELECT * FROM ks.compact_table WHERE col1 = '50'")) ==
+ [{'pk': '5', 'col1': '50'}])
+ assert (list(session.execute("SELECT * FROM ks.compact_table WHERE pk = '5'")) ==
+ [{'pk': '5', 'col1': '50'}])
+
+ session.execute("ALTER TABLE ks.compact_table DROP COMPACT STORAGE")
+
+ self.upgrade_to_version(VERSION_TRUNK, wait=True)
+
+ session = self.patient_cql_connection(node, row_factory=dict_factory)
+ assert (list(session.execute("SELECT * FROM ks.compact_table WHERE col1 = '50'")) ==
+ [{'col1': '50', 'column1': None, 'pk': '5', 'value': None}])
+ assert (list(session.execute("SELECT * FROM ks.compact_table WHERE pk = '5'")) ==
+ [{'col1': '50', 'column1': None, 'pk': '5', 'value': None}])
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org