From b287d1dbc8b42269ccba5dd79a4aa9df43d9ce3a Mon Sep 17 00:00:00 2001 From: Carl Mastrangelo Date: Wed, 28 Oct 2015 13:44:25 -0700 Subject: [PATCH] Deflake Call Options test --- core/src/test/java/io/grpc/CallOptionsTest.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/test/java/io/grpc/CallOptionsTest.java b/core/src/test/java/io/grpc/CallOptionsTest.java index 95da1001f6..25053468e9 100644 --- a/core/src/test/java/io/grpc/CallOptionsTest.java +++ b/core/src/test/java/io/grpc/CallOptionsTest.java @@ -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