Skip to content
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

Rework how tests deal with future timeout #496

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open

Conversation

var-const
Copy link
Contributor

@var-const var-const commented Jun 26, 2021

Also fix a potential bug in DescribeFailedFuture (error_message() can return null).

@google-cla google-cla bot added the cla: yes label Jun 26, 2021
@var-const var-const added the tests-requested: quick Trigger a quick set of integration tests. label Jun 26, 2021
@github-actions github-actions bot added tests: in-progress This PR's integration tests are in progress. and removed tests-requested: quick Trigger a quick set of integration tests. labels Jun 26, 2021
@github-actions
Copy link

github-actions bot commented Jun 26, 2021

❌  Integration test FAILED

Requested by @var-const on commit e5b44cf
Last updated: Fri Jul 23 12:56 PDT 2021
View integration test log & download artifacts

Failures Configs
missing_log [TEST] [ERROR] [iOS] [macos] [simulator_target]
firestore [TEST] [FAILURE] [Android] [macos] [emulator_target]
(1 failed tests)  TestDocumentSnapshotEventsForChange

@github-actions github-actions bot added the tests: failed This PR's integration tests failed. label Jun 26, 2021
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label Jun 26, 2021
@var-const var-const added tests-requested: quick Trigger a quick set of integration tests. and removed tests: failed This PR's integration tests failed. labels Jun 29, 2021
@github-actions github-actions bot added tests: in-progress This PR's integration tests are in progress. and removed tests-requested: quick Trigger a quick set of integration tests. labels Jun 29, 2021
@var-const var-const requested a review from dconeybe June 29, 2021 00:44
@github-actions github-actions bot added the tests: failed This PR's integration tests failed. label Jun 29, 2021
@var-const var-const added tests-requested: full Trigger a FULL set of integration tests (uses expanded test matrix). and removed tests: failed This PR's integration tests failed. tests: in-progress This PR's integration tests are in progress. labels Jun 29, 2021
@github-actions github-actions bot added tests: in-progress This PR's integration tests are in progress. tests: failed This PR's integration tests failed. and removed tests-requested: full Trigger a FULL set of integration tests (uses expanded test matrix). labels Jun 29, 2021
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label Jun 29, 2021
Copy link
Contributor

@dconeybe dconeybe left a comment

Choose a reason for hiding this comment

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

Overall, this looks fantastic! It's great to see the timeout logic de-duplicated in several places. Thanks for doing this.

// occurs. Returns `true` on success, `false` on timeout or if exit signal was
// received.
template <typename PredT>
bool WaitUntil(const PredT& pred, int timeout_ms = kTimeOutMillis);
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider returning an enum from WaitUntil() and WaitUntilFutureCompletes() instead of conflating timeout and exit signal with a false return value. This will improve readability at the call sites since it is not immediately obvious without reading the function's documentation or implementation what the return value means and will avoid misleading "timeout" error messages when the exit signal occurs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about this but was leaning towards not doing it. It seems to complicate the common case for the sake of a very rare occurrence. I'm not sure this even works correctly -- e.g. on Linux the integration tests seem to completely ignore Ctrl-C.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure this even works correctly -- e.g. on Linux the integration tests seem to completely ignore Ctrl-C.

Please disregard -- this is actually working correctly. I'm still hesitant to complicate the common case, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, it seems like it actually works in some tests and doesn't work in others.

Copy link
Contributor

Choose a reason for hiding this comment

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

My concern still stands, that returning a bool detracts from readability at the call sites. And confounding exit signal with timeout could lead to misleading test failure messages. When tests timeout they are already hard enough to debug and unclear error messages can further make that harder. This doesn't block my approval of this PR though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems to me that the root cause here is that these functions just don't have a great way of reporting this event, which really seems more akin to an exception. There also isn't much tests can do about it, so I'm not sure they need the ability to check for this condition. I think that this type of exit usually happens due to user input, so it shouldn't be confusing to the user, at least in the general case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should throw an exception now that exceptions are enabled in tests, especially once #561 is merged. In any case, that's out of scope for this PR so I'm fine with this code as-is.

@@ -280,37 +285,27 @@ class FirestoreIntegrationTest : public testing::Test {

// TODO(zxu): add a helper function to block on signal.

// A helper function to block until the future completes.
// Blocks until the future completes and returns the future result.
Copy link
Contributor

Choose a reason for hiding this comment

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

ultranit: Consider adding a comma after "completes".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, my understanding is that this is a compound predicate (Blocks... and returns) and thus doesn't require a comma. I can't dig up a very authoritative reference quickly but the few links that come up in a search seem to agree -- see e.g. this.

Copy link
Contributor

Choose a reason for hiding this comment

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

You may be technically correct. For me, every time I read this sentence I read "Blocks until the future completes and returns" which implies that the future "completes and returns" but "returns" actually gets associated with the text that follows. Totally up to you though :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see what you mean, and I fully agree. How about Blocks until the future is completed and returns...? I think it could still be read the wrong way but it seems like an improvement. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or, you could add a comma after "completes" ;) I think without the comma any wording has some ambiguity.

@dconeybe dconeybe removed their assignment Jun 29, 2021
@var-const var-const assigned dconeybe and unassigned var-const Jul 23, 2021
@github-actions github-actions bot added the tests: failed This PR's integration tests failed. label Jul 23, 2021
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label Jul 23, 2021
@var-const var-const added tests-requested: quick Trigger a quick set of integration tests. and removed tests: failed This PR's integration tests failed. labels Jul 23, 2021
@github-actions github-actions bot added tests: in-progress This PR's integration tests are in progress. tests: failed This PR's integration tests failed. and removed tests-requested: quick Trigger a quick set of integration tests. labels Jul 23, 2021
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label Jul 23, 2021
// This function is found dynamically by googletest to print a Future object
// in a test failure message.
void PrintTo(const Future<void>& future, std::ostream* os);
// This function is via ADL by Googletest to print a Future object in a test
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there is a missing verb in this sentence: "This function is via ADL...". Should it be "is found"?

dconeybe
dconeybe previously approved these changes Jul 23, 2021
Copy link
Contributor

@dconeybe dconeybe left a comment

Choose a reason for hiding this comment

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

Approved, with one very minor comment about a comment wording.

@dconeybe dconeybe assigned var-const and unassigned dconeybe Jul 23, 2021
@var-const var-const added tests-requested: quick Trigger a quick set of integration tests. and removed tests: failed This PR's integration tests failed. labels Jul 23, 2021
@github-actions github-actions bot added tests: in-progress This PR's integration tests are in progress. tests: failed This PR's integration tests failed. and removed tests-requested: quick Trigger a quick set of integration tests. labels Jul 23, 2021
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label Jul 23, 2021
@jonsimantov
Copy link
Contributor

@dconeybe Is this PR still relevant? Should it be merged or closed?

@github-actions github-actions bot dismissed stale reviews from dconeybe and dconeybe January 4, 2022 17:14

🍞 Dismissed stale approval on external PR.

@dconeybe dconeybe assigned dconeybe and unassigned var-const Jan 4, 2022
@dconeybe
Copy link
Contributor

dconeybe commented Jan 4, 2022

Yes, it is still relevant. I've merged in HEAD and assigned to myself.

auto-merge was automatically disabled May 5, 2022 03:14

Merge could not be authorized

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore cla: yes tests: failed This PR's integration tests failed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants