diff --git a/test/distributed/org/apache/cassandra/distributed/test/ByteBuddyExamplesTest.java b/test/distributed/org/apache/cassandra/distributed/test/ByteBuddyExamplesTest.java index aea3609c84bb..d6abd3578861 100644 --- a/test/distributed/org/apache/cassandra/distributed/test/ByteBuddyExamplesTest.java +++ b/test/distributed/org/apache/cassandra/distributed/test/ByteBuddyExamplesTest.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; import org.junit.Test; @@ -28,6 +29,7 @@ import net.bytebuddy.dynamic.loading.ClassLoadingStrategy; import net.bytebuddy.implementation.MethodDelegation; import net.bytebuddy.implementation.bind.annotation.SuperCall; +import org.apache.cassandra.cql3.ColumnSpecification; import org.apache.cassandra.cql3.QueryOptions; import org.apache.cassandra.cql3.statements.ModificationStatement; import org.apache.cassandra.cql3.statements.SelectStatement; @@ -35,6 +37,7 @@ import org.apache.cassandra.distributed.api.ConsistencyLevel; import org.apache.cassandra.service.QueryState; import org.apache.cassandra.transport.messages.ResultMessage; +import org.apache.cassandra.transport.messages.ResultMessage.Rows; import static net.bytebuddy.matcher.ElementMatchers.named; import static net.bytebuddy.matcher.ElementMatchers.takesArguments; @@ -86,7 +89,7 @@ public void countTest() throws IOException .withInstanceInitializer(BBCountHelper::install) .start())) { - cluster.schemaChange("create table " + KEYSPACE + ".tbl (id int primary key, t int)"); + cluster.schemaChange("create table " + KEYSPACE + ".tbl (id int primary key, bytebuddy_test_column int)"); cluster.coordinator(1).execute("select * from " + KEYSPACE + ".tbl;", ConsistencyLevel.ALL); cluster.coordinator(2).execute("select * from " + KEYSPACE + ".tbl;", ConsistencyLevel.ALL); cluster.get(1).runOnInstance(() -> { @@ -115,8 +118,12 @@ static void install(ClassLoader cl, int nodeNumber) public static ResultMessage.Rows execute(QueryState state, QueryOptions options, long queryStartNanoTime, @SuperCall Callable r) throws Exception { - count.incrementAndGet(); - return r.call(); + Rows res = r.call(); + + if (res.result.metadata.names.stream().map(ColumnSpecification::toString).collect(Collectors.toList()).contains("bytebuddy_test_column")) + count.incrementAndGet(); + + return res; } }