Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions test/unit/org/apache/cassandra/cql3/CQLTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public static final ProtocolVersion getDefaultVersion()
}
}

public static ResultMessage lastSchemaChangeResult;
public static volatile ResultMessage lastRecordedSchemaChange;

private List<String> keyspaces = new ArrayList<>();
private List<String> tables = new ArrayList<>();
Expand Down Expand Up @@ -426,19 +426,19 @@ public void run()
try
{
for (int i = tablesToDrop.size() - 1; i >= 0; i--)
schemaChange(String.format("DROP TABLE IF EXISTS %s.%s", KEYSPACE, tablesToDrop.get(i)));
schemaChange(String.format("DROP TABLE IF EXISTS %s.%s", KEYSPACE, tablesToDrop.get(i)), false);

for (int i = aggregatesToDrop.size() - 1; i >= 0; i--)
schemaChange(String.format("DROP AGGREGATE IF EXISTS %s", aggregatesToDrop.get(i)));
schemaChange(String.format("DROP AGGREGATE IF EXISTS %s", aggregatesToDrop.get(i)), false);

for (int i = functionsToDrop.size() - 1; i >= 0; i--)
schemaChange(String.format("DROP FUNCTION IF EXISTS %s", functionsToDrop.get(i)));
schemaChange(String.format("DROP FUNCTION IF EXISTS %s", functionsToDrop.get(i)), false);

for (int i = typesToDrop.size() - 1; i >= 0; i--)
schemaChange(String.format("DROP TYPE IF EXISTS %s.%s", KEYSPACE, typesToDrop.get(i)));
schemaChange(String.format("DROP TYPE IF EXISTS %s.%s", KEYSPACE, typesToDrop.get(i)), false);

for (int i = keyspacesToDrop.size() - 1; i >= 0; i--)
schemaChange(String.format("DROP KEYSPACE IF EXISTS %s", keyspacesToDrop.get(i)));
schemaChange(String.format("DROP KEYSPACE IF EXISTS %s", keyspacesToDrop.get(i)), false);

// Dropping doesn't delete the sstables. It's not a huge deal but it's cleaner to cleanup after us
// Thas said, we shouldn't delete blindly before the TransactionLogs.SSTableTidier for the table we drop
Expand Down Expand Up @@ -949,16 +949,22 @@ protected void assertLastSchemaChange(Event.SchemaChange.Change change, Event.Sc
String keyspace, String name,
String... argTypes)
{
Assert.assertTrue(lastSchemaChangeResult instanceof ResultMessage.SchemaChange);
ResultMessage.SchemaChange schemaChange = (ResultMessage.SchemaChange) lastSchemaChangeResult;
Assert.assertSame(change, schemaChange.change.change);
Assert.assertSame(target, schemaChange.change.target);
Assert.assertEquals(keyspace, schemaChange.change.keyspace);
Assert.assertEquals(name, schemaChange.change.name);
Assert.assertEquals(argTypes != null ? Arrays.asList(argTypes) : null, schemaChange.change.argTypes);
ResultMessage schemaChangeRes = lastRecordedSchemaChange;
Assert.assertTrue(schemaChangeRes instanceof ResultMessage.SchemaChange);
Event.SchemaChange schemaChange = ((ResultMessage.SchemaChange) schemaChangeRes).change;
Assert.assertSame(change, schemaChange.change);
Assert.assertSame(target, schemaChange.target);
Assert.assertEquals(keyspace, schemaChange.keyspace);
Assert.assertEquals(name, schemaChange.name);
Assert.assertEquals(argTypes != null ? Arrays.asList(argTypes) : null, schemaChange.argTypes);
}

protected static void schemaChange(String query)
{
schemaChange(query, true);
}

protected static void schemaChange(String query, boolean recordSchemaChange)
{
try
{
Expand All @@ -970,7 +976,9 @@ protected static void schemaChange(String query)

QueryOptions options = QueryOptions.forInternalCalls(Collections.<ByteBuffer>emptyList());

lastSchemaChangeResult = statement.executeLocally(queryState, options);
ResultMessage result = statement.executeLocally(queryState, options);
if (recordSchemaChange)
lastRecordedSchemaChange = result;
}
catch (Exception e)
{
Expand Down