Search in sources :

Example 1 with SafeDarkClusterVerifier

use of com.linkedin.darkcluster.impl.SafeDarkClusterVerifier 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
    }
}
Also used : SafeDarkClusterVerifier(com.linkedin.darkcluster.impl.SafeDarkClusterVerifier) DarkClusterVerifierManager(com.linkedin.darkcluster.api.DarkClusterVerifierManager) RestRequest(com.linkedin.r2.message.rest.RestRequest) RestResponse(com.linkedin.r2.message.rest.RestResponse) RestResponseBuilder(com.linkedin.r2.message.rest.RestResponseBuilder) SafeDarkClusterVerifier(com.linkedin.darkcluster.impl.SafeDarkClusterVerifier) DarkClusterVerifier(com.linkedin.darkcluster.api.DarkClusterVerifier) RestRequestBuilder(com.linkedin.r2.message.rest.RestRequestBuilder) DarkClusterVerifierManagerImpl(com.linkedin.darkcluster.impl.DarkClusterVerifierManagerImpl) Test(org.testng.annotations.Test)

Aggregations

DarkClusterVerifier (com.linkedin.darkcluster.api.DarkClusterVerifier)1 DarkClusterVerifierManager (com.linkedin.darkcluster.api.DarkClusterVerifierManager)1 DarkClusterVerifierManagerImpl (com.linkedin.darkcluster.impl.DarkClusterVerifierManagerImpl)1 SafeDarkClusterVerifier (com.linkedin.darkcluster.impl.SafeDarkClusterVerifier)1 RestRequest (com.linkedin.r2.message.rest.RestRequest)1 RestRequestBuilder (com.linkedin.r2.message.rest.RestRequestBuilder)1 RestResponse (com.linkedin.r2.message.rest.RestResponse)1 RestResponseBuilder (com.linkedin.r2.message.rest.RestResponseBuilder)1 Test (org.testng.annotations.Test)1