Skip to content

Commit 80c5685

Browse files
ci(spanner): Skip failing Directpath tests due to missing trailers (#4002)
* ci(spanner): Skip failing Directpath tests due to missing trailers * Add tests to fail if gRPC trailers are present
1 parent 8bc7c0a commit 80c5685

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

google-cloud-spanner/src/test/java/com/google/cloud/spanner/ITTransactionRetryTest.java

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818

1919
import static com.google.cloud.spanner.testing.EmulatorSpannerHelper.isUsingEmulator;
2020
import static com.google.common.truth.Truth.assertThat;
21+
import static org.junit.Assert.assertFalse;
2122
import static org.junit.Assert.assertTrue;
2223
import static org.junit.Assume.assumeFalse;
24+
import static org.junit.Assume.assumeTrue;
2325

2426
import org.junit.ClassRule;
2527
import org.junit.Test;
@@ -36,6 +38,10 @@ public class ITTransactionRetryTest {
3638
@Test
3739
public void TestRetryInfo() {
3840
assumeFalse("emulator does not support parallel transaction", isUsingEmulator());
41+
// TODO(sakthivelmani) - Re-enable once b/422916293 is resolved
42+
assumeFalse(
43+
"Skipping the test due to a known bug b/422916293",
44+
env.getTestHelper().getOptions().isEnableDirectAccess());
3945

4046
// Creating a database with the table which contains INT64 columns
4147
Database db =
@@ -80,4 +86,56 @@ public void TestRetryInfo() {
8086

8187
assertTrue("Transaction is not aborted with the trailers", isAbortedWithRetryInfo);
8288
}
89+
90+
@Test
91+
public void TestRetryInfoWithDirectPath() {
92+
assumeFalse("emulator does not support parallel transaction", isUsingEmulator());
93+
// TODO(sakthivelmani) - Re-enable once b/422916293 is resolved
94+
assumeTrue(
95+
"Enabling this test due to bug b/422916293",
96+
env.getTestHelper().getOptions().isEnableDirectAccess());
97+
98+
// Creating a database with the table which contains INT64 columns
99+
Database db =
100+
env.getTestHelper()
101+
.createTestDatabase("CREATE TABLE Test(ID INT64, " + "EMPID INT64) PRIMARY KEY (ID)");
102+
DatabaseClient databaseClient = env.getTestHelper().getClient().getDatabaseClient(db.getId());
103+
104+
// Inserting one row
105+
databaseClient
106+
.readWriteTransaction()
107+
.run(
108+
transaction -> {
109+
transaction.buffer(
110+
Mutation.newInsertBuilder("Test").set("ID").to(1).set("EMPID").to(1).build());
111+
return null;
112+
});
113+
114+
int numRetries = 10;
115+
boolean isAbortedWithRetryInfo = false;
116+
while (numRetries-- > 0) {
117+
try (TransactionManager transactionManager1 = databaseClient.transactionManager()) {
118+
try (TransactionManager transactionManager2 = databaseClient.transactionManager()) {
119+
try {
120+
TransactionContext transaction1 = transactionManager1.begin();
121+
TransactionContext transaction2 = transactionManager2.begin();
122+
transaction1.executeUpdate(
123+
Statement.of("UPDATE Test SET EMPID = EMPID + 1 WHERE ID = 1"));
124+
transaction2.executeUpdate(
125+
Statement.of("UPDATE Test SET EMPID = EMPID + 1 WHERE ID = 1"));
126+
transactionManager1.commit();
127+
transactionManager2.commit();
128+
} catch (AbortedException abortedException) {
129+
assertThat(abortedException.getErrorCode()).isEqualTo(ErrorCode.ABORTED);
130+
if (abortedException.getRetryDelayInMillis() > 0) {
131+
isAbortedWithRetryInfo = true;
132+
break;
133+
}
134+
}
135+
}
136+
}
137+
}
138+
139+
assertFalse("Transaction is aborted with the trailers", isAbortedWithRetryInfo);
140+
}
83141
}

google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/it/ITRetryDmlAsPartitionedDmlTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ public static void setupTestData() {
8686

8787
@Test
8888
public void testDmlFailsIfMutationLimitExceeded() {
89+
// TODO(sakthivelmani) - Re-enable once b/422916293 is resolved
90+
assumeFalse(
91+
"Skipping the test due to a known bug b/422916293",
92+
env.getTestHelper().getOptions().isEnableDirectAccess());
8993
try (Connection connection = createConnection()) {
9094
connection.setAutocommit(true);
9195
assertThrows(
@@ -98,6 +102,10 @@ public void testDmlFailsIfMutationLimitExceeded() {
98102

99103
@Test
100104
public void testRetryDmlAsPartitionedDml() throws Exception {
105+
// TODO(sakthivelmani) - Re-enable once b/422916293 is resolved
106+
assumeFalse(
107+
"Skipping the test due to a known bug b/422916293",
108+
env.getTestHelper().getOptions().isEnableDirectAccess());
101109
try (Connection connection = createConnection()) {
102110
connection.setAutocommit(true);
103111
connection.setAutocommitDmlMode(
@@ -138,6 +146,10 @@ public void retryDmlAsPartitionedDmlFinished(
138146

139147
@Test
140148
public void testRetryDmlAsPartitionedDml_failsForLargeInserts() throws Exception {
149+
// TODO(sakthivelmani) - Re-enable once b/422916293 is resolved
150+
assumeFalse(
151+
"Skipping the test due to a known bug b/422916293",
152+
env.getTestHelper().getOptions().isEnableDirectAccess());
141153
try (Connection connection = createConnection()) {
142154
connection.setAutocommit(true);
143155
connection.setAutocommitDmlMode(

0 commit comments

Comments
 (0)