Skip to content

WiP/RFC time: remove return-value from TestTimeSystem::waitFor().#10656

Closed
jmarantz wants to merge 7 commits intoenvoyproxy:masterfrom
jmarantz:wait-for-void-return
Closed

WiP/RFC time: remove return-value from TestTimeSystem::waitFor().#10656
jmarantz wants to merge 7 commits intoenvoyproxy:masterfrom
jmarantz:wait-for-void-return

Conversation

@jmarantz
Copy link
Copy Markdown
Contributor

@jmarantz jmarantz commented Apr 5, 2020

Description: The return value (timeout vs no-timeout) from condition-variables is not reliable, so remove it entirely. Per absl::CondVar doc
https://github.com/abseil/abseil-cpp/blob/d43b7997c0ca0f3312a51d1057fb73cfe934703b/absl/synchronization/mutex.h#L795
a timeout/signal race can be hard to reason about, and I think it's pretty error-prone to look at the value. So this PR proposes to change TestTimeSystem::waitFor to have it be a void function: the caller must check the condition.

A better pattern would be to include the condition function, ie Mutex::Await(Condition).

This PR is intended to seed the discussion of which way to go for the test infrastructure. Changing to Mutex::Await(Condition) as a pattern exposed to the integration test infrastructure might be the best way to go, but that's a slightly deeper change.

One of the controversial things in this PR is that there's a param to some Fake[Up]Stream methods ignore_spurious_wakeups and this PR makes that param be ignored.
Risk Level:
Testing:
Docs Changes:
Release Notes:
[Optional Fixes #Issue]
[Optional Deprecated:]

Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz jmarantz changed the title RFC time: remove return-value from TestTimeSystem::waitFor(). WiP/RFC time: remove return-value from TestTimeSystem::waitFor(). Apr 5, 2020
@jmarantz
Copy link
Copy Markdown
Contributor Author

jmarantz commented Apr 5, 2020

I meant this to be a Draft PR; sorry about that.

Anyway I'd love to get opinions on this direction from @alyssawilk and @mattklein123 .

@mattklein123
Copy link
Copy Markdown
Member

One of the controversial things in this PR is that there's a param to some Fake[Up]Stream methods ignore_spurious_wakeups and this PR makes that param be ignored.

I think we need to understand why this is being used? If it's not needed can we remove it? @alyssawilk would know best.

This PR is intended to seed the discussion of which way to go for the test infrastructure. Changing to Mutex::Await(Condition) as a pattern exposed to the integration test infrastructure might be the best way to go, but that's a slightly deeper change.

Is it possible to mock up what this would look like at 1 call site? I agree this sounds better and more explicit, but it's hard for me to get a feeling of what this would look like in practice and whether it's work it or not.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz
Copy link
Copy Markdown
Contributor Author

jmarantz commented Apr 7, 2020

@mattklein123 see 49f8649 for a mock-up. This doesn't work yet obviously (and CI is expected to fail).

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Copy link
Copy Markdown
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

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

at a glance, it looks much cleaner, and I don't like the spurious events checks anyway, so I'm fine doing away with them (as long as we really clean it up - consider removing it first and land this change second, else TODO)

@jmarantz
Copy link
Copy Markdown
Contributor Author

jmarantz commented Apr 8, 2020

Thanks; sounds like there's alignment. As this overlaps with #10551 I'll wait till that goes in and then work on this.

RE spurious wakeups: as part of the PR I'd just delete the param and clean up all call-sites; the PR was basically passing tests essentially, before I committed the non-functional strawman 'await' example.

jmarantz added 2 commits April 9, 2020 19:05
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@stale
Copy link
Copy Markdown

stale bot commented Apr 17, 2020

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Apr 17, 2020
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Apr 21, 2020
@stale
Copy link
Copy Markdown

stale bot commented Apr 29, 2020

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Apr 29, 2020
@stale
Copy link
Copy Markdown

stale bot commented May 6, 2020

This pull request has been automatically closed because it has not had activity in the last 14 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot closed this May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale stalebot believes this issue/PR has not been touched recently waiting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants