-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[BEAM-12164]: Add sad path tests for Cloud Spanner's ReadChangeStream #16846
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
Conversation
| testImplementation library.java.powermock | ||
| testImplementation library.java.powermock_mockito | ||
| testImplementation library.java.joda_time | ||
| testImplementation "com.google.cloud:google-cloud-spanner:6.17.4:tests" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the version come from the BOM? (if you remove the version, does it work?)
Could you create a variable as the other libraries (e.g. library.java.spanner.tests)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't work if I remove the version, but I've moved this to BeamModulePlugin.groovy with the versions defined by variables
.../google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerAccessor.java
Show resolved
Hide resolved
...-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/changestreams/dao/DaoFactory.java
Outdated
Show resolved
Hide resolved
...test/java/org/apache/beam/sdk/io/gcp/spanner/changestreams/SpannerChangeStreamErrorTest.java
Outdated
Show resolved
Hide resolved
...test/java/org/apache/beam/sdk/io/gcp/spanner/changestreams/SpannerChangeStreamErrorTest.java
Outdated
Show resolved
Hide resolved
...test/java/org/apache/beam/sdk/io/gcp/spanner/changestreams/SpannerChangeStreamErrorTest.java
Outdated
Show resolved
Hide resolved
thiagotnunes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM with a few nits.
Do we need to add documentation (javadocs) for the new options?
| def classgraph_version = "4.8.104" | ||
| def errorprone_version = "2.10.0" | ||
| // Try to keep gax_version consistent with gax-grpc version in google_cloud_platform_libraries_bom | ||
| def gax_version = "2.8.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this one will work without the version as the BOM defines a version for it (https://mvnrepository.com/artifact/com.google.cloud/libraries-bom/24.2.0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is ok, thanks for trying
.../google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerAccessor.java
Show resolved
Hide resolved
...test/java/org/apache/beam/sdk/io/gcp/spanner/changestreams/SpannerChangeStreamErrorTest.java
Show resolved
Hide resolved
|
|
||
| Statement changeStreamQueryStatement = | ||
| Statement.newBuilder( | ||
| "SELECT * FROM READ_my-change-stream( start_timestamp => @startTimestamp, end_timestamp => @endTimestamp, partition_token => @partitionToken, read_options => null, heartbeat_milliseconds => @heartbeatMillis)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we could remove the extra spacing here (probably spotless added it when merging lines into one)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually how it looks in the actual request statement, I believe the test will fail if I take out the spaces — https://github.com/googleapis/java-spanner/blob/main/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MockSpannerServiceImpl.java#L113
|
You should change the title to match the JIRA ticket |
Codecov Report
@@ Coverage Diff @@
## master #16846 +/- ##
==========================================
+ Coverage 74.63% 83.63% +8.99%
==========================================
Files 655 453 -202
Lines 82237 62471 -19766
==========================================
- Hits 61380 52245 -9135
+ Misses 19861 10226 -9635
+ Partials 996 0 -996
Continue to review full report at Codecov.
|
|
Hey @pabloem could you please review this PR? |
|
@thiagotnunes I've made a PR (#16879) with the javadocs which I'll rebase once this PR is merged. |
|
once again I'm sorry about the delay. Taking a look now! |
| builder.setEmulatorHost(emulatorHost.get()); | ||
| if (spannerConfig.getIsLocalChannelProvider() != null | ||
| && spannerConfig.getIsLocalChannelProvider().get()) { | ||
| builder.setChannelProvider(LocalChannelProvider.create(emulatorHost.get())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any chance of passing the LocalChannelProvider from the test to avoid depending on gax_grpc_test in the main package? It's not mandatory, but it would make life easier for like 1% of users, who, may have version clashes with that at some point : )
pabloem
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Merging this. Javadoc is missing as properly pointed out by others.
| .withInclusiveEndAt(after3Seconds)); | ||
| pipeline.run().waitUntilFinish(); | ||
| } finally { | ||
| assertThat( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Today this value is always zero. It seems very sensitive to internal details. Can we change it so that the assertion is checking correct results?
| testImplementation library.java.powermock | ||
| testImplementation library.java.powermock_mockito | ||
| testImplementation library.java.joda_time | ||
| testImplementation library.java.google_cloud_spanner_test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong. "test" dependencies indicate that they are test suites. They are not for use as "test-related libraries". On a technical level, their dependency resolution does not work that way and you just got lucky this worked.
"test" scope jars are just for when you want to actually run someone else's tests

Add sad path unit tests for the Cloud Spanner's ReadChangeStream, including testing for errors from the Spanner backend.