often tests put sleeps in as they are waiting for something to happen, and if tests fail intermittently, people extend the sleep until the failure goes away everywhere, on slow VMs as well as fast local systems.
In slider we've been spinning with probes that can return success/failure/retry; only when the final timeout is reached do things fail. We use this to handle slow actions like AM launch, web ui startup, etc https://github.com/apache/incubator-slider/blob/develop/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy#L1179 It's in groovy, letting us passing method references (with args as a string:string map), as well as a closure of actions on failure, so we can spin for AM launch thusly protected void ensureYarnApplicationIsUp(String applicationId) { repeatUntilSuccess("await yarn application Running", this.&isYarnApplicationRunning, instanceLaunchTime, PROBE_SLEEP_TIME, [applicationId: applicationId], true, E_LAUNCH_FAIL) { describe "final state of application" def sar = lookupApplication(applicationId) def message = E_LAUNCH_FAIL + "\n$sar" log.error(message) fail(message) } } In a language with lambda-expressions, you could do something similar; until then anonymous classes for the probe and failure action could be used. However its done, it makes for code that responds fast to change, yet can handle test runs against slower systems. Recommended, especially on anything waiting for service/app startup or shutdown -Steve On 14 January 2015 at 03:44, Karthik Kambatla <[email protected]> wrote: > Ping. > > Also, it would be nice to have our own test-only implementations of Timers > etc. > > On Tue, Dec 30, 2014 at 12:42 AM, Karthik Kambatla <[email protected]> > wrote: > > > Hi folks, > > > > I am sure you all have noticed the time to run YARN unit tests has been > > increasing constantly. Shortening this will let us run more tests for > > individual patches (all yarn tests for changes to yarn-common etc.) and > > faster turnaround times. > > > > Attached is the sorted list of tests on CDH (slightly behind upstream > > branch-2, and uses FairScheduler). I propose we look at them in > decreasing > > order of runtimes, and do the following: > > 1. Move tests using MiniYARNCluster to a separate profile or module that > > runs only on nightly builds and not pre-commit. > > 2. Where possible, use @BeforeClass instead of @Before. > > 3. Use mock clocks where possible instead of explicit sleeps in tests. > > 4. Where sleeps are required, split a long sleep into multiple shorter > > sleeps. > > > > Thoughts? > > > > -- > > Karthik Kambatla > > Software Engineer, Cloudera Inc. > > > > > > > -- > Karthik Kambatla > Software Engineer, Cloudera Inc. > -------------------------------------------- > http://five.sentenc.es > -- CONFIDENTIALITY NOTICE NOTICE: This message is intended for the use of the individual or entity to which it is addressed and may contain information that is confidential, privileged and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any printing, copying, dissemination, distribution, disclosure or forwarding of this communication is strictly prohibited. If you have received this communication in error, please contact the sender immediately and delete it from your system. Thank You.
