Deflake Call Options test

This commit is contained in:
Carl Mastrangelo 2015-10-28 13:44:25 -07:00
parent c53b5170ca
commit b287d1dbc8
1 changed files with 5 additions and 2 deletions

View File

@ -37,6 +37,7 @@ import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import com.google.common.base.Objects;
import com.google.common.collect.Range;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -102,8 +103,10 @@ public class CallOptionsTest {
.withDeadlineAfter(1, TimeUnit.MINUTES).getDeadlineNanoTime();
long expected = System.nanoTime() + 1L * 60 * 1000 * 1000 * 1000;
long delta = deadline - expected;
assertTrue(delta < 100 * 1000);
assertTrue(delta > -100 * 1000);
// 10 milliseconds of leeway
long epsilon = 1000 * 1000 * 10;
assertTrue(Range.closed(-epsilon, epsilon).contains(delta));
}
@Test