Skip to content

Commit 14190fe

Browse files
committed
Suffix checks
1 parent 6d18b78 commit 14190fe

File tree

2 files changed

+18
-33
lines changed

2 files changed

+18
-33
lines changed

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

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,18 +2923,6 @@ public void testPartitionedDmlDoesNotTimeout() {
29232923
xGoogReqIdInterceptor.checkExpectedStreamingXGoogRequestIds(wantStreamingValues);
29242924

29252925
XGoogSpannerRequestIdTest.MethodAndRequestId[] wantUnaryValues = {
2926-
XGoogSpannerRequestIdTest.ofMethodAndRequestId(
2927-
"google.spanner.v1.Spanner/BatchCreateSessions",
2928-
new XGoogSpannerRequestId(NON_DETERMINISTIC, NON_DETERMINISTIC, NON_DETERMINISTIC, 1)),
2929-
XGoogSpannerRequestIdTest.ofMethodAndRequestId(
2930-
"google.spanner.v1.Spanner/BatchCreateSessions",
2931-
new XGoogSpannerRequestId(NON_DETERMINISTIC, NON_DETERMINISTIC, NON_DETERMINISTIC, 1)),
2932-
XGoogSpannerRequestIdTest.ofMethodAndRequestId(
2933-
"google.spanner.v1.Spanner/BatchCreateSessions",
2934-
new XGoogSpannerRequestId(NON_DETERMINISTIC, NON_DETERMINISTIC, NON_DETERMINISTIC, 1)),
2935-
XGoogSpannerRequestIdTest.ofMethodAndRequestId(
2936-
"google.spanner.v1.Spanner/BatchCreateSessions",
2937-
new XGoogSpannerRequestId(NON_DETERMINISTIC, NON_DETERMINISTIC, NON_DETERMINISTIC, 1)),
29382926
XGoogSpannerRequestIdTest.ofMethodAndRequestId(
29392927
"google.spanner.v1.Spanner/BeginTransaction",
29402928
new XGoogSpannerRequestId(NON_DETERMINISTIC, channelId, 7, 1)),
@@ -2945,7 +2933,7 @@ public void testPartitionedDmlDoesNotTimeout() {
29452933
"google.spanner.v1.Spanner/ExecuteSql",
29462934
new XGoogSpannerRequestId(NON_DETERMINISTIC, channelId, 8, 1)),
29472935
};
2948-
xGoogReqIdInterceptor.checkExpectedUnaryXGoogRequestIds(wantUnaryValues);
2936+
xGoogReqIdInterceptor.checkExpectedUnaryXGoogRequestIdsAsSuffixes(wantUnaryValues);
29492937
}
29502938
}
29512939

@@ -3045,18 +3033,6 @@ public void testPartitionedDmlWithHigherTimeout() {
30453033
xGoogReqIdInterceptor.checkExpectedStreamingXGoogRequestIds(wantStreamingValues);
30463034

30473035
XGoogSpannerRequestIdTest.MethodAndRequestId[] wantUnaryValues = {
3048-
XGoogSpannerRequestIdTest.ofMethodAndRequestId(
3049-
"google.spanner.v1.Spanner/BatchCreateSessions",
3050-
new XGoogSpannerRequestId(NON_DETERMINISTIC, NON_DETERMINISTIC, NON_DETERMINISTIC, 1)),
3051-
XGoogSpannerRequestIdTest.ofMethodAndRequestId(
3052-
"google.spanner.v1.Spanner/BatchCreateSessions",
3053-
new XGoogSpannerRequestId(NON_DETERMINISTIC, NON_DETERMINISTIC, NON_DETERMINISTIC, 1)),
3054-
XGoogSpannerRequestIdTest.ofMethodAndRequestId(
3055-
"google.spanner.v1.Spanner/BatchCreateSessions",
3056-
new XGoogSpannerRequestId(NON_DETERMINISTIC, NON_DETERMINISTIC, NON_DETERMINISTIC, 1)),
3057-
XGoogSpannerRequestIdTest.ofMethodAndRequestId(
3058-
"google.spanner.v1.Spanner/BatchCreateSessions",
3059-
new XGoogSpannerRequestId(NON_DETERMINISTIC, NON_DETERMINISTIC, NON_DETERMINISTIC, 1)),
30603036
XGoogSpannerRequestIdTest.ofMethodAndRequestId(
30613037
"google.spanner.v1.Spanner/BeginTransaction",
30623038
new XGoogSpannerRequestId(NON_DETERMINISTIC, channelId, 7, 1)),
@@ -3067,7 +3043,7 @@ public void testPartitionedDmlWithHigherTimeout() {
30673043
"google.spanner.v1.Spanner/ExecuteSql",
30683044
new XGoogSpannerRequestId(NON_DETERMINISTIC, channelId, 8, 1)),
30693045
};
3070-
xGoogReqIdInterceptor.checkExpectedUnaryXGoogRequestIds(wantUnaryValues);
3046+
xGoogReqIdInterceptor.checkExpectedUnaryXGoogRequestIdsAsSuffixes(wantUnaryValues);
30713047
}
30723048
}
30733049

