Skip to content

Commit a882204

Browse files
feat: Use multiplex sessions for RW and Partition Ops (#3996)
* feat: Use multiplex sessions for RW and Partition Ops * Fix emulator tests
1 parent 93ca52e commit a882204

File tree

5 files changed

+21
-12
lines changed

5 files changed

+21
-12
lines changed

.kokoro/presubmit/integration-regular-sessions-enabled.cfg

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,14 @@ env_vars: {
3535
env_vars: {
3636
key: "GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS"
3737
value: "false"
38-
}
38+
}
39+
40+
env_vars: {
41+
key: "GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS_PARTITIONED_OPS"
42+
value: "false"
43+
}
44+
45+
env_vars: {
46+
key: "GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS_FOR_RW"
47+
value: "false"
48+
}

google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,13 +619,13 @@ public static class Builder {
619619
// client.
620620
// Set useMultiplexedSessionForRW to true to make multiplexed session for RW operations the
621621
// default.
622-
private boolean useMultiplexedSessionForRW = false;
622+
private boolean useMultiplexedSessionForRW = true;
623623

624624
// This field controls the default behavior of session management for Partitioned operations in
625625
// Java client.
626626
// Set useMultiplexedSessionPartitionedOps to true to make multiplexed session for Partitioned
627627
// operations the default.
628-
private boolean useMultiplexedSessionPartitionedOps = false;
628+
private boolean useMultiplexedSessionPartitionedOps = true;
629629

630630
private Duration multiplexedSessionMaintenanceDuration = Duration.ofDays(7);
631631
private Clock poolMaintainerClock = Clock.INSTANCE;

google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDatabaseTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ public void databaseDeletedTest() throws Exception {
150150
}
151151
}
152152
}
153-
assertThat(notFoundException).isNotNull();
153+
if (!isUsingEmulator()) {
154+
assertThat(notFoundException).isNotNull();
155+
}
154156

155157
// Now get a new DatabaseClient for the database. This should now result in a valid
156158
// DatabaseClient.

google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITJsonWriteReadTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.cloud.spanner.it;
1818

19+
import static com.google.cloud.spanner.testing.EmulatorSpannerHelper.isUsingEmulator;
1920
import static org.junit.Assert.assertEquals;
2021
import static org.junit.Assert.assertThrows;
2122

@@ -132,10 +133,8 @@ public void testWriteAndReadInvalidJsonValues() throws IOException {
132133
.to(Value.json(jsonStr))
133134
.build())));
134135

135-
if (env.getTestHelper()
136-
.getOptions()
137-
.getSessionPoolOptions()
138-
.getUseMultiplexedSessionForRW()) {
136+
if (env.getTestHelper().getOptions().getSessionPoolOptions().getUseMultiplexedSessionForRW()
137+
&& !isUsingEmulator()) {
139138
assertEquals(ErrorCode.INVALID_ARGUMENT, exception.getErrorCode());
140139
} else {
141140
assertEquals(ErrorCode.FAILED_PRECONDITION, exception.getErrorCode());

google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITWriteTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,10 +1081,8 @@ public void incorrectType() {
10811081
write(baseInsert().set("StringValue").to(1.234).build());
10821082
fail("Expected exception");
10831083
} catch (SpannerException ex) {
1084-
if (env.getTestHelper()
1085-
.getOptions()
1086-
.getSessionPoolOptions()
1087-
.getUseMultiplexedSessionForRW()) {
1084+
if (env.getTestHelper().getOptions().getSessionPoolOptions().getUseMultiplexedSessionForRW()
1085+
&& !isUsingEmulator()) {
10881086
assertThat(ex.getErrorCode()).isEqualTo(ErrorCode.INVALID_ARGUMENT);
10891087
} else {
10901088
assertThat(ex.getErrorCode()).isEqualTo(ErrorCode.FAILED_PRECONDITION);

0 commit comments

Comments
 (0)