From aac7cf76218f75f6f55ef18426438b9a8d9ba6d4 Mon Sep 17 00:00:00 2001 From: Olav Loite Date: Thu, 14 May 2020 08:19:55 +0200 Subject: [PATCH] tests: add test for retry on UNAVAILABLE --- .../cloud/spanner/DatabaseClientImplTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java index 30e55b521c..3b61e0cb92 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java @@ -324,6 +324,23 @@ public Long run(TransactionContext transaction) throws Exception { } } + @Test + public void testPartitionedDmlRetriesOnUnavailable() throws Exception { + mockSpanner.setExecuteSqlExecutionTime( + SimulatedExecutionTime.ofException(Status.UNAVAILABLE.asRuntimeException())); + SpannerOptions.Builder builder = + SpannerOptions.newBuilder() + .setProjectId(TEST_PROJECT) + .setChannelProvider(channelProvider) + .setCredentials(NoCredentials.getInstance()); + try (Spanner spanner = builder.build().getService()) { + DatabaseClient client = + spanner.getDatabaseClient(DatabaseId.of(TEST_PROJECT, TEST_INSTANCE, TEST_DATABASE)); + long updateCount = client.executePartitionedUpdate(UPDATE_STATEMENT); + assertThat(updateCount).isEqualTo(UPDATE_COUNT); + } + } + @Test public void testDatabaseOrInstanceDoesNotExistOnPrepareSession() throws Exception { StatusRuntimeException[] exceptions =