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);
}
Aggregations