@@ -5406,17 +5382,11 @@ public void testSessionPoolExhaustedError_containsStackTraces() {
54065382
long NON_DETERMINISTIC = XGoogSpannerRequestIdTest.NON_DETERMINISTIC;
54075383

54085384
XGoogSpannerRequestIdTest.MethodAndRequestId[] wantUnaryValues = {
5409-
XGoogSpannerRequestIdTest.ofMethodAndRequestId(
5410-
"google.spanner.v1.Spanner/BatchCreateSessions",
5411-
new XGoogSpannerRequestId(NON_DETERMINISTIC, NON_DETERMINISTIC, NON_DETERMINISTIC, 1)),
5412-
XGoogSpannerRequestIdTest.ofMethodAndRequestId(
5413-
"google.spanner.v1.Spanner/BatchCreateSessions",
5414-
new XGoogSpannerRequestId(NON_DETERMINISTIC, NON_DETERMINISTIC, NON_DETERMINISTIC, 1)),
54155385
XGoogSpannerRequestIdTest.ofMethodAndRequestId(
54165386
"google.spanner.v1.Spanner/CreateSession",
54175387
new XGoogSpannerRequestId(NON_DETERMINISTIC, 0, 1, 1)),
54185388
};
5419-
xGoogReqIdInterceptor.checkExpectedUnaryXGoogRequestIds(wantUnaryValues);
5389+
xGoogReqIdInterceptor.checkExpectedUnaryXGoogRequestIdsAsSuffixes(wantUnaryValues);
54205390
}
54215391
}
54225392

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,21 @@ public void checkAtLeastHasExpectedUnaryXGoogRequestIds(MethodAndRequestId... wa
206206
}
207207
}
208208

209+
public void checkExpectedUnaryXGoogRequestIdsAsSuffixes(MethodAndRequestId... wantUnaryValues) {
210+
MethodAndRequestId[] gotUnaryValues = this.accumulatedUnaryValues();
211+
sortValues(gotUnaryValues);
212+
for (int i = 0; i < gotUnaryValues.length && false; i++) {
213+
System.out.println("\033[33misUnary: #" + i + ":: " + gotUnaryValues[i] + "\033[00m");
214+
}
215+
if (wantUnaryValues.length < gotUnaryValues.length) {
216+
MethodAndRequestId[] gotSliced =
217+
Arrays.copyOfRange(gotUnaryValues, wantUnaryValues.length+1, gotUnaryValues.length);
218+
assertEquals(wantUnaryValues, gotSliced);
219+
} else {
220+
assertEquals(wantUnaryValues, gotUnaryValues);
221+
}
222+
}
223+
209224
private void sortValues(MethodAndRequestId[] values) {
210225
massageValues(values);
211226
Arrays.sort(values, new MethodAndRequestIdComparator());

0 commit comments

Comments
 (0)