test_whole_list_conditional | Failure | TypeError: '<' not supported between instances of 'str' and 'int'
self = <abc.TestCQLNodes3RF3_Upgrade_current_5_0_x_To_indev_5_0_x object at 0x7fd6c6aad490>
@since('2.1.1')
def test_whole_list_conditional(self):
cursor = self.prepare()
cursor.execute("""
CREATE TABLE tlist (
k int PRIMARY KEY,
l list<text>
)""")
cursor.execute("""
CREATE TABLE frozentlist (
k int PRIMARY KEY,
l frozen<list<text>>
)""")
for is_upgraded, cursor in self.do_upgrade(cursor):
logger.debug("Querying {} node".format("upgraded" if is_upgraded else "old"))
cursor.execute("TRUNCATE tlist")
cursor.execute("TRUNCATE frozentlist")
for frozen in (False, True):
table = "frozentlist" if frozen else "tlist"
cursor.execute("INSERT INTO {}(k, l) VALUES (0, ['foo', 'bar', 'foobar'])".format(table))
def check_applies(condition):
# UPDATE statement
assert_one(cursor, "UPDATE {} SET l = ['foo', 'bar', 'foobar'] WHERE k=0 IF {}".format(table, condition), [True], cl=self.CL)
assert_one(cursor, "SELECT * FROM {}".format(table), [0, ['foo', 'bar', 'foobar']]) # read back at default cl.one
# DELETE statement
assert_one(cursor, "DELETE FROM {} WHERE k=0 IF {}".format(table, condition), [True], cl=self.CL)
assert_none(cursor, "SELECT * FROM {}".format(table)) # read back at default cl.one
cursor.execute("INSERT INTO {}(k, l) VALUES (0, ['foo', 'bar', 'foobar'])".format(table))
check_applies("l = ['foo', 'bar', 'foobar']")
check_applies("l != ['baz']")
check_applies("l > ['a']")
check_applies("l >= ['a']")
check_applies("l < ['z']")
check_applies("l <= ['z']")
check_applies("l IN (null, ['foo', 'bar', 'foobar'], ['a'])")
# multiple conditions
check_applies("l > ['aaa', 'bbb'] AND l > ['aaa']")
check_applies("l != null AND l IN (['foo', 'bar', 'foobar'])")
def check_does_not_apply(condition):
# UPDATE statement
assert_one(cursor, "UPDATE {} SET l = ['foo', 'bar', 'foobar'] WHERE k=0 IF {}".format(table, condition),
[False, ['foo', 'bar', 'foobar']], cl=self.CL)
assert_one(cursor, "SELECT * FROM {}".format(table), [0, ['foo', 'bar', 'foobar']]) # read back at default cl.one
# DELETE statement
assert_one(cursor, "DELETE FROM {} WHERE k=0 IF {}".format(table, condition),
[False, ['foo', 'bar', 'foobar']], cl=self.CL)
assert_one(cursor, "SELECT * FROM {}".format(table), [0, ['foo', 'bar', 'foobar']]) # read back at default cl.one
# should not apply
check_does_not_apply("l = ['baz']")
check_does_not_apply("l != ['foo', 'bar', 'foobar']")
check_does_not_apply("l > ['z']")
check_does_not_apply("l >= ['z']")
check_does_not_apply("l < ['a']")
check_does_not_apply("l <= ['a']")
check_does_not_apply("l IN (['a'], null)")
check_does_not_apply("l IN ()")
# multiple conditions
check_does_not_apply("l IN () AND l IN (['foo', 'bar', 'foobar'])")
check_does_not_apply("l > ['zzz'] AND l < ['zzz']")
def check_invalid(condition, expected=InvalidRequest):
# UPDATE statement
assert_invalid(cursor, "UPDATE {} SET l = ['foo', 'bar', 'foobar'] WHERE k=0 IF {}".format(table, condition), expected=expected)
assert_one(cursor, "SELECT * FROM {}".format(table), [0, ['foo', 'bar', 'foobar']], cl=self.CL)
# DELETE statement
assert_invalid(cursor, "DELETE FROM {} WHERE k=0 IF {}".format(table, condition), expected=expected)
assert_one(cursor, "SELECT * FROM {}".format(table), [0, ['foo', 'bar', 'foobar']], cl=self.CL)
check_invalid("l = [null]")
check_invalid("l < null")
check_invalid("l <= null")
check_invalid("l > null")
check_invalid("l >= null")
check_invalid("l IN null", expected=SyntaxException)
check_invalid("l IN 367", expected=SyntaxException)
# @jira_ticket CASSANDRA-10537
> if self.get_node_version(is_upgraded) >= LooseVersion(CASSANDRA_4_1):
upgrade_tests/cql_tests.py:4452:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
upgrade_tests/upgrade_base.py:227: in get_node_version
return max(node_versions) if is_upgraded else min(node_versions)
/usr/lib/python3.8/distutils/version.py:64: in __gt__
c = self._cmp(other)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = LooseVersion ('5.0-rc1'), other = LooseVersion ('5.0.1')
def _cmp (self, other):
if isinstance(other, str):
other = LooseVersion(other)
if self.version == other.version:
return 0
> if self.version < other.version:
E TypeError: '<' not supported between instances of 'str' and 'int'
/usr/lib/python3.8/distutils/version.py:337: TypeError | 57.726 |
test_whole_map_conditional | Failure | TypeError: '<' not supported between instances of 'str' and 'int'
self = <abc.TestCQLNodes2RF1_Upgrade_current_5_0_x_To_indev_5_0_x object at 0x7fd6c67862b0>
@since('2.1.1')
def test_whole_map_conditional(self):
cursor = self.prepare()
cursor.execute("""
CREATE TABLE tmap (
k int PRIMARY KEY,
m map<text, text>
)""")
cursor.execute("""
CREATE TABLE frozentmap (
k int PRIMARY KEY,
m frozen<map<text, text>>
)""")
for is_upgraded, cursor in self.do_upgrade(cursor):
logger.debug("Querying {} node".format("upgraded" if is_upgraded else "old"))
cursor.execute("TRUNCATE tmap")
cursor.execute("TRUNCATE frozentmap")
for frozen in (False, True):
logger.debug("Testing {} maps".format("frozen" if frozen else "normal"))
table = "frozentmap" if frozen else "tmap"
cursor.execute("INSERT INTO %s(k, m) VALUES (0, {'foo' : 'bar'})" % (table,))
def check_applies(condition):
# UPDATE statement
assert_one(cursor, "UPDATE {} SET m = {{'foo': 'bar'}} WHERE k=0 IF {}".format(table, condition), [True])
assert_one(cursor, "SELECT * FROM {}".format(table), [0, {'foo': 'bar'}], cl=ConsistencyLevel.SERIAL)
# DELETE statement
assert_one(cursor, "DELETE FROM {} WHERE k=0 IF {}".format(table, condition), [True])
assert_none(cursor, "SELECT * FROM {}".format(table), cl=ConsistencyLevel.SERIAL)
cursor.execute("INSERT INTO {}(k, m) VALUES (0, {{'foo' : 'bar'}})".format(table))
check_applies("m = {'foo': 'bar'}")
check_applies("m > {'a': 'a'}")
check_applies("m >= {'a': 'a'}")
check_applies("m < {'z': 'z'}")
check_applies("m <= {'z': 'z'}")
check_applies("m != {'a': 'a'}")
check_applies("m IN (null, {'a': 'a'}, {'foo': 'bar'})")
# multiple conditions
check_applies("m > {'a': 'a'} AND m < {'z': 'z'}")
check_applies("m != null AND m IN (null, {'a': 'a'}, {'foo': 'bar'})")
def check_does_not_apply(condition):
# UPDATE statement
assert_one(cursor, "UPDATE {} SET m = {{'foo': 'bar'}} WHERE k=0 IF {}".format(table, condition), [False, {'foo': 'bar'}])
assert_one(cursor, "SELECT * FROM {}".format(table), [0, {'foo': 'bar'}], cl=ConsistencyLevel.SERIAL)
# DELETE statement
assert_one(cursor, "DELETE FROM {} WHERE k=0 IF {}".format(table, condition), [False, {'foo': 'bar'}])
assert_one(cursor, "SELECT * FROM {}".format(table), [0, {'foo': 'bar'}], cl=ConsistencyLevel.SERIAL)
# should not apply
check_does_not_apply("m = {'a': 'a'}")
check_does_not_apply("m > {'z': 'z'}")
check_does_not_apply("m >= {'z': 'z'}")
check_does_not_apply("m < {'a': 'a'}")
check_does_not_apply("m <= {'a': 'a'}")
check_does_not_apply("m != {'foo': 'bar'}")
check_does_not_apply("m IN ({'a': 'a'}, null)")
check_does_not_apply("m IN ()")
check_does_not_apply("m = null AND m != null")
def check_invalid(condition, expected=InvalidRequest):
# UPDATE statement
assert_invalid(cursor, "UPDATE {} SET m = {{'foo': 'bar'}} WHERE k=0 IF {}".format(table, condition), expected=expected)
assert_one(cursor, "SELECT * FROM {}".format(table), [0, {'foo': 'bar'}], cl=ConsistencyLevel.SERIAL)
# DELETE statement
assert_invalid(cursor, "DELETE FROM {} WHERE k=0 IF {}".format(table, condition), expected=expected)
assert_one(cursor, "SELECT * FROM {}".format(table), [0, {'foo': 'bar'}], cl=ConsistencyLevel.SERIAL)
check_invalid("m = {null: null}")
check_invalid("m = {'a': null}")
check_invalid("m = {null: 'a'}")
check_invalid("m < null")
check_invalid("m IN null", expected=SyntaxException)
# @jira_ticket CASSANDRA-10537
> if self.get_node_version(is_upgraded) >= LooseVersion(CASSANDRA_4_1):
upgrade_tests/cql_tests.py:4775:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
upgrade_tests/upgrade_base.py:227: in get_node_version
return max(node_versions) if is_upgraded else min(node_versions)
/usr/lib/python3.8/distutils/version.py:64: in __gt__
c = self._cmp(other)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = LooseVersion ('5.0-rc1'), other = LooseVersion ('5.0.1')
def _cmp (self, other):
if isinstance(other, str):
other = LooseVersion(other)
if self.version == other.version:
return 0
> if self.version < other.version:
E TypeError: '<' not supported between instances of 'str' and 'int'
/usr/lib/python3.8/distutils/version.py:337: TypeError | 52.369 |