-
Notifications
You must be signed in to change notification settings - Fork 374
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
fix(pubsub): get future value before returning #13241
Conversation
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.
The change looks good, but some kind of test was (and remains) missing if this made it so far.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #13241 +/- ##
==========================================
+ Coverage 93.04% 93.05% +0.01%
==========================================
Files 2136 2137 +1
Lines 186524 186562 +38
==========================================
+ Hits 173545 173612 +67
+ Misses 12979 12950 -29 ☔ View full report in Codecov by Sentry. |
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 this really a fix? @coryan would know better, but I thought we implicitly get the future in this case.
google-cloud-cpp/google/cloud/internal/future_then_impl.h
Lines 42 to 44 in 803c09a
template <typename T> | |
inline future<T>::future(future<future<T>>&& rhs) | |
: future<T>(rhs.then([](future<future<T>> f) { return f.get(); })) {} |
If so, this is just a cleanup.
I'm not sure what test would cover this.... Do you have any ideas @coryan? |
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.
If you prefer to merge this and then add the regression test please go ahead.
Tested locally with: |
google/cloud/pubsub/integration_tests/publisher_integration_test.cc
Outdated
Show resolved
Hide resolved
using ::google::cloud::testing_util::DisableTracing; | ||
using ::google::cloud::testing_util::EnableTracing; | ||
|
||
TEST_F(PublisherIntegrationTest, TracingEnabled) { |
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.
We should install the span catcher in these tests, and set some expectations on the results. While something like #13034 would be nice, it might take some brainpower to design. I think we should start by verifying spans that we know are created all of the time. Something like:
EXPECT_THAT(span_catcher->GetSpans(), AllOf(
Contains(SpanNamed("publish")),
Contains(SpanNamed("google.pubsub.v1.PublisherClient/Publish"))));
We can worry about parent/child relationships, sequence of spans, conditional spans (e.g. the backoffs) later.
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 don't think we want a SpanCatcher here. That's what the publisher_connection is for.
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.
So your test verifies that if you make a client with tracing enabled and use it, the application does not crash.
Why not also verify that if you make a client with tracing enabled and use it, it produces spans?
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.
Because that's what the publisher_connection_test does. Then I would have 2 of the same 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.
For an end to end test of traces generated, I think there's a better spot then here. Maybe something that creates a publisher, exports the span data to a .txt file, then diffs it.
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 don't think we want a SpanCatcher here.
Also, if we don't set an exporter, all of the OTel functions will be no-ops. That will probably limit the coverage we are hoping to achieve from an end-to-end integration test.
Because that's what the publisher_connection_test does.
Ok, I did not realize we decorated the mock stub in those tests
SpanNamed("google.pubsub.v1.Publisher/Publish"), |
Still, the production code path is slightly different from the test code path. For integration tests, we want to be using the clients and public APIs the way an application would.
For an end to end test of traces generated, I think there's a better spot then here.
Yeah, you could have a pubsub/integration_tests/publisher_tracing_test.cc
that makes all different sorts of publisher clients, uses them against production / an emulator, and verifies the spans produced. I am thinking like one TEST()
per client configuration.
Maybe something that creates a publisher, exports the span data to a .txt file, then diffs it.
You are going to have to explain this one to me. Why are we exporting to a .txt file, when we have access to the spans programmatically? What are we diffing the .txt file against? Are we writing the span's creation time, which would change every time we run the program?
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 don't think we want a SpanCatcher here.
Also, if we don't set an exporter, all of the OTel functions will be no-ops. That will probably limit the coverage we are hoping to achieve from an end-to-end integration test.
Yes that makes sense.
Because that's what the publisher_connection_test does.
Ok, I did not realize we decorated the mock stub in those tests
SpanNamed("google.pubsub.v1.Publisher/Publish"), Still, the production code path is slightly different from the test code path. For integration tests, we want to be using the clients and public APIs the way an application would.
Is it that different? I'm not sure... Also, this is test is not using the client in any special way. I really think it has the same coverage as publisher_connection_test. At least if the only assertion we make is
EXPECT_THAT(span_catcher->GetSpans(), AllOf( Contains(SpanNamed("publish")), Contains(SpanNamed("google.pubsub.v1.PublisherClient/Publish"))));
For an end to end test of traces generated, I think there's a better spot then here.
Yeah, you could have a
pubsub/integration_tests/publisher_tracing_test.cc
that makes all different sorts of publisher clients, uses them against production / an emulator, and verifies the spans produced. I am thinking like oneTEST()
per client configuration.
This sounds like a better idea. WDYM by client configuration? Different options?
Maybe something that creates a publisher, exports the span data to a .txt file, then diffs it.
You are going to have to explain this one to me. Why are we exporting to a .txt file, when we have access to the spans programmatically? What are we diffing the .txt file against? Are we writing the span's creation time, which would change every time we run the program?
It does not need to be this. What I meant was a solution to #13034
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.
WDYM by client configuration? Different options?
👍
What I meant was a solution to #13034
I am trying to understand the solution, but failing to do so.
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 just my guess about what happens under the hood in something like https://tracetest.io/
if (using_emulator) { | ||
options_ = Options{} | ||
.set<UnifiedCredentialsOption>(MakeInsecureCredentials()) | ||
.set<internal::UseInsecureChannelOption>(true); |
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.
TIL: UseInsecureChannelOption
This reverts commit a061069.
I think any reviews are stale, so requested a re-review |
Closes #13240 and #13244
This change is