Skip to content
Permalink
Browse files
Tests fixed and new ones added for CASSANDRA-15897
patch by Ekaterina Dimitrova; reviewed by Benjamin Lerer and Brandon Williams
  • Loading branch information
ekaterinadimitrova2 committed Mar 11, 2021
1 parent 7d10bdd commit 700f712c0ee87ea90c960e7fe92343bff7b2ba23
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 23 deletions.
@@ -127,26 +127,26 @@ def test_prefer_local_reconnect_on_listen_address(self):
logger.debug(out)

assert "/{}".format(NODE1_BROADCAST_ADDRESS) in out
assert "INTERNAL_IP:{}:{}".format('9' if running40 else '6', NODE1_LISTEN_ADDRESS) in out
assert "INTERNAL_IP:{}:{}".format('10' if running40 else '7', NODE1_LISTEN_ADDRESS) in out
assert "/{}".format(NODE2_BROADCAST_ADDRESS) in out
if running40:
assert "INTERNAL_ADDRESS_AND_PORT:7:{}".format(NODE1_40_LISTEN_ADDRESS) in out
assert "INTERNAL_ADDRESS_AND_PORT:7:{}".format(NODE2_40_LISTEN_ADDRESS) in out
assert "INTERNAL_ADDRESS_AND_PORT:8:{}".format(NODE1_40_LISTEN_ADDRESS) in out
assert "INTERNAL_ADDRESS_AND_PORT:8:{}".format(NODE2_40_LISTEN_ADDRESS) in out
else:
assert "INTERNAL_IP:{}:{}".format('6', NODE2_LISTEN_ADDRESS) in out
assert "INTERNAL_IP:{}:{}".format('7', NODE2_LISTEN_ADDRESS) in out

out, err, _ = node2.nodetool('gossipinfo')
assert_stderr_clean(err)
logger.debug(out)

assert "/{}".format(NODE1_BROADCAST_ADDRESS) in out
assert "INTERNAL_IP:{}:{}".format('9' if running40 else '6', NODE2_LISTEN_ADDRESS) in out
assert "INTERNAL_IP:{}:{}".format('10' if running40 else '7', NODE2_LISTEN_ADDRESS) in out
assert "/{}".format(NODE2_BROADCAST_ADDRESS) in out
if running40:
assert "INTERNAL_ADDRESS_AND_PORT:7:{}".format(NODE1_40_LISTEN_ADDRESS) in out
assert "INTERNAL_ADDRESS_AND_PORT:7:{}".format(NODE2_40_LISTEN_ADDRESS) in out
assert "INTERNAL_ADDRESS_AND_PORT:8:{}".format(NODE1_40_LISTEN_ADDRESS) in out
assert "INTERNAL_ADDRESS_AND_PORT:8:{}".format(NODE2_40_LISTEN_ADDRESS) in out
else:
assert "INTERNAL_IP:{}:{}".format('6', NODE1_LISTEN_ADDRESS) in out
assert "INTERNAL_IP:{}:{}".format('7', NODE1_LISTEN_ADDRESS) in out

class TestDynamicEndpointSnitch(Tester):
@pytest.mark.resource_intensive
@@ -1,3 +1,5 @@
import time

import pytest
import logging

@@ -8,20 +10,18 @@
since = pytest.mark.since
logger = logging.getLogger(__name__)

VERSION_30 = 'github:apache/cassandra-3.0'
VERSION_311 = 'github:apache/cassandra-3.11'
VERSION_TRUNK = 'github:apache/trunk'

