Skip to content

Commit

Permalink
cql-pytest: translate Cassandra's tests for compact tables
Browse files Browse the repository at this point in the history
This is a translation of Cassandra's CQL unit test source file
validation/operations/CompactStorageTest.java into our cql-pytest
framework.

This very large test file includes 86 tests for various types of
operations and corner cases of WITH COMPACT STORAGE tables.

All 86 tests pass on Cassandra (except one using a deprecated feature
that needs to be specially enabled). 30 of the tests fail on Scylla
reproducing 7 already-known Scylla issues and 7 previously-unknown issues:

Already known issues:

Refs #3882: Support "ALTER TABLE DROP COMPACT STORAGE"
Refs #4244: Add support for mixing token, multi- and single-column
            restrictions
Refs #5361: LIMIT doesn't work when using GROUP BY
Refs #5362: LIMIT is not doing it right when using GROUP BY
Refs #5363: PER PARTITION LIMIT doesn't work right when using GROUP BY
Refs #7735: CQL parser missing support for Cassandra 3.10's new "+=" syntax
Refs #8627: Cleanly reject updates with indexed values where value > 64k

New issues:

Refs #12471: Range deletions on COMPACT STORAGE is not supported
Refs #12474: DELETE prints misleading error message suggesting
             ALLOW FILTERING would work
Refs #12477: Combination of COUNT with GROUP BY is different from
             Cassandra in case of no matches
Refs #12479: SELECT DISTINCT should refuse GROUP BY with clustering column
Refs #12526: Support filtering on COMPACT tables
Refs #12749: Unsupported empty clustering key in COMPACT table
Refs #12815: Hidden column "value" in compact table isn't completely hidden

Signed-off-by: Nadav Har'El <nyh@scylladb.com>

Closes #12816
  • Loading branch information
nyh authored and denesb committed Feb 20, 2023
1 parent 1b1fbf4 commit db33951
Show file tree
Hide file tree
Showing 2 changed files with 4,444 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/cql-pytest/cassandra_tests/porting.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,13 @@ def assert_invalid(cql, table, cmd, *args):
# SyntaxException.
assert_invalid_throw(cql, table, InvalidRequest, cmd, *args)

assertInvalid = assert_invalid

def assert_invalid_syntax(cql, table, cmd, *args):
assert_invalid_throw(cql, table, SyntaxException, cmd, *args)

assertInvalidSyntax = assert_invalid_syntax

def assert_invalid_message(cql, table, message, cmd, *args):
with pytest.raises(InvalidRequest, match=re.escape(message)):
execute(cql, table, cmd, *args)
Expand Down Expand Up @@ -156,11 +160,19 @@ def assert_invalid_throw_message_re(cql, table, message, typ, cmd, *args):
def assert_row_count(result, expected):
assert len(list(result)) == expected

assertRowCount = assert_row_count

def assert_empty(result):
assert len(list(result)) == 0

assertEmpty = assert_empty

def assertArrayEquals(a, b):
assert a == b

def getRows(results):
return list(results)

# Result objects contain some strange types specific to the CQL driver, which
# normally compare well against normal Python types, but in some cases of nested
# types they do not, and require some cleanup:
Expand All @@ -183,6 +195,22 @@ def assert_rows(result, *expected):

assertRows = assert_rows

# Check if results is one of two possible result sets.
# Can be useful in cases where Cassandra and Scylla results are
# expected to be different and we consider that fine.
def assert_rows2(result, expected1, expected2):
allresults = list(result)
assert len(allresults) == len(expected1) or len(allresults) == len(expected2)
same1 = True
for r,e in zip(allresults, expected1):
r = [result_cleanup(col) for col in r]
same1 = same1 and r == e
same2 = True
for r,e in zip(allresults, expected2):
r = [result_cleanup(col) for col in r]
same2 = same2 and r == e
assert same1 or same2

# To compare two lists of items (each is a dict) without regard for order,
# The following function, multiset() converts the list into a multiset
# (set with duplicates) where order doesn't matter, so the multisets can
Expand Down

0 comments on commit db33951

Please sign in to comment.