fix version checking for 4.0+ conditionals
patch by Adam Holmberg; reviewed by Benjamin Lerer, David Capwell for CASSANDRA-16330
diff --git a/upgrade_tests/paging_test.py b/upgrade_tests/paging_test.py
index 11df0b9..06c5dfd 100644
--- a/upgrade_tests/paging_test.py
+++ b/upgrade_tests/paging_test.py
@@ -471,9 +471,7 @@
) WITH COMPACT STORAGE;
""")
- version_string = self.upgrade_version_string()
- #4.0 doesn't support compact storage
- if version_string == 'trunk' or version_string >= MAJOR_VERSION_4:
+ if testing_compact_storage and self.upgrade_is_version_4_or_greater(): # 4.0 doesn't support compact storage
cursor.execute("ALTER TABLE test2 DROP COMPACT STORAGE;")
for is_upgraded, cursor in self.do_upgrade(cursor):
@@ -527,9 +525,7 @@
) WITH COMPACT STORAGE;
""")
- version_string = self.upgrade_version_string()
- #4.0 doesn't support compact storage
- if version_string == 'trunk' or version_string >= MAJOR_VERSION_4:
+ if testing_compact_storage and self.upgrade_is_version_4_or_greater(): # 4.0 doesn't support compact storage
cursor.execute("ALTER TABLE test2 DROP COMPACT STORAGE;")
for is_upgraded, cursor in self.do_upgrade(cursor):
diff --git a/upgrade_tests/thrift_upgrade_test.py b/upgrade_tests/thrift_upgrade_test.py
index cad1d7e..491786e 100644
--- a/upgrade_tests/thrift_upgrade_test.py
+++ b/upgrade_tests/thrift_upgrade_test.py
@@ -588,10 +588,7 @@
_validate_dense_cql(cursor)
_validate_dense_thrift(client)
- version_string = self.upgrade_version_string()
- is_version_4_or_greater = version_string == 'trunk' or version_string >= '4.0'
- #4.0 doesn't support compact storage
- if is_version_4_or_greater:
+ if self.upgrade_is_version_4_or_greater(): # 4.0 doesn't support compact storage
cursor.execute("ALTER TABLE ks.dense_super_1 DROP COMPACT STORAGE;")
for is_upgraded, cursor in self.do_upgrade(cursor, row_factory=dict_factory, use_thrift=True):
@@ -628,10 +625,7 @@
_validate_dense_cql(cursor, cf='dense_super_2', key='renamed_key', column1='renamed_column1', column2='renamed_column2', value='renamed_value')
_validate_dense_thrift(client, cf='dense_super_2')
- version_string = self.upgrade_version_string()
- is_version_4_or_greater = version_string == 'trunk' or version_string >= '4.0'
- #4.0 doesn't support compact storage
- if is_version_4_or_greater:
+ if self.upgrade_is_version_4_or_greater(): # 4.0 doesn't support compact storage
cursor.execute("ALTER TABLE ks.dense_super_2 DROP COMPACT STORAGE;")
for is_upgraded, cursor in self.do_upgrade(cursor, row_factory=dict_factory, use_thrift=True):
@@ -671,10 +665,7 @@
_validate_sparse_thrift(client)
_validate_sparse_cql(cursor, column1='renamed_column1', key='renamed_key')
- version_string = self.upgrade_version_string()
- is_version_4_or_greater = version_string == 'trunk' or version_string >= '4.0'
- #4.0 doesn't support compact storage
- if is_version_4_or_greater:
+ if self.upgrade_is_version_4_or_greater(): # 4.0 doesn't support compact storage
cursor.execute("ALTER TABLE ks.sparse_super_1 DROP COMPACT STORAGE;")
for is_upgraded, cursor in self.do_upgrade(cursor, row_factory=dict_factory, use_thrift=True):
@@ -711,10 +702,7 @@
_validate_sparse_thrift(client, cf='sparse_super_2')
_validate_sparse_cql(cursor, cf='sparse_super_2')
- version_string = self.upgrade_version_string()
- is_version_4_or_greater = version_string == 'trunk' or version_string >= '4.0'
- #4.0 doesn't support compact storage
- if is_version_4_or_greater:
+ if self.upgrade_is_version_4_or_greater(): # 4.0 doesn't support compact storage
cursor.execute("ALTER TABLE ks.sparse_super_2 DROP COMPACT STORAGE;")
for is_upgraded, cursor in self.do_upgrade(cursor, row_factory=dict_factory, use_thrift=True):
diff --git a/upgrade_tests/upgrade_base.py b/upgrade_tests/upgrade_base.py
index 62a06ea..04c0c18 100644
--- a/upgrade_tests/upgrade_base.py
+++ b/upgrade_tests/upgrade_base.py
@@ -251,18 +251,15 @@
)
assert self.UPGRADE_PATH is not None, no_upgrade_path_error
- def upgrade_version_string(self):
+ def upgrade_version_family(self):
"""
Returns a hopefully useful version string that can be compared
to tune test behavior. For trunk this returns trunk, for an earlier
version like github:apache/cassandra-3.11 it returns a version number
as a string
- :return:
"""
- version_string = self.UPGRADE_PATH.upgrade_version
- if version_string.startswith('github'):
- version_string = version_string.partition('/')[2]
- if "-" in version_string:
- version_string = version_string.partition('-')[2]
- return version_string
+ return self.UPGRADE_PATH.upgrade_meta.family
+ def upgrade_is_version_4_or_greater(self):
+ upgrade_version = self.upgrade_version_family()
+ return upgrade_version == 'trunk' or upgrade_version >= '4.0'