diff --git a/test/distributed/org/apache/cassandra/distributed/test/AbstractNetstatsStreaming.java b/test/distributed/org/apache/cassandra/distributed/test/AbstractNetstatsStreaming.java index 2e828e0c15..93d26f1235 100644 --- a/test/distributed/org/apache/cassandra/distributed/test/AbstractNetstatsStreaming.java +++ b/test/distributed/org/apache/cassandra/distributed/test/AbstractNetstatsStreaming.java @@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory; import com.datastax.driver.core.Session; import org.apache.cassandra.distributed.Cluster; import org.apache.cassandra.distributed.api.IInvokableInstance; +import org.apache.cassandra.distributed.api.LogResult; import org.apache.cassandra.distributed.api.NodeToolResult; import org.apache.cassandra.utils.Pair; @@ -509,6 +510,7 @@ public abstract class AbstractNetstatsStreaming extends TestBaseImpl boolean sawAnyStreamingOutput = false; + long mark = 0; while (true) { try @@ -523,6 +525,20 @@ public abstract class AbstractNetstatsStreaming extends TestBaseImpl { sawAnyStreamingOutput = true; } + else + { + // there is a race condition that streaming starts/stops between calls to netstats + // to detect this, check to see if the node has completed a stream + // expected log: [Stream (.*)?] All sessions completed + LogResult> logs = node.logs().grep(mark, "\\[Stream .*\\] All sessions completed"); + mark = logs.getMark(); + if (!logs.getResult().isEmpty()) + { + // race condition detected... + logger.info("Test race condition detected where streaming started/stopped between calls to netstats"); + sawAnyStreamingOutput = true; + } + } } if (sawAnyStreamingOutput && (!result.getStdout().contains("Receiving") && !result.getStdout().contains("Sending")))