Skip to content

Commit 6b7e755

Browse files
committed
Fix flaky DiskSpaceMetricsTest
1 parent a38d50f commit 6b7e755

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

test/unit/org/apache/cassandra/io/DiskSpaceMetricsTest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ public void summaryRedistribution() throws Throwable
9999
@Test
100100
public void testFlushSize() throws Throwable
101101
{
102-
createTable("CREATE TABLE %s (pk bigint, PRIMARY KEY (pk))");
103-
ColumnFamilyStore cfs = getCurrentColumnFamilyStore();
102+
createTable(KEYSPACE_PER_TEST, "CREATE TABLE %s (pk bigint, PRIMARY KEY (pk))");
103+
ColumnFamilyStore cfs = getCurrentColumnFamilyStore(KEYSPACE_PER_TEST);
104104
assertTrue(Double.isNaN(cfs.metric.flushSizeOnDisk.get()));
105105

106106
// disable compaction so nothing changes between calculations
107107
cfs.disableAutoCompaction();
108108

109109
for (int i = 0; i < 3; i++)
110-
insertN(cfs, 1000, 55);
110+
insertN(KEYSPACE_PER_TEST, cfs, 1000, 55);
111111

112112
int totalSize = 0;
113113
final Set<SSTableReader> liveSSTables = cfs.getLiveSSTables();
@@ -125,9 +125,14 @@ private void insert(ColumnFamilyStore cfs, long value) throws Throwable
125125
}
126126

127127
private void insertN(ColumnFamilyStore cfs, int n, long base) throws Throwable
128+
{
129+
insertN(KEYSPACE, cfs, n, base);
130+
}
131+
132+
private void insertN(String keyspace, ColumnFamilyStore cfs, int n, long base) throws Throwable
128133
{
129134
for (int i = 0; i < n; i++)
130-
execute("INSERT INTO %s (pk) VALUES (?)", base + i);
135+
executeFormattedQuery(formatQuery(keyspace, "INSERT INTO %s (pk) VALUES (?)"), base + i);
131136

132137
// flush to write the sstable
133138
Util.flush(cfs);

0 commit comments

Comments
 (0)