use of com.google.gerrit.acceptance.RestResponse 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.acceptance.RestResponse 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.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class FlushCacheIT method flushWebSessionsCache_Forbidden.
@Test
public void flushWebSessionsCache_Forbidden() throws Exception {
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.VIEW_CACHES, GlobalCapability.FLUSH_CACHES);
try {
RestResponse r = userRestSession.post("/config/server/caches/accounts/flush");
r.assertOK();
r.consume();
userRestSession.post("/config/server/caches/web_sessions/flush").assertForbidden();
} finally {
removeGlobalCapabilities(REGISTERED_USERS, GlobalCapability.VIEW_CACHES, GlobalCapability.FLUSH_CACHES);
}
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class KillTaskIT method killTask_NotFound.
private void killTask_NotFound() throws Exception {
RestResponse r = adminRestSession.get("/config/server/tasks/");
List<TaskInfo> result = newGson().fromJson(r.getReader(), new TypeToken<List<TaskInfo>>() {
}.getType());
r.consume();
assertThat(result.size()).isGreaterThan(0);
userRestSession.delete("/config/server/tasks/" + result.get(0).id).assertNotFound();
}
use of com.google.gerrit.acceptance.RestResponse 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);
}
Aggregations