use of com.google.gerrit.server.config.ListCaches.CacheInfo in project gerrit by GerritCodeReview.
the class CacheOperationsIT method flush_UnprocessableEntity.
@Test
public void flush_UnprocessableEntity() throws Exception {
RestResponse r = adminRestSession.getOK("/config/server/caches/projects");
CacheInfo cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
assertThat(cacheInfo.entries.mem).isGreaterThan((long) 0);
r = adminRestSession.post("/config/server/caches/", new PostCaches.Input(FLUSH, Arrays.asList("projects", "unprocessable")));
r.assertUnprocessableEntity();
r.consume();
r = adminRestSession.getOK("/config/server/caches/projects");
cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
assertThat(cacheInfo.entries.mem).isGreaterThan((long) 0);
}
use of com.google.gerrit.server.config.ListCaches.CacheInfo in project gerrit by GerritCodeReview.
the class CacheOperationsIT method flushAll.
@Test
public void flushAll() throws Exception {
RestResponse r = adminRestSession.getOK("/config/server/caches/project_list");
CacheInfo cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
assertThat(cacheInfo.entries.mem).isGreaterThan((long) 0);
r = adminRestSession.postOK("/config/server/caches/", new PostCaches.Input(FLUSH_ALL));
r.consume();
r = adminRestSession.getOK("/config/server/caches/project_list");
cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
assertThat(cacheInfo.entries.mem).isNull();
}
use of com.google.gerrit.server.config.ListCaches.CacheInfo in project gerrit by GerritCodeReview.
the class FlushCacheIT method flushCache.
@Test
public void flushCache() throws Exception {
RestResponse r = adminRestSession.get("/config/server/caches/groups");
CacheInfo result = newGson().fromJson(r.getReader(), CacheInfo.class);
assertThat(result.entries.mem).isGreaterThan((long) 0);
r = adminRestSession.post("/config/server/caches/groups/flush");
r.assertOK();
r.consume();
r = adminRestSession.get("/config/server/caches/groups");
result = newGson().fromJson(r.getReader(), CacheInfo.class);
assertThat(result.entries.mem).isNull();
}
use of com.google.gerrit.server.config.ListCaches.CacheInfo in project gerrit by GerritCodeReview.
the class ListCachesIT method listCaches.
@Test
public void listCaches() throws Exception {
RestResponse r = adminRestSession.get("/config/server/caches/");
r.assertOK();
Map<String, CacheInfo> result = newGson().fromJson(r.getReader(), new TypeToken<Map<String, CacheInfo>>() {
}.getType());
assertThat(result).containsKey("accounts");
CacheInfo accountsCacheInfo = result.get("accounts");
assertThat(accountsCacheInfo.type).isEqualTo(CacheType.MEM);
assertThat(accountsCacheInfo.entries.mem).isAtLeast(1L);
assertThat(accountsCacheInfo.averageGet).isNotNull();
assertThat(accountsCacheInfo.averageGet).endsWith("s");
assertThat(accountsCacheInfo.entries.disk).isNull();
assertThat(accountsCacheInfo.entries.space).isNull();
assertThat(accountsCacheInfo.hitRatio.mem).isAtLeast(0);
assertThat(accountsCacheInfo.hitRatio.mem).isAtMost(100);
assertThat(accountsCacheInfo.hitRatio.disk).isNull();
userRestSession.get("/config/server/version").consume();
r = adminRestSession.get("/config/server/caches/");
r.assertOK();
result = newGson().fromJson(r.getReader(), new TypeToken<Map<String, CacheInfo>>() {
}.getType());
assertThat(result.get("accounts").entries.mem).isEqualTo(2);
}
use of com.google.gerrit.server.config.ListCaches.CacheInfo in project gerrit by GerritCodeReview.
the class ShowCaches method getCaches.
private Collection<CacheInfo> getCaches() {
@SuppressWarnings("unchecked") Map<String, CacheInfo> caches = (Map<String, CacheInfo>) listCaches.apply(new ConfigResource());
for (Map.Entry<String, CacheInfo> entry : caches.entrySet()) {
CacheInfo cache = entry.getValue();
cache.name = entry.getKey();
}
return caches.values();
}
Aggregations