Skip to content

chore(x-goog-spanner-request-id): enable tests for more RPCs #3898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ public boolean equals(Object o) {
if (this.reqId == null || other.reqId == null) {
return this.reqId == null && other.reqId == null;
}
Comment on lines 1101 to 1103
Copy link
Collaborator

@olavloite olavloite Jun 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you can remove this as well when you use Objects.equals(...) (feel free to do in a following PR)

Suggested change
if (this.reqId == null || other.reqId == null) {
return this.reqId == null && other.reqId == null;
}

return this.reqId.equals(other.reqId);
return Objects.equals(this.reqId, other.reqId);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.google.cloud.spanner;

import com.google.api.core.InternalApi;
import com.google.api.gax.rpc.ApiException;
import com.google.api.gax.rpc.ErrorDetails;
import com.google.cloud.grpc.BaseGrpcServiceException;
Expand Down Expand Up @@ -198,7 +199,8 @@ public ErrorDetails getErrorDetails() {
return null;
}

/** Sets the requestId. This method is meant to be used internally and not by customers. */
/** Sets the requestId. */
@InternalApi
public void setRequestId(XGoogSpannerRequestId reqId) {
this.requestId = reqId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,20 +228,22 @@ public static void startStaticServer() throws IOException {
Set<String> checkMethods =
new HashSet(
Arrays.asList(
"google.spanner.v1.Spanner/BatchCreateSessions"
// As functionality is added, uncomment each method.
// "google.spanner.v1.Spanner/BatchWrite",
// "google.spanner.v1.Spanner/BeginTransaction",
// "google.spanner.v1.Spanner/CreateSession",
// "google.spanner.v1.Spanner/DeleteSession",
// "google.spanner.v1.Spanner/ExecuteBatchDml",
// "google.spanner.v1.Spanner/ExecuteSql",
// "google.spanner.v1.Spanner/ExecuteStreamingSql",
// "google.spanner.v1.Spanner/StreamingRead",
// "google.spanner.v1.Spanner/PartitionQuery",
// "google.spanner.v1.Spanner/PartitionRead",
// "google.spanner.v1.Spanner/Commit",
));
"google.spanner.v1.Spanner/BatchCreateSessions",
"google.spanner.v1.Spanner/BatchWrite",
"google.spanner.v1.Spanner/BeginTransaction",
"google.spanner.v1.Spanner/Commit",
"google.spanner.v1.Spanner/CreateSession",
"google.spanner.v1.Spanner/DeleteSession",
"google.spanner.v1.Spanner/ExecuteBatchDml",
"google.spanner.v1.Spanner/ExecuteSql",
"google.spanner.v1.Spanner/ExecuteStreamingSql",
"google.spanner.v1.Spanner/GetSession",
"google.spanner.v1.Spanner/ListSessions",
"google.spanner.v1.Spanner/PartitionQuery",
"google.spanner.v1.Spanner/PartitionRead",
"google.spanner.v1.Spanner/Read",
"google.spanner.v1.Spanner/Rollback",
"google.spanner.v1.Spanner/StreamingRead"));
xGoogReqIdInterceptor = new XGoogSpannerRequestIdTest.ServerHeaderEnforcer(checkMethods);
executor = Executors.newSingleThreadExecutor();
String uniqueName = InProcessServerBuilder.generateName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public class PartitionedDmlTransactionTest {
public void setup() {
MockitoAnnotations.initMocks(this);
when(session.getName()).thenReturn(sessionId);
when(session.getRequestIdCreator())
.thenReturn(new XGoogSpannerRequestId.NoopRequestIdCreator());
when(session.getOptions()).thenReturn(Collections.EMPTY_MAP);
when(session.getRequestIdCreator())
.thenReturn(new XGoogSpannerRequestId.NoopRequestIdCreator());
Expand Down