diff --git a/msa/black-box-tests/README.md b/msa/black-box-tests/README.md
index a45badf44a..a60e7405a8 100644
--- a/msa/black-box-tests/README.md
+++ b/msa/black-box-tests/README.md
@@ -30,5 +30,9 @@ As result, in REPOSITORY column, next images should be present:
mvn clean install -DblackBoxTests.skip=false -DblackBoxTests.hybridMode=true
+To run the black box tests with using local env run tests in the [msa/black-box-tests](../black-box-tests) directory with runLocal property:
+
+ mvn clean install -DblackBoxTests.skip=false -DrunLocal=true
+
diff --git a/msa/black-box-tests/pom.xml b/msa/black-box-tests/pom.xml
index a1c745e163..49f4c959e9 100644
--- a/msa/black-box-tests/pom.xml
+++ b/msa/black-box-tests/pom.xml
@@ -57,11 +57,6 @@
httpclient
test
-
- io.takari.junit
- takari-cpsuite
- test
-
org.springframework.boot
spring-boot-starter-test
@@ -72,6 +67,26 @@
junit-vintage-engine
test
+
+ org.testng
+ testng
+ test
+
+
+ org.assertj
+ assertj-core
+ test
+
+
+ io.rest-assured
+ rest-assured
+ test
+
+
+ org.hamcrest
+ hamcrest-all
+ test
+
org.awaitility
awaitility
@@ -152,11 +167,18 @@
org.apache.maven.plugins
maven-surefire-plugin
-
- **/*TestSuite.java
-
+
+ src/test/resources/testNG.xml
+
${blackBoxTests.skip}
+
+
+ org.apache.maven.surefire
+ surefire-testng
+ ${surefire.version}
+
+
diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/AbstractContainerTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/AbstractContainerTest.java
index 07529baead..a148d7d138 100644
--- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/AbstractContainerTest.java
+++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/AbstractContainerTest.java
@@ -15,115 +15,59 @@
*/
package org.thingsboard.server.msa;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
import lombok.extern.slf4j.Slf4j;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.ssl.SSLContexts;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.rules.TestRule;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
-import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
-import org.thingsboard.rest.client.RestClient;
-import org.thingsboard.server.common.data.Device;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Listeners;
import org.thingsboard.server.common.data.EntityType;
-import org.thingsboard.server.common.data.StringUtils;
import org.thingsboard.server.common.data.id.DeviceId;
-import org.thingsboard.server.msa.mapper.WsTelemetryResponse;
-import javax.net.ssl.SSLContext;
import java.net.URI;
-import java.util.List;
import java.util.Map;
import java.util.Random;
+
@Slf4j
+@Listeners(TestListener.class)
public abstract class AbstractContainerTest {
- protected static final String HTTPS_URL = "https://localhost";
- protected static final String WSS_URL = "wss://localhost";
- protected static String TB_TOKEN;
- protected static RestClient restClient;
-
protected static long timeoutMultiplier = 1;
-
protected ObjectMapper mapper = new ObjectMapper();
- protected JsonParser jsonParser = new JsonParser();
-
- @BeforeClass
- public static void before() throws Exception {
- restClient = new RestClient(HTTPS_URL);
- restClient.getRestTemplate().setRequestFactory(getRequestFactoryForSelfSignedCert());
+ private static final ContainerTestSuite containerTestSuite = ContainerTestSuite.getInstance();
+ protected static TestRestClient testRestClient;
+ @BeforeSuite
+ public void beforeSuite() {
+ if ("false".equals(System.getProperty("runLocal", "false"))) {
+ containerTestSuite.start();
+ }
+ testRestClient = new TestRestClient(TestProperties.getBaseUrl());
if (!"kafka".equals(System.getProperty("blackBoxTests.queue", "kafka"))) {
timeoutMultiplier = 10;
}
}
- @Rule
- public TestRule watcher = new TestWatcher() {
- protected void starting(Description description) {
- log.info("=================================================");
- log.info("STARTING TEST: {}" , description.getMethodName());
- log.info("=================================================");
+ @AfterSuite
+ public void afterSuite() {
+ if (containerTestSuite.isActive()) {
+ containerTestSuite.stop();
}
-
- /**
- * Invoked when a test succeeds
- */
- protected void succeeded(Description description) {
- log.info("=================================================");
- log.info("SUCCEEDED TEST: {}" , description.getMethodName());
- log.info("=================================================");
- }
-
- /**
- * Invoked when a test fails
- */
- protected void failed(Throwable e, Description description) {
- log.info("=================================================");
- log.info("FAILED TEST: {}" , description.getMethodName(), e);
- log.info("=================================================");
- }
- };
-
- protected Device createGatewayDevice() throws JsonProcessingException {
- String isGateway = "{\"gateway\":true}";
- ObjectMapper objectMapper = new ObjectMapper();
- JsonNode additionalInfo = objectMapper.readTree(isGateway);
- Device gatewayDeviceTemplate = new Device();
- gatewayDeviceTemplate.setName("mqtt_gateway");
- gatewayDeviceTemplate.setType("gateway");
- gatewayDeviceTemplate.setAdditionalInfo(additionalInfo);
- return restClient.saveDevice(gatewayDeviceTemplate);
- }
-
- protected Device createDevice(String name) {
- Device device = new Device();
- device.setName(name + StringUtils.randomAlphanumeric(7));
- device.setType("DEFAULT");
- return restClient.saveDevice(device);
}
protected WsClient subscribeToWebSocket(DeviceId deviceId, String scope, CmdsType property) throws Exception {
- WsClient wsClient = new WsClient(new URI(WSS_URL + "/api/ws/plugins/telemetry?token=" + restClient.getToken()), timeoutMultiplier);
- SSLContextBuilder builder = SSLContexts.custom();
- builder.loadTrustMaterial(null, (TrustStrategy) (chain, authType) -> true);
- wsClient.setSocketFactory(builder.build().getSocketFactory());
+ String webSocketUrl = TestProperties.getWebSocketUrl();
+ WsClient wsClient = new WsClient(new URI(webSocketUrl + "/api/ws/plugins/telemetry?token=" + testRestClient.getToken()), timeoutMultiplier);
+ if (webSocketUrl.matches("^(wss)://.*$")) {
+ SSLContextBuilder builder = SSLContexts.custom();
+ builder.loadTrustMaterial(null, (TrustStrategy) (chain, authType) -> true);
+ wsClient.setSocketFactory(builder.build().getSocketFactory());
+ }
wsClient.connectBlocking();
JsonObject cmdsObject = new JsonObject();
@@ -150,16 +94,6 @@ public abstract class AbstractContainerTest {
.build();
}
- protected boolean verify(WsTelemetryResponse wsTelemetryResponse, String key, Long expectedTs, String expectedValue) {
- List
+
+ org.testng
+ testng
+ ${testng.version}
+ test
+
+
+ org.assertj
+ assertj-core
+ ${assertj.version}
+ test
+
+
+ io.rest-assured
+ rest-assured
+ ${rest-assured.version}
+ test
+
+
+ org.hamcrest
+ hamcrest-all
+ ${hamcrest.version}
+ test
+
org.awaitility
awaitility