From 01cf9ab05724fd548c74dde0764cb4527b8876e2 Mon Sep 17 00:00:00 2001 From: xzchaoo Date: Wed, 29 Mar 2023 14:30:31 +0800 Subject: [PATCH] test: disable unstable tests and fix some unsable tests (#294) --- .../holoinsight/server/test/it/AlertCalculateIT.java | 2 ++ .../server/test/it/AlertDingDingRobotIT.java | 6 +++--- .../io/holoinsight/server/test/it/AlertRuleIT.java | 10 +++++----- .../io/holoinsight/server/test/it/AlertWebhookIT.java | 8 ++++---- .../java/io/holoinsight/server/test/it/BaseIT.java | 7 ++++++- .../io/holoinsight/server/test/it/DashboardIT.java | 6 +++--- .../server/test/it/OpenMetricsScraperIT.java | 6 +++--- .../src/main/resources/junit-platform.properties | 3 +++ 8 files changed, 29 insertions(+), 19 deletions(-) diff --git a/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/AlertCalculateIT.java b/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/AlertCalculateIT.java index 9a1a5822b..f9e942e1d 100644 --- a/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/AlertCalculateIT.java +++ b/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/AlertCalculateIT.java @@ -21,6 +21,7 @@ import org.apache.commons.lang3.RandomStringUtils; import org.hamcrest.Matchers; import org.json.JSONObject; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; @@ -32,6 +33,7 @@ * @author masaimu * @version 2023-03-23 17:08:00 */ +@Disabled("https://github.com/traas-stack/holoinsight/issues/290") public class AlertCalculateIT extends BaseIT { Long currentId; diff --git a/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/AlertDingDingRobotIT.java b/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/AlertDingDingRobotIT.java index 9baf0b13b..5d23d928e 100644 --- a/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/AlertDingDingRobotIT.java +++ b/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/AlertDingDingRobotIT.java @@ -67,7 +67,7 @@ public void test_rule_create() { System.out.println(tenant); } - @Order(1) + @Order(2) @Test public void test_rule_update() { name = name + "_v2"; @@ -91,7 +91,7 @@ public void test_rule_update() { .root("data").body("groupName", eq(name)); } - @Order(2) + @Order(3) @Test public void test_rule_delete() { given() // @@ -107,7 +107,7 @@ public void test_rule_delete() { .body("data", IS_NULL); // } - @Order(3) + @Order(4) @Test public void test_rule_pageQuery() { Stack ids = new Stack<>(); diff --git a/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/AlertRuleIT.java b/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/AlertRuleIT.java index d215d9d99..081291160 100644 --- a/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/AlertRuleIT.java +++ b/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/AlertRuleIT.java @@ -91,7 +91,7 @@ public void test_rule_create() { System.out.println(tenant); } - @Order(1) + @Order(2) @Test public void test_triggerContent() { AlarmRuleDTO alarmRuleDTO = new AlarmRuleDTO(); @@ -132,7 +132,7 @@ public void test_triggerContent() { .path("data.tenant"); } - @Order(2) + @Order(3) @Test public void test_rule_update() { name = name + "_v2"; @@ -155,7 +155,7 @@ public void test_rule_update() { .root("data").body("ruleName", eq(name)); } - @Order(3) + @Order(4) @Test public void test_rule_delete() { given() // @@ -170,7 +170,7 @@ public void test_rule_delete() { .body("data", IS_NULL); } - @Order(4) + @Order(5) @Test public void test_rule_pageQuery() { Stack ids = new Stack<>(); @@ -219,7 +219,7 @@ public boolean matches(Object o) { })); } - @Order(5) + @Order(6) @Test public void test_alert_calculate() { Integer ruleId = given() // diff --git a/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/AlertWebhookIT.java b/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/AlertWebhookIT.java index b2d88b9c2..a3fd059e7 100644 --- a/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/AlertWebhookIT.java +++ b/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/AlertWebhookIT.java @@ -65,7 +65,7 @@ public void test_rule_create() { System.out.println(tenant); } - @Order(1) + @Order(2) @Test public void test_rule_update() { name = name + "_v2"; @@ -87,7 +87,7 @@ public void test_rule_update() { .root("data").body("webhookName", eq(name)); } - @Order(2) + @Order(3) @Test public void test_rule_delete() { given() // @@ -104,7 +104,7 @@ public void test_rule_delete() { .body("data", IS_NULL); // } - @Order(3) + @Order(4) @Test public void test_rule_pageQuery() { Stack ids = new Stack<>(); @@ -138,7 +138,7 @@ public void test_rule_pageQuery() { given() // .body(new JSONObject(J.toMap(J.toJson(pageRequest)))) // .when() // - .post("/webapi/alarmDingDingRobot/pageQuery") // + .post("/webapi/alarmWebhook/pageQuery") // .then() // .body("success", IS_TRUE) // .root("data") diff --git a/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/BaseIT.java b/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/BaseIT.java index b1b42a2d0..6b4cfd97c 100644 --- a/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/BaseIT.java +++ b/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/BaseIT.java @@ -5,6 +5,7 @@ import java.io.File; import java.io.FileInputStream; +import java.io.IOException; import java.io.InputStream; import java.time.Duration; import java.util.List; @@ -146,6 +147,10 @@ protected static InputStream getResourceAsStream(String name) { } protected static JSONObject getJsonFromClasspath(String name) { - return new JSONObject(new JSONTokener(getResourceAsStream(name))); + try (InputStream is = getResourceAsStream(name)) { + return new JSONObject(new JSONTokener(is)); + } catch (IOException e) { + throw new RuntimeException(e); + } } } diff --git a/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/DashboardIT.java b/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/DashboardIT.java index 123e95a5b..3062e1fa8 100644 --- a/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/DashboardIT.java +++ b/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/DashboardIT.java @@ -69,7 +69,7 @@ public void test_rule_create() { System.out.println(tenant); } - @Order(1) + @Order(2) @Test public void test_rule_update() { name = name + "_v2"; @@ -92,7 +92,7 @@ public void test_rule_update() { .root("data").body("title", eq(name)); } - @Order(2) + @Order(3) @Test public void test_rule_delete() { given() // @@ -108,7 +108,7 @@ public void test_rule_delete() { .body("data", IS_NULL); // } - @Order(3) + @Order(4) @Test public void test_rule_pageQuery() { Stack ids = new Stack<>(); diff --git a/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/OpenMetricsScraperIT.java b/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/OpenMetricsScraperIT.java index 8e3437348..604f2a773 100644 --- a/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/OpenMetricsScraperIT.java +++ b/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/OpenMetricsScraperIT.java @@ -76,7 +76,7 @@ public void test_rule_create() { System.out.println(tenant); } - @Order(1) + @Order(2) @Test public void test_rule_update() { name = name + "_v2"; @@ -107,7 +107,7 @@ public void test_rule_update() { .root("data").body("name", eq(name)); } - @Order(2) + @Order(3) @Test public void test_rule_delete() { given() // @@ -123,7 +123,7 @@ public void test_rule_delete() { .body("data", IS_NULL); // } - @Order(3) + @Order(4) @Test public void test_rule_pageQuery() { Stack ids = new Stack<>(); diff --git a/test/server-e2e-test/src/main/resources/junit-platform.properties b/test/server-e2e-test/src/main/resources/junit-platform.properties index 8670e43f1..03cad10c0 100644 --- a/test/server-e2e-test/src/main/resources/junit-platform.properties +++ b/test/server-e2e-test/src/main/resources/junit-platform.properties @@ -1,3 +1,6 @@ junit.jupiter.execution.parallel.enabled=true junit.jupiter.execution.parallel.mode.default=same_thread junit.jupiter.execution.parallel.mode.classes.default=concurrent +# dyanmic use thread pool size = 4 * cpu +junit.jupiter.execution.parallel.config.strategy=dynamic +junit.jupiter.execution.parallel.config.dynamic.factor=4