in grpc-gcp-benchmarks/src/benchmarkTest/java/SpannerLoadTest.java [164:187]
public static void testListSessionsAsync() throws InterruptedException {
logger.info("Start testing ListSessions StreamObserver..");
File configFile =
new File(SpannerLoadTest.class.getClassLoader().getResource(API_FILE).getFile());
ManagedChannel channel =
GcpManagedChannelBuilder.forDelegateBuilder(builder)
.withApiConfigJsonFile(configFile)
.build();
SpannerStub stub = getSpannerStub(channel);
List<String> respNames = createAsyncSessions(stub);
AsyncResponseObserver<ListSessionsResponse> respList = new AsyncResponseObserver<>();
stub.listSessions(ListSessionsRequest.newBuilder().setDatabase(DATABASE).build(), respList);
ListSessionsResponse responseList = respList.get();
Set<String> trueNames = new HashSet<>();
for (Session s : responseList.getSessionsList()) {
trueNames.add(s.getName());
}
for (String name : respNames) {
if (!trueNames.contains(name)) {
logger.warning(String.format("Listed Sessions doesn't contain session %s", name));
}
}
deleteAsyncSessions(stub, respNames);
}