Skip to content

Loading…

LanguageUtilsTest -- increase the tolerance in the assertions #623

Merged
merged 1 commit into from

3 participants

@buildhive

Brooklyn Central » brooklyn #318 FAILURE
Looks like there's a problem with this pull request
(what's this?)

@buildhive

Brooklyn Central » brooklyn #319 FAILURE
Looks like there's a problem with this pull request
(what's this?)

@aledsage aledsage commented on an outdated diff
.../java/brooklyn/util/internal/LanguageUtilsTest.groovy
@@ -138,8 +138,8 @@ public class LanguageUtilsTest {
LanguageUtils.repeatUntilSuccess(period: 5*TimeUnit.MILLISECONDS, timeout: 500*TimeUnit.MILLISECONDS) {
System.currentTimeMillis() > start+50
}
- assertTrue System.currentTimeMillis() > start+50
- assertTrue System.currentTimeMillis() < start+500
+ assertTrue System.currentTimeMillis() > start+10
+ assertTrue System.currentTimeMillis() < start+200
@aledsage Brooklyn Central member

This has made the tolerance even less: < start+200 is stricter than < start+500. I'd write something like:

    long start = System.currentTimeMillis();
    LanguageUtils.repeatUntilSuccess(period: 1*TimeUnit.MILLISECONDS, timeout: 5000*TimeUnit.MILLISECONDS) { 
        System.currentTimeMillis() > start+50 
    }
    long time = System.currentTimeMillis() - start;
    assertTrue(time >= 50, "time="+time);
    assertTrue(time <= 1000, "time="+time);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@aledsage
Brooklyn Central member

Will see if buildhive thinks this is good enough to fix the test failure, and then merge.

@buildhive

Brooklyn Central » brooklyn #320 FAILURE
Looks like there's a problem with this pull request
(what's this?)

@aledsage
Brooklyn Central member

The test passed in buildhive, but then failed at:

CliTest.testLaunchCommandParsesArgs:188 LaunchCommand{verbose=false, quiet=false, app=my.App, script=null, location=localhost, port=8081+, noConsole=false, noShutdownOnExit=false, stopOnKeyPress=false} expected [true] but found [false]

So merging.

@aledsage aledsage merged commit 45cfe9a into brooklyncentral:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 6 deletions.
  1. +7 −6 core/src/test/java/brooklyn/util/internal/LanguageUtilsTest.groovy
View
13 core/src/test/java/brooklyn/util/internal/LanguageUtilsTest.groovy
@@ -134,12 +134,13 @@ public class LanguageUtilsTest {
@Test
public void testRepeatUntilSuccessFlags() {
- long start = System.currentTimeMillis();
- LanguageUtils.repeatUntilSuccess(period: 5*TimeUnit.MILLISECONDS, timeout: 500*TimeUnit.MILLISECONDS) {
- System.currentTimeMillis() > start+50
- }
- assertTrue System.currentTimeMillis() > start+50
- assertTrue System.currentTimeMillis() < start+500
+ long start = System.currentTimeMillis();
+ LanguageUtils.repeatUntilSuccess(period: 1*TimeUnit.MILLISECONDS, timeout: 5000*TimeUnit.MILLISECONDS) {
+ System.currentTimeMillis() > start+50
+ }
+ long time = System.currentTimeMillis() - start;
+ assertTrue(time >= 50, "time="+time);
+ assertTrue(time <= 1000, "time="+time);
}
@Test
public void testRepeatUntilSuccessDefaults() {
Something went wrong with that request. Please try again.