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
#585 - Multi-threaded tests for SyncIterator class #639
Conversation
Job #639 is now in scope, role is |
Matchers.hasItem("b") | ||
) | ||
); | ||
MatcherAssert.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.
@amihaiemil Two matchers have to be used here, because the compiler complains about using Object
arrays in matchers (contaisInAnyOrder with different object types). (produces a compiler warning)
Codecov Report
@@ Coverage Diff @@
## master #639 +/- ##
===========================================
+ Coverage 69.96% 70.37% +0.4%
- Complexity 1001 1022 +21
===========================================
Files 213 220 +7
Lines 3300 3335 +35
Branches 192 190 -2
===========================================
+ Hits 2309 2347 +38
+ Misses 944 941 -3
Partials 47 47
Continue to review full report at Codecov.
|
@driver733 please, add a proper title and description to this PR. What is it about, what tests were added etc. |
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.
@driver733 looks ok, just one comment :)
*/ | ||
private final CountDownLatch done; | ||
|
||
Concurrent(final List<? extends Runnable> runnables) { |
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.
@driver733 I think here, instead of a List, you could accept Runnable...
and then in the tests you won't have to instantiate Runnables, add them to a List and use that List. You can directly instantiate Concurrent
and give the Runnables directly as lambdas.
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.
@amihaiemil I agree with you. I will make this change now.
@amihaiemil I have updated the title and the description of the PR. |
@amihaiemil Done. (#639 (comment)) |
@rultor good to merge |
@amihaiemil Thanks for your request. @yegor256 Please confirm this. |
@amihaiemil/z this job was assigned to you 5 days ago. It will be taken away from you soon, unless you close it, see §8. Read this and this, please. |
@yegor256 ping, don't forget about this one. Also, I have several other PRs which are waiting arch approval :) |
import java.util.concurrent.locks.ReentrantReadWriteLock; | ||
import junit.framework.TestCase; |
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.
@driver733 we don't use this. Use Hamcrest instead, like all other tests are doing
@driver733 see above |
@yegor256 Done. |
/** | ||
* Tests runnables for concurrency issues. | ||
*/ | ||
private final class Concurrent { |
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.
@driver733 I have a big suspicion that you are reinventing here what we already have in RunInThreads
. Can you please check?
@driver733 @amihaiemil can you please check how |
@amihaiemil |
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.
@driver733 looks nice :)
@yegor256 ping |
@rultor merge |
@ypshenychka/z please review this job, as in §30; the job will be fully closed and all payments will be made when the quality review is completed |
@amihaiemil According to our QA Rules:
Only one issue was found during code review. Please confirm that you'll try to find at least three problems while future reviews. |
@driver733 According to our QA Rules:
Please correct your code review comment by indicating an addressee in the beginning. |
@ypshenychka I confirm |
@amihaiemil Thanks! |
@ypshenychka I think the author made the changes here -- addressed the comments :) |
@ypshenychka Done. |
@driver733 Thank you! |
@0crat quality acceptable |
QA review completed: +15 points just awarded to @ypshenychka/z, total is +510 |
Order was finished, quality was "acceptable": +15 points just awarded to @amihaiemil/z, total is +905 |
@ypshenychka You can't do that, unless you have one of these roles: |
@0crat refuse |
@0crat out |
As per #585
I have written three multi-threaded tests for the
SyncIterator
class.The first test deals with two concurrent
iterator.next()
method calls and tests that the calls are able to produce the correct output even when they are accessed concurrently.The second test deals with two concurrent methods calls (
iterator.next()
anditerator.hasNext()
).The last added test has two concurrent
iterator.hasNext()
calls.I have also added the
Concurrent
inner class that tests the suppliedRunnable
s for concurrency problems. I have constructed this class based on the information found here.