clohfink commented on a change in pull request #719:
URL: https://github.com/apache/cassandra/pull/719#discussion_r494312422
##########
File path:
test/unit/org/apache/cassandra/transport/InflightRequestPayloadTrackerTest.java
##########
@@ -69,137 +82,115 @@ public void dropCreatedTable()
}
}
+ private SimpleClient client() throws IOException
+ {
+ return new SimpleClient(nativeAddr.getHostAddress(),
+ nativePort,
+ ProtocolVersion.V5,
+ true,
+ new EncryptionOptions())
+ .connect(false, false, true);
+ }
+
@Test
public void testQueryExecutionWithThrowOnOverload() throws Throwable
{
- SimpleClient client = new SimpleClient(nativeAddr.getHostAddress(),
- nativePort,
- ProtocolVersion.V5,
- true,
- new EncryptionOptions());
-
- try
+ try (SimpleClient client = client())
{
- client.connect(false, false, true);
- QueryOptions queryOptions = QueryOptions.create(
- QueryOptions.DEFAULT.getConsistency(),
- QueryOptions.DEFAULT.getValues(),
- QueryOptions.DEFAULT.skipMetadata(),
- QueryOptions.DEFAULT.getPageSize(),
- QueryOptions.DEFAULT.getPagingState(),
- QueryOptions.DEFAULT.getSerialConsistency(),
- ProtocolVersion.V5,
- KEYSPACE);
-
QueryMessage queryMessage = new QueryMessage("CREATE TABLE atable
(pk1 int PRIMARY KEY, v text)",
- queryOptions);
+ V5_DEFAULT_OPTIONS);
client.execute(queryMessage);
}
- finally
- {
- client.close();
- }
}
@Test
public void testQueryExecutionWithoutThrowOnOverload() throws Throwable
{
- SimpleClient client = new SimpleClient(nativeAddr.getHostAddress(),
- nativePort,
- ProtocolVersion.V5,
- true,
- new EncryptionOptions());
-
- try
+ try (SimpleClient client = client())
{
client.connect(false, false, false);
- QueryOptions queryOptions = QueryOptions.create(
- QueryOptions.DEFAULT.getConsistency(),
- QueryOptions.DEFAULT.getValues(),
- QueryOptions.DEFAULT.skipMetadata(),
- QueryOptions.DEFAULT.getPageSize(),
- QueryOptions.DEFAULT.getPagingState(),
- QueryOptions.DEFAULT.getSerialConsistency(),
- ProtocolVersion.V5,
- KEYSPACE);
QueryMessage queryMessage = new QueryMessage("CREATE TABLE atable
(pk int PRIMARY KEY, v text)",
- queryOptions);
+ V5_DEFAULT_OPTIONS);
client.execute(queryMessage);
queryMessage = new QueryMessage("SELECT * FROM atable",
- queryOptions);
+ V5_DEFAULT_OPTIONS);
client.execute(queryMessage);
}
- finally
+ }
+
+ @Test
+ public void testQueryUpdatesConcurrentMetricsUpdate() throws Throwable
+ {
+ try (SimpleClient client = client())
{
- client.close();
+ final QueryMessage create = new QueryMessage("CREATE TABLE atable
(pk int PRIMARY KEY, v text)",
+ V5_DEFAULT_OPTIONS);
+ client.execute(create);
+
+ final QueryMessage queryMessage = new QueryMessage("SELECT * FROM
atable",
+
V5_DEFAULT_OPTIONS);
+
+ Assert.assertEquals(0L,
Server.EndpointPayloadTracker.getCurrentGlobalUsage());
+ AtomicBoolean running = new AtomicBoolean(true);
+ // run query serially on repeat
+ new Thread(() ->
+ {
+ while (running.get())
+ {
+ client.execute(queryMessage);
+ }
+ }).start();
+
+ // checking metric may occur inbetween running of query, so check
multiple times for up to 2 seconds
+ long start = System.currentTimeMillis();
+ while (running.get() && System.currentTimeMillis() - start < 2000)
Review comment:
changed to use locks with a virtual table to remove any flakiness
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]