maedhroz commented on code in PR #3575:
URL: https://github.com/apache/cassandra/pull/3575#discussion_r1800135371
##########
test/distributed/org/apache/cassandra/distributed/test/accord/AccordCQLTestBase.java:
##########
@@ -92,12 +98,198 @@ public static void setupClass() throws IOException
SHARED_CLUSTER.schemaChange("CREATE TYPE " + KEYSPACE + ".person
(height int, age int)");
}
+ @Test
+ public void testCounterCreateTableTransactionalModeFails() throws Exception
+ {
+ try
+ {
+ test("CREATE TABLE " + qualifiedAccordTableName + " (k int, c int,
v counter, primary key (k, c)) WITH " + transactionalMode.asCqlParam(), cluster
-> {});
+ fail("Expected exception");
+ }
+ catch (Throwable t)
+ {
+ assertEquals(IllegalStateException.class.getName(),
t.getClass().getName());
+ assertEquals(format(ACCORD_COUNTER_TABLES_UNSUPPORTED, KEYSPACE,
accordTableName), t.getMessage());
+ }
+ }
+
+ @Test
+ public void testCounterCreateTableTransactionalMigrationFromModeFails()
throws Exception
+ {
+ try
+ {
+ test("CREATE TABLE " + qualifiedAccordTableName + " (k int, c int,
v counter, primary key (k, c)) WITH transactional_migration_from = '" +
transactionalMode.name() + "'", cluster -> {});
+ fail("Expected exception");
+ }
+ catch (Throwable t)
+ {
+ assertEquals(IllegalStateException.class.getName(),
t.getClass().getName());
+ assertEquals(format(ACCORD_COUNTER_TABLES_UNSUPPORTED, KEYSPACE,
accordTableName), t.getMessage());
+ }
+ }
+
+ @Test
+ public void testCounterAlterTableTransactionalModeFails() throws Exception
+ {
+ test("CREATE TABLE " + qualifiedAccordTableName + " (k int, c int, v
counter, primary key (k, c))", cluster -> {
+ try
+ {
+ cluster.coordinator(1).execute("ALTER TABLE " +
qualifiedAccordTableName + " WITH transactional_mode = '" +
transactionalMode.name() + "';", ConsistencyLevel.ALL);
+ fail("Expected exception");
+ }
+ catch (Throwable t)
+ {
+ assertEquals(InvalidRequestException.class.getName(),
t.getClass().getName());
+ assertEquals(format(ACCORD_COUNTER_TABLES_UNSUPPORTED,
KEYSPACE, accordTableName), t.getMessage());
+ }
+ });
+ }
+
+ @Test
+ public void testCounterAlterTableTransactionalMigrationFromModeFails()
throws Exception
+ {
+ test("CREATE TABLE " + qualifiedAccordTableName + " (k int, c int, v
counter, primary key (k, c))", cluster -> {
+ try
+ {
+ cluster.coordinator(1).execute("ALTER TABLE " +
qualifiedAccordTableName + " WITH transactional_migration_from = '" +
transactionalMode.name() + "';", ConsistencyLevel.ALL);
+ fail("Expected exception");
+ }
+ catch (Throwable t)
+ {
+ assertEquals(InvalidRequestException.class.getName(),
t.getClass().getName());
+ assertEquals(format(ACCORD_COUNTER_TABLES_UNSUPPORTED,
KEYSPACE, accordTableName), t.getMessage());
+ }
+ });
+ }
+
+ @Test
+ public void testCounterAddColumnFailsWithAccord() throws Exception
+ {
+ test("CREATE TABLE " + qualifiedAccordTableName + " (k int, c int, s
int static, v int, primary key (k, c)) WITH " + transactionalMode.asCqlParam(),
cluster -> {
+ try
+ {
+ cluster.coordinator(1).execute("ALTER TABLE " +
qualifiedAccordTableName + " ADD (v2 counter);", ConsistencyLevel.ALL);
+ fail("Expected exception");
+ }
+ catch (Throwable t)
+ {
+ assertEquals(InvalidRequestException.class.getName(),
t.getClass().getName());
+ assertEquals(format(ACCORD_COUNTER_COLUMN_UNSUPPORTED,
KEYSPACE, accordTableName, transactionalMode,
TransactionalMigrationFromMode.none), t.getMessage());
+ }
+ });
+ }
+
+ @Test
+ public void testCounterAddColumnFailsWithMigration() throws Exception
+ {
+ test("CREATE TABLE " + qualifiedAccordTableName + " (k int, c int, s
int static, v int, primary key (k, c)) WITH " + transactionalMode.asCqlParam(),
cluster -> {
+ try
+ {
+ cluster.coordinator(1).execute("ALTER TABLE " +
qualifiedAccordTableName + " WITH transactional_mode = '" +
TransactionalMode.off + "';", ConsistencyLevel.ALL);
+ cluster.coordinator(1).execute("ALTER TABLE " +
qualifiedAccordTableName + " ADD (v2 counter);", ConsistencyLevel.ALL);
+ fail("Expected exception");
+ }
+ catch (Throwable t)
+ {
+ assertEquals(InvalidRequestException.class.getName(),
t.getClass().getName());
+ assertEquals(format(ACCORD_COUNTER_COLUMN_UNSUPPORTED,
KEYSPACE, accordTableName, TransactionalMode.off, transactionalMode),
t.getMessage());
+ }
+ });
+ }
+
@Override
protected void test(FailingConsumer<Cluster> fn) throws Exception
{
test("CREATE TABLE " + qualifiedAccordTableName + " (k int, c int, v
int, primary key (k, c)) WITH " + transactionalMode.asCqlParam(), fn);
}
+ @Test
+ public void testPartitionMultiRowReturn() throws Exception
+ {
+ test(cluster -> {
+ for (int i = 0; i < 3; i++)
+ cluster.coordinator(1).execute(wrapInTxn("INSERT INTO " +
qualifiedAccordTableName + " (k, c, v) VALUES (?, ?, ?)"),
ConsistencyLevel.ALL, 42, 43 + i, 44 + i);
+
+ String txn = "BEGIN TRANSACTION " +
+ "SELECT * " +
+ "FROM " + qualifiedAccordTableName + " " +
+ "WHERE k = 42;" +
+ "COMMIT TRANSACTION;";
+ SimpleQueryResult result =
cluster.coordinator(1).executeWithResult(txn, ConsistencyLevel.SERIAL);
+ assertThat(result).hasSize(3)
+ .contains(42, 43, 44)
+ .contains(42, 44, 45)
+ .contains(42, 45, 46);
+ });
+ }
+
+ @Test
+ public void testSaiMultiRowReturn() throws Exception
+ {
+ test(cluster -> {
+ cluster.schemaChange("CREATE INDEX ON " + qualifiedAccordTableName
+ "(v) USING 'sai';");
+ for (int i = 0; i < 3; i++)
+ cluster.coordinator(1).execute(wrapInTxn("INSERT INTO " +
qualifiedAccordTableName + " (k, c, v) VALUES (?, ?, ?)"),
ConsistencyLevel.ALL, 42, 43 + i, 44 + i);
+
+ String txn = "BEGIN TRANSACTION " +
+ "SELECT * " +
+ "FROM " + qualifiedAccordTableName + " " +
+ "WHERE k = 42 AND v = 45;" +
+ "COMMIT TRANSACTION;";
+ SimpleQueryResult result =
cluster.coordinator(1).executeWithResult(txn, ConsistencyLevel.SERIAL);
+ assertThat(result).hasSize(1)
+ .contains(42, 44, 45);
+ });
+ }
+
+ // This fails and it is expected, mostly just here as documentation until
it is fixed
+ @Test
+ public void testSasiMultiRowReturn() throws Exception
Review Comment:
SASI works with `SPRC` now, so this test will fail...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]