Skip to content

Commit

Permalink
tests: fix failing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
olavloite committed Mar 13, 2020
1 parent f032d17 commit 57fbcb5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Expand Up @@ -45,6 +45,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.hamcrest.BaseMatcher;
Expand Down Expand Up @@ -252,18 +253,18 @@ public void backupCreateCancel() {
RetryingFuture<OperationSnapshot> pollingFuture = op.getPollingFuture();
// Wait for the operation to finish.
// isDone will return true if the operation has finished successfully or if it was cancelled
// or any other error occurred..
// or any other error occurred.
while (!pollingFuture.get().isDone()) {
Thread.sleep(TimeUnit.MILLISECONDS.convert(5, TimeUnit.SECONDS));
}
if (pollingFuture.get().getErrorCode() == null) {
// The cancellation of the backup creation failed. Delete the backup.
backup.delete();
}
} catch (CancellationException e) {
// ignore, this exception may also occur if the polling future has been cancelled.
} catch (ExecutionException e) {
throw (SpannerException) e.getCause();
throw (RuntimeException) e.getCause();
} catch (InterruptedException e) {
throw SpannerExceptionFactory.propagateInterrupt(e);
} finally {
backup.delete();
}
}

Expand Down
Expand Up @@ -148,9 +148,9 @@ public void cancelOperation(
.build())
.build());
fut.cancel(true);
responseObserver.onNext(Empty.getDefaultInstance());
responseObserver.onCompleted();
}
responseObserver.onNext(Empty.getDefaultInstance());
responseObserver.onCompleted();
} else {
responseObserver.onError(Status.NOT_FOUND.asRuntimeException());
}
Expand Down
Expand Up @@ -316,7 +316,7 @@ public void testBackups() throws InterruptedException, ExecutionException {
.doesNotContain(backup1);

// Test pagination.
testPagination(3);
testPagination(2);
logger.info("Finished listBackup tests");

// Execute other tests as part of this integration test to reduce total execution time.
Expand Down

0 comments on commit 57fbcb5

Please sign in to comment.