@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
"""
def prepare(self):
cluster = self.cluster
cluster.populate(2)
node1, node2 = cluster.nodelist()
cluster.populate(3)
node1, node2, node3 = cluster.nodelist()

# Forcing cluster version on purpose
cluster.set_install_dir(version="2.1.14")
cluster.start(wait_for_binary_proto=True)

@@ -35,6 +35,33 @@ def test_drop_compact_storage(self):
session.execute(
"INSERT INTO drop_compact_storage_test.test (a, b, c) VALUES ('{}', '{}', '{}');".format(i, i + 1,
i + 2))
return cluster

def drop_compact_storage(self, session, assert_msg):
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 assert_msg in str(e)

def upgrade_node(self, node, to_version):
node.drain()
node.watch_log_for("DRAINED")
node.stop(wait_other_notice=False)

node.set_install_dir(version=to_version)
node.start(wait_other_notice=False, wait_for_binary_proto=False, verbose=False)

@since('3.0', max_version='3.11')
def test_drop_compact_storage(self):
"""
@jira_ticket CASSANDRA-15897
Test to verify that dropping compact storage is not possible prior running `nodetool upgradesstables` when we still
have old pre-3.0 SSTables in the cluster.
"""
cluster = self.prepare()
node1, node2, node3 = cluster.nodelist()

logging.debug("Upgrading to current version")
for node in [node1, node2]:
@@ -46,13 +73,87 @@ def test_drop_compact_storage(self):
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)
assert_msg = "Cannot DROP COMPACT STORAGE as some nodes in the cluster ([/127.0.0.3]) are not on 3.0+ yet. " \
"Please upgrade those nodes and run `upgradesstables` before retrying."
self.drop_compact_storage(session, assert_msg)

self.upgrade_node(node3, VERSION_30)

# time provided to gossip to update its info after upgrade
time.sleep(5)

for node in [node1, node2, node3]:
node.nodetool("upgradesstables")

time.sleep(2)

session.execute("ALTER TABLE drop_compact_storage_test.test DROP COMPACT STORAGE")
session.execute("SELECT * FROM drop_compact_storage_test.test")

@since('4.0')
def test_drop_compact_storage_mixed_cluster(self):
"""
@jira_ticket CASSANDRA-15897
Test to verify that dropping compact storage is not possible prior running `nodetool upgradesstables` when we still
have old pre-3.0 sstables in the cluster. Also, all nodes to be on the same major version.
"""
cluster = self.prepare()
node1, node2, node3 = cluster.nodelist()

logging.debug("Upgrading all nodes to version 3.0")
for node in [node1, node2, node3]:
self.upgrade_node(node, VERSION_30)

session = self.patient_exclusive_cql_connection(node3)
assert_msg = "Cannot DROP COMPACT STORAGE as some nodes in the cluster ([/127.0.0.1, /127.0.0.2, /127.0.0.3]) has some " \
"non-upgraded 2.x sstables. Please run `upgradesstables` on those nodes before retrying"
self.drop_compact_storage(session, assert_msg)

node3.nodetool("upgradesstables")
time.sleep(1)

assert_msg = "Cannot DROP COMPACT STORAGE as some nodes in the cluster ([/127.0.0.1, /127.0.0.2]) has some " \
"non-upgraded 2.x sstables. Please run `upgradesstables` on those nodes before retrying"
self.drop_compact_storage(session, assert_msg)

self.upgrade_node(node3, VERSION_311)

time.sleep(5)

session = self.patient_exclusive_cql_connection(node3)
self.drop_compact_storage(session, assert_msg)

node2.nodetool("upgradesstables")

# time for gossip to update its info after running upgradesstables
time.sleep(2)

assert_msg = "Cannot DROP COMPACT STORAGE as some nodes in the cluster ([/127.0.0.1]) has some " \
"non-upgraded 2.x sstables. Please run `upgradesstables` on those nodes before retrying"
self.drop_compact_storage(session, assert_msg)

self.upgrade_node(node2, VERSION_311)

self.upgrade_node(node3, VERSION_TRUNK)

node1.nodetool("upgradesstables")
time.sleep(2)

session = self.patient_exclusive_cql_connection(node3)
session.execute("SELECT * FROM drop_compact_storage_test.test")
assert_msg = "Cannot DROP COMPACT STORAGE as some nodes in the cluster ([/127.0.0.2:7000, /127.0.0.1:7000]) are not on 4.0+ yet. " \
"Please upgrade those nodes and run `upgradesstables` before retrying."
self.drop_compact_storage(session, assert_msg)

for node in [node1, node2]:
self.upgrade_node(node, VERSION_TRUNK)
time.sleep(5)
node.nodetool("upgradesstables")

time.sleep(10)

session = self.patient_exclusive_cql_connection(node1)
session.execute("SELECT * FROM drop_compact_storage_test.test")
session.execute("ALTER TABLE drop_compact_storage_test.test DROP COMPACT STORAGE")
session.execute("SELECT * FROM drop_compact_storage_test.test")

0 comments on commit 700f712

Please sign in to comment.