[ 
https://issues.apache.org/jira/browse/GROOVY-12572?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18135445#comment-18135445
 ] 

ASF GitHub Bot commented on GROOVY-12572:
-----------------------------------------

paulk-asert commented on PR #3100:
URL: https://github.com/apache/groovy/pull/3100#issuecomment-6535207495

   Approving - what is proposed is a real step forward but I'll note these 
minor comments in case we spot issues down the track:
   
   > Things the reviewers didn't mention (not blocking):
   > 
   > 1. A slow machine could make forAwaitOverPublisher hang instead of fail. 
waitUntil gives up after 2 s by default and throws inside the async block.
   >    - Nobody awaits that task, so the exception is silently lost. The 
broadcast is never closed, and the main thread's for await blocks forever. The 
repo has no default JUnit timeout to stop it.
   >    - The old 50 ms sleep could only miss values and fail an assertion.
   >    - The sibling forAwaitOverPublisherThrowsARetainedFailure already has 
the same shape, so it's consistent. Closing the broadcast in a try { … } 
finally { broadcast.close() } around the async body would turn the hang into a 
failure. That would be a reasonable follow-up, or a suggestion on the PR.
   > 2. The AsyncAwaitSpecTest change appears in the user guide. The 
fastest_server tag is included in core-async-await.adoc, so readers will now 
see Thread.sleep(5000).
   >    - It reads fine for a slow server.
   >    - The losing task isn't cancelled, so a pool thread sleeps for 5 s 
after the test passes. That's harmless.
   > 
   > Minor points:
   > - The fast/slow ChannelSelectTest now checks which branch index is 
reported rather than a race. That's fine, since the race was never 
deterministic anyway.
   > - If the deadline in the timer test fires early, the producer stays 
blocked on take(), which leaks one thread. The test still fails cleanly.
   > 
   > Lost coverage: ActorTest.testScheduleAtFixedRateFiresRepeatedly.
   > - The old test asked for at least 3 ticks in 300 ms on a 40 ms period. 
That caught a schedule that repeats but far too slowly.
   > - The new test only asks for 3 ticks within 5 s. A period wrongly taken as 
400 ms would fail the old test and pass the new one, though 40 seconds would 
still fail.
   > - What's still covered is "it repeats and doesn't stop after one tick", 
which is what the test name and the new comment claim. Any fixed time window 
will fail on a loaded machine, so I think this trade is the right one. If you 
still want the rate checked, a looser check that can't flake would do it, for 
example asserting the time between ticks is well under a second.




> Concurrency tests fail on a loaded machine because they sleep instead of 
> waiting for a state
> --------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12572
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12572
>             Project: Groovy
>          Issue Type: Test
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> Several tests sleep for a fixed time and assume another thread has reached 
> some state, or need a thread to keep to a tight schedule; on a loaded machine 
> they fail. For example, 
> {{BroadcastChannelAsPublisherTest.forAwaitOverPublisher}} fails with 
> "BroadcastChannel is closed" when the consumer subscribes after the producer 
> has sent and closed. Affected: {{BroadcastChannelAsPublisherTest}}, 
> {{AgentChangesTest}}, {{BroadcastChannelTest}}, {{ActorTest}}, 
> {{ChannelSelectTest}}, {{AsyncAwaitSpecTest.testFastestServer}} and 
> {{groovy-http-builder}}'s {{MultiExchangeTickerEndToEndTest}}. Each can be 
> made to fail by delaying the other thread.
> PR: https://github.com/apache/groovy/pull/3100



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to