use of com.linkedin.darkcluster.api.DarkClusterVerifier in project rest.li by linkedin.
the class TestDarkClusterVerifierManager method testSafeVerifier.
@Test
void testSafeVerifier() throws InterruptedException {
// only use this to set up the executor service.
setup(false);
DarkClusterVerifier verifier = new SafeDarkClusterVerifier(new TestThrowingVerifier());
DarkClusterVerifierManager verifierManager = new DarkClusterVerifierManagerImpl(verifier, _executorService);
RestRequest req = new RestRequestBuilder(URI.create("foo")).build();
RestResponse res = new RestResponseBuilder().build();
verifierManager.onDarkResponse(req, res, DARK_CLUSTER1_NAME);
verifierManager.onDarkResponse(req, res, DARK_CLUSTER1_NAME);
verifierManager.onResponse(req, res);
waitForLatch();
// if we got here, we successfully caught the exceptions
// now retry without the SafeDarkClusterVerifier
DarkClusterVerifier verifier2 = new TestThrowingVerifier();
DarkClusterVerifierManager verifierManager2 = new DarkClusterVerifierManagerImpl(verifier2, _executorService);
RestRequest req2 = new RestRequestBuilder(URI.create("foo")).build();
RestResponse res2 = new RestResponseBuilder().build();
try {
verifierManager2.onDarkResponse(req2, res2, DARK_CLUSTER1_NAME);
verifierManager2.onDarkResponse(req2, res2, DARK_CLUSTER1_NAME);
verifierManager2.onResponse(req2, res2);
waitForLatch();
// we shouldn't get here, should have thrown exception
fail("shouldn't have gotten here");
} catch (Throwable t) {
// expected, because we aren't using the SafeDarkClusterVerifier here
}
}
Aggregations