Merge branch 'stable-2.14' into stable-2.15
* stable-2.14: PutConfig: add cause to ResourceConflictException RestSession: Remove unnecessary utility methods Change-Id: I3f099f905f3ef31a904e0fc823f3f40f09c4af31
This commit is contained in:
commit
a930b923e7
@ -23,7 +23,6 @@ import com.google.gerrit.extensions.restapi.RawInput;
|
||||
import com.google.gerrit.server.OutputFormat;
|
||||
import java.io.IOException;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.fluent.Request;
|
||||
import org.apache.http.entity.BufferedHttpEntity;
|
||||
import org.apache.http.entity.InputStreamEntity;
|
||||
@ -36,16 +35,6 @@ public class RestSession extends HttpSession {
|
||||
super(server, account);
|
||||
}
|
||||
|
||||
public RestResponse getOK(String endPoint) throws Exception {
|
||||
return get(endPoint, HttpStatus.SC_OK);
|
||||
}
|
||||
|
||||
public RestResponse get(String endPoint, int expectedStatus) throws Exception {
|
||||
RestResponse r = get(endPoint);
|
||||
r.assertStatus(expectedStatus);
|
||||
return r;
|
||||
}
|
||||
|
||||
public RestResponse get(String endPoint) throws IOException {
|
||||
return getWithHeader(endPoint, null);
|
||||
}
|
||||
@ -105,16 +94,6 @@ public class RestSession extends HttpSession {
|
||||
return post(endPoint, null);
|
||||
}
|
||||
|
||||
public RestResponse postOK(String endPoint, Object content) throws Exception {
|
||||
return post(endPoint, content, HttpStatus.SC_OK);
|
||||
}
|
||||
|
||||
public RestResponse post(String endPoint, Object content, int expectedStatus) throws Exception {
|
||||
RestResponse r = post(endPoint, content);
|
||||
r.assertStatus(expectedStatus);
|
||||
return r;
|
||||
}
|
||||
|
||||
public RestResponse post(String endPoint, Object content) throws IOException {
|
||||
return postWithHeader(endPoint, null, content);
|
||||
}
|
||||
|
@ -31,14 +31,17 @@ public class CacheOperationsIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void flushAll() throws Exception {
|
||||
RestResponse r = adminRestSession.getOK("/config/server/caches/project_list");
|
||||
RestResponse r = adminRestSession.get("/config/server/caches/project_list");
|
||||
r.assertOK();
|
||||
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 = adminRestSession.post("/config/server/caches/", new PostCaches.Input(FLUSH_ALL));
|
||||
r.assertOK();
|
||||
r.consume();
|
||||
|
||||
r = adminRestSession.getOK("/config/server/caches/project_list");
|
||||
r = adminRestSession.get("/config/server/caches/project_list");
|
||||
r.assertOK();
|
||||
cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
|
||||
assertThat(cacheInfo.entries.mem).isNull();
|
||||
}
|
||||
@ -59,25 +62,30 @@ public class CacheOperationsIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void flush() throws Exception {
|
||||
RestResponse r = adminRestSession.getOK("/config/server/caches/project_list");
|
||||
RestResponse r = adminRestSession.get("/config/server/caches/project_list");
|
||||
r.assertOK();
|
||||
CacheInfo cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
|
||||
assertThat(cacheInfo.entries.mem).isGreaterThan((long) 0);
|
||||
|
||||
r = adminRestSession.getOK("/config/server/caches/projects");
|
||||
r = adminRestSession.get("/config/server/caches/projects");
|
||||
r.assertOK();
|
||||
cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
|
||||
assertThat(cacheInfo.entries.mem).isGreaterThan((long) 1);
|
||||
|
||||
r =
|
||||
adminRestSession.postOK(
|
||||
adminRestSession.post(
|
||||
"/config/server/caches/",
|
||||
new PostCaches.Input(FLUSH, Arrays.asList("accounts", "project_list")));
|
||||
r.assertOK();
|
||||
r.consume();
|
||||
|
||||
r = adminRestSession.getOK("/config/server/caches/project_list");
|
||||
r = adminRestSession.get("/config/server/caches/project_list");
|
||||
r.assertOK();
|
||||
cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
|
||||
assertThat(cacheInfo.entries.mem).isNull();
|
||||
|
||||
r = adminRestSession.getOK("/config/server/caches/projects");
|
||||
r = adminRestSession.get("/config/server/caches/projects");
|
||||
r.assertOK();
|
||||
cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
|
||||
assertThat(cacheInfo.entries.mem).isGreaterThan((long) 1);
|
||||
}
|
||||
@ -96,7 +104,8 @@ public class CacheOperationsIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void flush_UnprocessableEntity() throws Exception {
|
||||
RestResponse r = adminRestSession.getOK("/config/server/caches/projects");
|
||||
RestResponse r = adminRestSession.get("/config/server/caches/projects");
|
||||
r.assertOK();
|
||||
CacheInfo cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
|
||||
assertThat(cacheInfo.entries.mem).isGreaterThan((long) 0);
|
||||
|
||||
@ -107,7 +116,8 @@ public class CacheOperationsIT extends AbstractDaemonTest {
|
||||
r.assertUnprocessableEntity();
|
||||
r.consume();
|
||||
|
||||
r = adminRestSession.getOK("/config/server/caches/projects");
|
||||
r = adminRestSession.get("/config/server/caches/projects");
|
||||
r.assertOK();
|
||||
cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
|
||||
assertThat(cacheInfo.entries.mem).isGreaterThan((long) 0);
|
||||
}
|
||||
@ -118,8 +128,9 @@ public class CacheOperationsIT extends AbstractDaemonTest {
|
||||
REGISTERED_USERS, GlobalCapability.FLUSH_CACHES, GlobalCapability.VIEW_CACHES);
|
||||
try {
|
||||
RestResponse r =
|
||||
userRestSession.postOK(
|
||||
userRestSession.post(
|
||||
"/config/server/caches/", new PostCaches.Input(FLUSH, Arrays.asList("projects")));
|
||||
r.assertOK();
|
||||
r.consume();
|
||||
|
||||
userRestSession
|
||||
|
@ -190,7 +190,7 @@ public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
|
||||
"Cannot update " + projectName + ": " + e.getCause().getMessage());
|
||||
}
|
||||
log.warn("Failed to update config of project {}.", projectName, e);
|
||||
throw new ResourceConflictException("Cannot update " + projectName);
|
||||
throw new ResourceConflictException("Cannot update " + projectName, e);
|
||||
}
|
||||
|
||||
ProjectState state = projectStateFactory.create(projectConfig);
|
||||
|
Loading…
x
Reference in New Issue
Block a user