Skip to content

Commit

Permalink
test: add custom index tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Balwancia committed Nov 25, 2024
1 parent 5658acc commit fc83537
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/boost/secondary_index_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -708,11 +708,13 @@ SEASTAR_TEST_CASE(test_secondary_index_create_custom_index) {
// "exceptions::invalid_request_exception: CUSTOM index requires
// specifying the index class"
assert_that_failed(e.execute_cql("create custom index on cf (a)"));
// It's also a syntax error to try to specify a "USING" without
// specifying CUSTOM. We expect the exception:
// "exceptions::invalid_request_exception: Cannot specify index class
// for a non-CUSTOM index"
assert_that_failed(e.execute_cql("create index on cf (a) using 'org.apache.cassandra.index.sasi.SASIIndex'"));
// This is the default syntax for specifying a custom index and we
// 'support' "dummy-vector-backend". This should work.
e.execute_cql("create custom index on cf (a) using 'dummy-vector-backend'").get();
// It's not a syntax error to try to specify a "USING" without
// specifying CUSTOM. This should work.
e.execute_cql("create index on cf (a) using 'dummy-vector-backend'").get();

});
}

Expand Down
4 changes: 4 additions & 0 deletions test/cqlpy/test_describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,16 +477,19 @@ def test_desc_index(cql, test_keyspace):
has_local = is_scylla(cql)
if has_local:
create_idx_ab = f"CREATE INDEX ON {tbl}((a), b)"
create_idx_d = f"CREATE INDEX custom ON {tbl}(c) USING 'dummy-vector-backend'"

cql.execute(create_idx_b)
cql.execute(create_idx_c)
cql.execute(create_idx_d)
if has_local:
cql.execute(create_idx_ab)

b_desc = cql.execute(f"DESC INDEX {test_keyspace}.{tbl_name}_b_idx").one().create_statement
if has_local:
ab_desc = cql.execute(f"DESC INDEX {test_keyspace}.{tbl_name}_b_idx_1").one().create_statement
c_desc = cql.execute(f"DESC INDEX {test_keyspace}.named_index").one().create_statement
d_desc = cql.execute(f"DESC INDEX {test_keyspace}.custom").one().create_statement

# Cassandra inserts a space between the table name and parentheses,
# Scylla doesn't. This difference doesn't matter because both are
Expand All @@ -500,6 +503,7 @@ def test_desc_index(cql, test_keyspace):
assert f"CREATE INDEX {tbl_name}_b_idx_1 ON {tbl}((a), b)" in ab_desc

assert f"CREATE INDEX named_index ON {tbl}{maybe_space}(c)" in c_desc
assert f"CREATE INDEX custom ON {tbl}{maybe_space}(c) USING 'dummy-vector-backend'" in d_desc

def test_desc_index_on_collections(cql, test_keyspace):
# In this test, all assertions are in form of
Expand Down

0 comments on commit fc83537

Please sign in to comment.