Fix flaky test LocalReadSizeWarningTest#failThresholdSinglePartition

patch by Bernardo Botella Corbi; reviewed by Andres de la Peña, Yifan Cai for CASSANDRA-17217
This commit is contained in:
Bernardo Botella Corbi 2022-04-12 11:06:41 -07:00 committed by Yifan Cai
parent 6013f16de7
commit 2fe1c30483
2 changed files with 36 additions and 7 deletions

View File

@ -211,15 +211,27 @@ public abstract class AbstractClientSizeWarning extends TestBaseImpl
}
@Test
public void failThresholdSinglePartition() throws UnknownHostException
public void failThresholdSinglePartitionTrackingEnabled() throws UnknownHostException
{
failThreshold(CQL_PK_READ);
failThresholdEnabled(CQL_PK_READ);
}
@Test
public void failThresholdScan() throws UnknownHostException
public void failThresholdSinglePartitionTrackingDisabled() throws UnknownHostException
{
failThreshold(CQL_TABLE_SCAN);
failThresholdDisabled(CQL_PK_READ);
}
@Test
public void failThresholdScanTrackingEnabled() throws UnknownHostException
{
failThresholdEnabled(CQL_TABLE_SCAN);
}
@Test
public void failThresholdScanTrackingDisabled() throws UnknownHostException
{
failThresholdDisabled(CQL_TABLE_SCAN);
}
protected int failThresholdRowCount()
@ -227,7 +239,7 @@ public abstract class AbstractClientSizeWarning extends TestBaseImpl
return 5;
}
public void failThreshold(String cql) throws UnknownHostException
public void failThresholdEnabled(String cql) throws UnknownHostException
{
ICoordinator node = CLUSTER.coordinator(1);
for (int i = 0; i < failThresholdRowCount(); i++)
@ -283,15 +295,26 @@ public abstract class AbstractClientSizeWarning extends TestBaseImpl
}
assertHistogramUpdated();
assertWarnAborts(0, 2, 1);
}
public void failThresholdDisabled(String cql) throws UnknownHostException
{
ICoordinator node = CLUSTER.coordinator(1);
for (int i = 0; i < failThresholdRowCount(); i++)
node.execute("INSERT INTO " + KEYSPACE + ".tbl (pk, ck, v) VALUES (1, ?, ?)", ConsistencyLevel.ALL, i + 1, bytes(512));
if (shouldFlush())
CLUSTER.stream().forEach(i -> i.flush(KEYSPACE));
// query should no longer fail
enable(false);
checkpointHistogram();
SimpleQueryResult result = node.executeWithResult(cql, ConsistencyLevel.ALL);
assertThat(result.warnings()).isEmpty();
assertHistogramNotUpdated();
assertThat(driverQueryAll(cql).getExecutionInfo().getWarnings()).isEmpty();
assertHistogramNotUpdated();
assertWarnAborts(0, 2, 0);
assertWarnAborts(0, 0, 0);
}
protected static void enable(boolean value)

View File

@ -84,7 +84,13 @@ public class RowIndexSizeWarningTest extends AbstractClientSizeWarning
}
@Override
public void failThresholdScan()
public void failThresholdScanTrackingEnabled()
{
Assume.assumeFalse("Ignore Scans", true);
}
@Override
public void failThresholdScanTrackingDisabled()
{
Assume.assumeFalse("Ignore Scans", true);
}