Search in sources :

Example 16 with RestResponse

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();
}
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 17 with RestResponse

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();
}
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 18 with RestResponse

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

Example 19 with RestResponse

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();
}
Also used : TaskInfo(com.google.gerrit.server.config.ListTasks.TaskInfo) RestResponse(com.google.gerrit.acceptance.RestResponse) TypeToken(com.google.gson.reflect.TypeToken)

Example 20 with RestResponse

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

Aggregations

RestResponse (com.google.gerrit.acceptance.RestResponse)79 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)67 Test (org.junit.Test)67 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)17 TypeToken (com.google.gson.reflect.TypeToken)15 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)9 CacheInfo (com.google.gerrit.server.config.ListCaches.CacheInfo)6 TaskInfo (com.google.gerrit.server.config.ListTasks.TaskInfo)6 ReviewResult (com.google.gerrit.extensions.api.changes.ReviewResult)5 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)5 Result (com.google.gerrit.acceptance.PushOneCommit.Result)4 AccountExternalIdInfo (com.google.gerrit.extensions.common.AccountExternalIdInfo)4 LabelInfo (com.google.gerrit.extensions.common.LabelInfo)4 ArrayList (java.util.ArrayList)4 ApprovalInfo (com.google.gerrit.extensions.common.ApprovalInfo)3 Truth.assertThat (com.google.common.truth.Truth.assertThat)2 TestProjectInput (com.google.gerrit.acceptance.TestProjectInput)2 EmailInput (com.google.gerrit.extensions.api.accounts.EmailInput)2 AddReviewerInput (com.google.gerrit.extensions.api.changes.AddReviewerInput)2 PublishChangeEditInput (com.google.gerrit.extensions.api.changes.PublishChangeEditInput)2