-
Notifications
You must be signed in to change notification settings - Fork 4
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
Acceptance tests: prevent deadlocks in tests for async writes #27
Conversation
acceptance_testing.go
Outdated
@@ -1129,3 +1129,17 @@ func (a acceptanceTest) isEqualData(is *is.I, want, got Data) { | |||
is.Equal(want.Bytes(), got.Bytes()) // data did not match (want != got) | |||
} | |||
} | |||
|
|||
func waitTimeout(wg *sync.WaitGroup, timeout time.Duration) bool { |
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'm thinking if it would be worth it to add this function as a method to acceptanceTest
and to ConfigurableAcceptanceTestDriver
🤔 it would mean it's duplicated, but on the other hand we prevent it from being used anywhere else and keep the package clean.
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 was thinking about that too, but I didn't like the duplication at all. On the other hand, maybe it's not a bad thing at all that it's accessible to the rest of the package. I'd maybe move it to a utils package or import it from a library.
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.
Lovro and I talked about this "offline". Similar functionality is needed in other places, so we'll extract this function into a separate file.
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 saw the comment about pulling the wait utils functions into a separate file or package. I would be in favor of a separate package entirely over a file, especially if these functions are useful concurrency patterns for acceptance tests et. al. Looks good!
Something was bugging me about these functions, bugging me to the point that I took the time to play around with a completely different approach. Here's what I came up with: a9290b4. The idea is to have types that extend the functionality of
Or you can use the internal types directly (as I did in the commit). WDYT @hariso? |
@lovromazgon Nice! I've seen a similar approach in a library I was considering (introducing a dependency for a thing as simple as this wasn't really appealing). Your approach with types is more elegant though! Since we're basically writing our own WaitGroup alternative, we'd need tests for the new as well as the existing WaitGroup functionality. If we can agree the the scope change is OK and pays out, I think it's be cool seeing this merged. 👍 |
Glad to hear you like the approach.
I totally agree, I didn't include them since I made the commit more as an exploration to see if it made sense. Do you want me to write the tests or do you want to include the commit in your PR and write tests for it? |
FTR, I'll include Lovro's commit into this PR and add tests. I'll convert this PR into a draft to finish another issue first. |
We're punting on #26 for now, so I'll close this. |
Description
Fixes #26
Quick checks:
update/change.