Skip to content

Commit

Permalink
make session pool accessible for test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
olavloite committed May 5, 2019
1 parent 1b61e28 commit 829b657
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DatabaseClientImpl implements DatabaseClient {
TraceUtil.exportSpans(READ_WRITE_TRANSACTION, READ_ONLY_TRANSACTION, PARTITION_DML_TRANSACTION);
}

private final SessionPool pool;
@VisibleForTesting final SessionPool pool;

DatabaseClientImpl(SessionPool pool) {
this.pool = pool;
Expand All @@ -52,11 +52,6 @@ PooledSession getReadWriteSession() {
return pool.getReadWriteSession();
}

@VisibleForTesting
int getNumberOfAvailableWritePreparedSessions() {
return pool.getNumberOfAvailableWritePreparedSessions();
}

@Override
public Timestamp write(final Iterable<Mutation> mutations) throws SpannerException {
Span span = tracer.spanBuilder(READ_WRITE_TRANSACTION).startSpan();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public Void call() throws Exception {
service.shutdown();
service.awaitTermination(10L, TimeUnit.SECONDS);
Stopwatch watch = Stopwatch.createStarted();
while (((DatabaseClientImpl) client).getNumberOfAvailableWritePreparedSessions() == 0) {
while (((DatabaseClientImpl) client).pool.getNumberOfAvailableWritePreparedSessions() == 0) {
if (watch.elapsed(TimeUnit.MILLISECONDS) > 1000L) {
fail("No read/write sessions prepared");
}
Expand Down

0 comments on commit 829b657

Please sign in to comment.