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

#585 - Multi-threaded tests for SyncIterator class #639

Merged
merged 6 commits into from Feb 20, 2018
Merged

#585 - Multi-threaded tests for SyncIterator class #639

merged 6 commits into from Feb 20, 2018

Conversation

driver733
Copy link
Contributor

@driver733 driver733 commented Feb 14, 2018

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() and iterator.hasNext()).
The last added test has two concurrent iterator.hasNext() calls.

I have also added the Concurrent inner class that tests the supplied Runnables for concurrency problems. I have constructed this class based on the information found here.

@0crat 0crat added the scope label Feb 14, 2018
@0crat
Copy link
Collaborator

0crat commented Feb 14, 2018

Job #639 is now in scope, role is REV

Matchers.hasItem("b")
)
);
MatcherAssert.assertThat(
Copy link
Contributor Author

@driver733 driver733 Feb 14, 2018

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-io
Copy link

codecov-io commented Feb 14, 2018

Codecov Report

Merging #639 into master will increase coverage by 0.4%.
The diff coverage is n/a.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ Complexity Δ
src/main/java/org/cactoos/io/TeeOutputStream.java 52.63% <0%> (-15.79%) 3% <0%> (-1%)
src/main/java/org/cactoos/iterable/Reversed.java 66.66% <0%> (-13.34%) 2% <0%> (-1%)
src/main/java/org/cactoos/io/TeeInputStream.java 56.52% <0%> (-13.05%) 6% <0%> (-1%)
src/main/java/org/cactoos/scalar/ItemAt.java 84.44% <0%> (-0.34%) 19% <0%> (+1%)
...main/java/org/cactoos/iterator/StickyIterator.java
src/main/java/org/cactoos/scalar/SumOfScalar.java 100% <0%> (ø) 3% <0%> (?)
src/main/java/org/cactoos/map/Grouped.java 100% <0%> (ø) 2% <0%> (?)
src/main/java/org/cactoos/iterator/IteratorOf.java 100% <0%> (ø) 5% <0%> (?)
src/main/java/org/cactoos/scalar/Constant.java 100% <0%> (ø) 2% <0%> (?)
...c/main/java/org/cactoos/scalar/SumOfIntScalar.java 100% <0%> (ø) 2% <0%> (?)
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eff4166...41da93f. Read the comment docs.

@0crat
Copy link
Collaborator

0crat commented Feb 14, 2018

This pull request #639 is assigned to @amihaiemil/z, here is why. The budget is 15 minutes, see §4. Please, read §27 and when you decide to accept the changes, inform @yegor256/z (the architect) right in this ticket. If you decide that this PR should not be accepted ever, also inform the architect.

@amihaiemil
Copy link

@driver733 please, add a proper title and description to this PR. What is it about, what tests were added etc.

@driver733 driver733 changed the title #585 #585 - Multi-threaded tests for SyncIterator class Feb 16, 2018
Copy link

@amihaiemil amihaiemil left a 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) {
Copy link

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.

Copy link
Contributor Author

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.

@driver733
Copy link
Contributor Author

@amihaiemil I have updated the title and the description of the PR.

@driver733
Copy link
Contributor Author

@amihaiemil Done. (#639 (comment))

@amihaiemil
Copy link

@rultor good to merge

@rultor
Copy link
Collaborator

rultor commented Feb 16, 2018

@rultor good to merge

@amihaiemil Thanks for your request. @yegor256 Please confirm this.

@0crat
Copy link
Collaborator

0crat commented Feb 19, 2018

@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.

@amihaiemil
Copy link

@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;
Copy link
Owner

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

@yegor256
Copy link
Owner

@driver733 see above

@driver733
Copy link
Contributor Author

@yegor256 Done.

/**
* Tests runnables for concurrency issues.
*/
private final class Concurrent {
Copy link
Owner

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?

@yegor256
Copy link
Owner

@driver733 @amihaiemil can you please check how RunInThreads is used in other tests? It seems that in this PR we are reinventing the same functionality.

@driver733
Copy link
Contributor Author

@amihaiemil
@yegor256
ping

Copy link

@amihaiemil amihaiemil left a comment

Choose a reason for hiding this comment

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

@driver733 looks nice :)

@amihaiemil
Copy link

@yegor256 ping

@yegor256
Copy link
Owner

@rultor merge

@rultor
Copy link
Collaborator

rultor commented Feb 20, 2018

@rultor merge

@yegor256 OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit 41da93f into yegor256:master Feb 20, 2018
@rultor
Copy link
Collaborator

rultor commented Feb 20, 2018

@rultor merge

@yegor256 Done! FYI, the full log is here (took me 9min)

@0crat
Copy link
Collaborator

0crat commented Feb 20, 2018

@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

@ypshenychka
Copy link

@amihaiemil According to our QA Rules:

The code reviewer found at least three problems in the code.

Only one issue was found during code review. Please confirm that you'll try to find at least three problems while future reviews.

@ypshenychka
Copy link

@driver733 According to our QA Rules:

Messages in a ticket always start with a name of a user they are addressed to.

Please correct your code review comment by indicating an addressee in the beginning.

@amihaiemil
Copy link

@ypshenychka I confirm

@ypshenychka
Copy link

@amihaiemil Thanks!

@amihaiemil
Copy link

@ypshenychka I think the author made the changes here -- addressed the comments :)

@driver733
Copy link
Contributor Author

@ypshenychka Done.

@ypshenychka
Copy link

@driver733 Thank you!

@ypshenychka
Copy link

@0crat quality acceptable

@0crat
Copy link
Collaborator

0crat commented Feb 21, 2018

QA review completed: +15 points just awarded to @ypshenychka/z, total is +510

@0crat
Copy link
Collaborator

0crat commented Feb 21, 2018

Order was finished, quality was "acceptable": +15 points just awarded to @amihaiemil/z, total is +905

@0crat
Copy link
Collaborator

0crat commented Feb 21, 2018

@0crat quality acceptable (here)

@ypshenychka You can't do that, unless you have one of these roles: ARC, PO. Your current roles are: QA.

@0crat
Copy link
Collaborator

0crat commented Feb 21, 2018

Payment to ARC for a closed pull request, as in §28: +15 points just awarded to @yegor256/z, total is +10619

@0crat
Copy link
Collaborator

0crat commented Feb 28, 2018

This pull request #639 is assigned to @neonailol/z, here is why. The budget is 15 minutes, see §4. Please, read §27 and when you decide to accept the changes, inform @yegor256/z (the architect) right in this ticket. If you decide that this PR should not be accepted ever, also inform the architect.

@yegor256
Copy link
Owner

@0crat refuse

@yegor256
Copy link
Owner

@0crat out

@0crat 0crat removed the scope label Feb 28, 2018
@0crat
Copy link
Collaborator

0crat commented Feb 28, 2018

@0crat refuse (here)

@yegor256 The user @neonailol/z resigned from #639, please stop working. Reason for job resignation: Order was cancelled

@0crat
Copy link
Collaborator

0crat commented Feb 28, 2018

@0crat out (here)

@yegor256 The job #639 is now out of scope

@0crat
Copy link
Collaborator

0crat commented Feb 28, 2018

@0crat out (here)

@yegor256 Job #639 was not in scope

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants