use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class TraceIT method traceProjectNoMatch.
@Test
@GerritConfig(name = "tracing.issue123.projectPattern", value = "foo.*")
public void traceProjectNoMatch() throws Exception {
TraceValidatingProjectCreationValidationListener projectCreationListener = new TraceValidatingProjectCreationValidationListener();
try (Registration registration = extensionRegistry.newRegistration().add(projectCreationListener)) {
RestResponse response = adminRestSession.put("/projects/new13");
assertThat(response.getStatusCode()).isEqualTo(SC_CREATED);
assertThat(response.getHeader(RestApiServlet.X_GERRIT_TRACE)).isNull();
assertThat(projectCreationListener.traceId).isNull();
assertThat(projectCreationListener.isLoggingForced).isFalse();
// The logging tag with the project name is also set if tracing is off.
assertThat(projectCreationListener.tags.get("project")).containsExactly("new13");
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class TraceIT method performanceLoggingForRestCall.
@Test
public void performanceLoggingForRestCall() throws Exception {
PerformanceLogger testPerformanceLogger = mock(PerformanceLogger.class);
try (Registration registration = extensionRegistry.newRegistration().add(testPerformanceLogger)) {
RestResponse response = adminRestSession.put("/projects/new10");
assertThat(response.getStatusCode()).isEqualTo(SC_CREATED);
verify(testPerformanceLogger, timeout(5000).atLeastOnce()).log(anyString(), anyLong(), any());
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class TraceIT method traceExcludedRequestUriPattern.
@Test
@GerritConfig(name = "tracing.issue123.excludedRequestUriPattern", value = "/projects/.*")
public void traceExcludedRequestUriPattern() throws Exception {
TraceValidatingProjectCreationValidationListener projectCreationListener = new TraceValidatingProjectCreationValidationListener();
try (Registration registration = extensionRegistry.newRegistration().add(projectCreationListener)) {
RestResponse response = adminRestSession.put("/projects/xyz1");
assertThat(response.getStatusCode()).isEqualTo(SC_CREATED);
assertThat(response.getHeader(RestApiServlet.X_GERRIT_TRACE)).isNull();
assertThat(projectCreationListener.traceId).isNull();
assertThat(projectCreationListener.isLoggingForced).isFalse();
// The logging tag with the project name is also set if tracing is off.
assertThat(projectCreationListener.tags.get("project")).containsExactly("xyz1");
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class TraceIT method restCallForChangeSetsProjectTag.
@Test
public void restCallForChangeSetsProjectTag() throws Exception {
String changeId = createChange().getChangeId();
TraceChangeIndexedListener changeIndexedListener = new TraceChangeIndexedListener();
try (Registration registration = extensionRegistry.newRegistration().add(changeIndexedListener)) {
RestResponse response = adminRestSession.post("/changes/" + changeId + "/revisions/current/review", ReviewInput.approve());
assertThat(response.getStatusCode()).isEqualTo(SC_OK);
// The logging tag with the project name is also set if tracing is off.
assertThat(changeIndexedListener.tags.get("project")).containsExactly(project.get());
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class TraceIT method traceRequestUriPatternAndExcludedRequestUriPatternNoMatch.
@Test
@GerritConfig(name = "tracing.issue123.requestUriPattern", value = "/projects/.*")
@GerritConfig(name = "tracing.issue123.excludedRequestUriPattern", value = "/projects/no-match")
public void traceRequestUriPatternAndExcludedRequestUriPatternNoMatch() throws Exception {
TraceValidatingProjectCreationValidationListener projectCreationListener = new TraceValidatingProjectCreationValidationListener();
try (Registration registration = extensionRegistry.newRegistration().add(projectCreationListener)) {
RestResponse response = adminRestSession.put("/projects/xyz3");
assertThat(response.getStatusCode()).isEqualTo(SC_CREATED);
assertThat(response.getHeader(RestApiServlet.X_GERRIT_TRACE)).isNull();
assertThat(projectCreationListener.traceId).isEqualTo("issue123");
assertThat(projectCreationListener.isLoggingForced).isTrue();
assertThat(projectCreationListener.tags.get("project")).containsExactly("xyz3");
}
}
Aggregations