-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Development: Add admin metrics page tests (#9249)
- Loading branch information
1 parent
bac8af9
commit 64be5de
Showing
2 changed files
with
70 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/test/java/de/tum/cit/aet/artemis/JhiMetricsIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package de.tum.cit.aet.artemis; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.security.test.context.support.WithMockUser; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
class JhiMetricsIntegrationTest extends AbstractSpringIntegrationIndependentTest { | ||
|
||
@Autowired | ||
private ObjectMapper objectMapper; | ||
|
||
@Test | ||
@WithMockUser(username = "admin", roles = "ADMIN") | ||
void getMetricsTest() throws Exception { | ||
var result = request.get("/management/jhimetrics", HttpStatus.OK, String.class); | ||
|
||
JsonNode rootNode = objectMapper.readTree(result); | ||
|
||
assertThat(rootNode.has("jvm")).isTrue(); | ||
assertThat(rootNode.path("jvm").has("G1 Old Gen")).isTrue(); | ||
assertThat(rootNode.path("jvm").path("G1 Old Gen").has("committed")).isTrue(); | ||
assertThat(rootNode.path("jvm").path("G1 Old Gen").has("max")).isTrue(); | ||
assertThat(rootNode.path("jvm").path("G1 Old Gen").has("used")).isTrue(); | ||
|
||
assertThat(rootNode.has("http.server.requests")).isTrue(); | ||
assertThat(rootNode.path("http.server.requests").path("all").has("count")).isTrue(); | ||
|
||
assertThat(rootNode.has("cache")).isTrue(); | ||
|
||
assertThat(rootNode.has("garbageCollector")).isTrue(); | ||
assertThat(rootNode.path("garbageCollector").has("jvm.gc.max.data.size")).isTrue(); | ||
assertThat(rootNode.path("garbageCollector").path("jvm.gc.pause").has("max")).isTrue(); | ||
|
||
assertThat(rootNode.has("processMetrics")).isTrue(); | ||
assertThat(rootNode.path("processMetrics").has("process.cpu.usage")).isTrue(); | ||
|
||
assertThat(rootNode.has("customMetrics")).isTrue(); | ||
} | ||
} |