Search in sources :

Example 1 with CacheInfo

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);
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) CacheInfo(com.google.gerrit.server.config.ListCaches.CacheInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 2 with CacheInfo

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();
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) CacheInfo(com.google.gerrit.server.config.ListCaches.CacheInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 3 with CacheInfo

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();
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) CacheInfo(com.google.gerrit.server.config.ListCaches.CacheInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 4 with CacheInfo

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);
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) TypeToken(com.google.gson.reflect.TypeToken) Map(java.util.Map) CacheInfo(com.google.gerrit.server.config.ListCaches.CacheInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 5 with CacheInfo

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();
}
Also used : Map(java.util.Map) ConfigResource(com.google.gerrit.server.config.ConfigResource) CacheInfo(com.google.gerrit.server.config.ListCaches.CacheInfo)

Aggregations

CacheInfo (com.google.gerrit.server.config.ListCaches.CacheInfo)8 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)6 RestResponse (com.google.gerrit.acceptance.RestResponse)6 Test (org.junit.Test)6 ConfigResource (com.google.gerrit.server.config.ConfigResource)2 Map (java.util.Map)2 AuthException (com.google.gerrit.extensions.restapi.AuthException)1 JvmSummaryInfo (com.google.gerrit.server.config.GetSummary.JvmSummaryInfo)1 MemSummaryInfo (com.google.gerrit.server.config.GetSummary.MemSummaryInfo)1 SummaryInfo (com.google.gerrit.server.config.GetSummary.SummaryInfo)1 TaskSummaryInfo (com.google.gerrit.server.config.GetSummary.TaskSummaryInfo)1 ThreadSummaryInfo (com.google.gerrit.server.config.GetSummary.ThreadSummaryInfo)1 PermissionBackendException (com.google.gerrit.server.permissions.PermissionBackendException)1 TypeToken (com.google.gson.reflect.TypeToken)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1