Search in sources :

Example 61 with RestResponse

use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.

the class GetCacheIT method getCache.

@Test
public void getCache() throws Exception {
    RestResponse r = adminRestSession.get("/config/server/caches/accounts");
    r.assertOK();
    CacheInfo result = newGson().fromJson(r.getReader(), CacheInfo.class);
    assertThat(result.name).isEqualTo("accounts");
    assertThat(result.type).isEqualTo(CacheType.MEM);
    assertThat(result.entries.mem).isAtLeast(1L);
    assertThat(result.averageGet).isNotNull();
    assertThat(result.averageGet).endsWith("s");
    assertThat(result.entries.disk).isNull();
    assertThat(result.entries.space).isNull();
    assertThat(result.hitRatio.mem).isAtLeast(0);
    assertThat(result.hitRatio.mem).isAtMost(100);
    assertThat(result.hitRatio.disk).isNull();
    userRestSession.get("/config/server/version").consume();
    r = adminRestSession.get("/config/server/caches/accounts");
    r.assertOK();
    result = newGson().fromJson(r.getReader(), CacheInfo.class);
    assertThat(result.entries.mem).isEqualTo(2);
}
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 62 with RestResponse

use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.

the class GetTaskIT method getLogFileCompressorTaskId.

private String getLogFileCompressorTaskId() throws Exception {
    RestResponse r = adminRestSession.get("/config/server/tasks/");
    List<TaskInfo> result = newGson().fromJson(r.getReader(), new TypeToken<List<TaskInfo>>() {
    }.getType());
    r.consume();
    for (TaskInfo info : result) {
        if ("Log File Compressor".equals(info.command)) {
            return info.id;
        }
    }
    return null;
}
Also used : TaskInfo(com.google.gerrit.server.config.ListTasks.TaskInfo) RestResponse(com.google.gerrit.acceptance.RestResponse) TypeToken(com.google.gson.reflect.TypeToken)

Example 63 with RestResponse

use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.

the class GetTaskIT method getTask.

@Test
public void getTask() throws Exception {
    RestResponse r = adminRestSession.get("/config/server/tasks/" + getLogFileCompressorTaskId());
    r.assertOK();
    TaskInfo info = newGson().fromJson(r.getReader(), new TypeToken<TaskInfo>() {
    }.getType());
    assertThat(info.id).isNotNull();
    Long.parseLong(info.id, 16);
    assertThat(info.command).isEqualTo("Log File Compressor");
    assertThat(info.startTime).isNotNull();
}
Also used : TaskInfo(com.google.gerrit.server.config.ListTasks.TaskInfo) RestResponse(com.google.gerrit.acceptance.RestResponse) TypeToken(com.google.gson.reflect.TypeToken) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 64 with RestResponse

use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.

the class KillTaskIT method killTask.

private void killTask() throws Exception {
    RestResponse r = adminRestSession.get("/config/server/tasks/");
    List<TaskInfo> result = newGson().fromJson(r.getReader(), new TypeToken<List<TaskInfo>>() {
    }.getType());
    r.consume();
    Optional<String> id = result.stream().filter(t -> "Log File Compressor".equals(t.command)).map(t -> t.id).findFirst();
    assertThat(id).isPresent();
    r = adminRestSession.delete("/config/server/tasks/" + id.get());
    r.assertNoContent();
    r.consume();
    r = adminRestSession.get("/config/server/tasks/");
    result = newGson().fromJson(r.getReader(), new TypeToken<List<TaskInfo>>() {
    }.getType());
    r.consume();
    Set<String> ids = result.stream().map(t -> t.id).collect(toSet());
    assertThat(ids).doesNotContain(id.get());
}
Also used : TaskInfo(com.google.gerrit.server.config.ListTasks.TaskInfo) List(java.util.List) TypeToken(com.google.gson.reflect.TypeToken) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) RestResponse(com.google.gerrit.acceptance.RestResponse) Optional(java.util.Optional) Set(java.util.Set) Test(org.junit.Test) Truth.assertThat(com.google.common.truth.Truth.assertThat) TaskInfo(com.google.gerrit.server.config.ListTasks.TaskInfo) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) Collectors.toSet(java.util.stream.Collectors.toSet) RestResponse(com.google.gerrit.acceptance.RestResponse) TypeToken(com.google.gson.reflect.TypeToken) List(java.util.List)

Example 65 with RestResponse

use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.

the class ListCachesIT method listCacheNamesTextList.

@Test
public void listCacheNamesTextList() throws Exception {
    RestResponse r = adminRestSession.get("/config/server/caches/?format=TEXT_LIST");
    r.assertOK();
    String result = new String(Base64.decode(r.getEntityContent()), UTF_8.name());
    List<String> list = Arrays.asList(result.split("\n"));
    assertThat(list).contains("accounts");
    assertThat(list).contains("projects");
    assertThat(Ordering.natural().isOrdered(list)).isTrue();
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) 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