mirror of https://github.com/grpc/grpc-java.git
Fix flakiness of testConfigureDeadlineNanoTime with warmup
Without the warm up I saw large deltas, like 2,262,968ns and 1,712,558ns, on my machine. With the single-line warm up the deltas decreased dramitically, like 385ns and 536ns. Since our times are so much better now, decreasing the required delta to 10ms seems reasonable. This would seem to support the theory that the flakiness was caused by the class loader, which may even be doing I/O. Fixes #1646
This commit is contained in:
parent
91b087e526
commit
83bf5e6f42
|
|
@ -107,11 +107,13 @@ public class StubConfigTest {
|
||||||
// Create a default stub
|
// Create a default stub
|
||||||
TestServiceGrpc.TestServiceBlockingStub stub = TestServiceGrpc.newBlockingStub(channel);
|
TestServiceGrpc.TestServiceBlockingStub stub = TestServiceGrpc.newBlockingStub(channel);
|
||||||
assertNull(stub.getCallOptions().getDeadlineNanoTime());
|
assertNull(stub.getCallOptions().getDeadlineNanoTime());
|
||||||
|
// Warm up JVM
|
||||||
|
stub.withDeadlineNanoTime(deadline);
|
||||||
// Reconfigure it
|
// Reconfigure it
|
||||||
TestServiceGrpc.TestServiceBlockingStub reconfiguredStub = stub.withDeadlineNanoTime(deadline);
|
TestServiceGrpc.TestServiceBlockingStub reconfiguredStub = stub.withDeadlineNanoTime(deadline);
|
||||||
// New altered config
|
// New altered config
|
||||||
assertNotNull(reconfiguredStub.getCallOptions().getDeadlineNanoTime());
|
assertNotNull(reconfiguredStub.getCallOptions().getDeadlineNanoTime());
|
||||||
long maxDelta = MILLISECONDS.toNanos(30);
|
long maxDelta = MILLISECONDS.toNanos(10);
|
||||||
long actualDelta = Math.abs(reconfiguredStub.getCallOptions().getDeadlineNanoTime() - deadline);
|
long actualDelta = Math.abs(reconfiguredStub.getCallOptions().getDeadlineNanoTime() - deadline);
|
||||||
assertTrue(maxDelta + " < " + actualDelta, maxDelta >= actualDelta);
|
assertTrue(maxDelta + " < " + actualDelta, maxDelta >= actualDelta);
|
||||||
// Default config unchanged
|
// Default config unchanged
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue