Search in sources :

Example 6 with RestMetricsClient

use of org.infinispan.client.rest.RestMetricsClient in project infinispan by infinispan.

the class XSiteRestMetricsOperations method testSiteStatus.

@Test
public void testSiteStatus() throws Exception {
    String lonXML = String.format(LON_CACHE_XML_CONFIG, SERVER_TEST.getMethodName());
    String nycXML = String.format(NYC_CACHE_XML_CONFIG, SERVER_TEST.getMethodName());
    RestClient client = SERVER_TEST.rest(LON).withServerConfiguration(new StringConfiguration(lonXML)).create();
    RestMetricsClient metricsClient = client.metrics();
    // create cache in NYC
    SERVER_TEST.rest(NYC).withServerConfiguration(new StringConfiguration(nycXML)).create();
    String statusMetricName = "cache_manager_default_cache_" + SERVER_TEST.getMethodName() + "_x_site_admin_nyc_status";
    try (RestResponse response = sync(metricsClient.metrics(true))) {
        assertEquals(200, response.getStatus());
        RestMetricsResource.checkIsOpenmetrics(response.contentType());
        assertTrue(response.getBody().contains("# TYPE vendor_" + statusMetricName + " gauge\n"));
    }
    assertSiteStatusMetrics(metricsClient, statusMetricName, 1);
    try (RestResponse response = sync(client.cacheManager("default").takeOffline(NYC))) {
        assertEquals(200, response.getStatus());
    }
    assertSiteStatusMetrics(metricsClient, statusMetricName, 0);
}
Also used : StringConfiguration(org.infinispan.commons.configuration.StringConfiguration) RestResponse(org.infinispan.client.rest.RestResponse) RestClient(org.infinispan.client.rest.RestClient) RestMetricsClient(org.infinispan.client.rest.RestMetricsClient) Test(org.junit.Test)

Aggregations

RestMetricsClient (org.infinispan.client.rest.RestMetricsClient)6 RestResponse (org.infinispan.client.rest.RestResponse)6 Test (org.junit.Test)6 RestClient (org.infinispan.client.rest.RestClient)4 RestCacheClient (org.infinispan.client.rest.RestCacheClient)2 StringConfiguration (org.infinispan.commons.configuration.StringConfiguration)1