Browse Source

Address PR review feedback

- Skip the TTN tests from @BeforeClass when credentials are missing and document the TTN and Pub/Sub properties (PR #16301)
- Skip the Pub/Sub test from @BeforeClass when credentials are missing (PR #16301)
- Skip the ChirpStack tests without the docker-compose environment and make the integration teardown null-safe (PR #16301)
pull/16301/head
Viacheslav Klimov 2 months ago
parent
commit
496c939b33
Failed to extract signature
  1. 15
      msa/black-box-tests/README.md
  2. 15
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/integration/AbstractIntegrationTest.java
  3. 5
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/integration/ChirpStackIntegrationTest.java
  4. 18
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/integration/PubSubIntegrationTest.java
  5. 27
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/integration/TTNIntegrationTest.java

15
msa/black-box-tests/README.md

@ -103,6 +103,21 @@ development - which is why every generated report carries the non-production not
-DblackBoxTests.azureServiceBusDownlinkTopicName=YOUR_TOPIC_NAME
-DblackBoxTests.azureServiceBusDownlinkSubName=YOUR_SUB_NAME
Note: for The Things Stack (TTN) integration add next VM options:
-DblackBoxTests.ttnRegion=YOUR_REGION
-DblackBoxTests.ttnUsername=YOUR_USERNAME
-DblackBoxTests.ttnPassword=YOUR_API_KEY
-DblackBoxTests.ttnAppId=YOUR_APPLICATION_ID
-DblackBoxTests.ttnDeviceId=YOUR_DEVICE_ID
Note: for Google Pub/Sub integration add next VM options:
-DblackBoxTests.pubSubProjectId=YOUR_PROJECT_ID
-DblackBoxTests.pubSubSubscriptionId=YOUR_SUBSCRIPTION_ID
-DblackBoxTests.pubSubTopicId=YOUR_TOPIC_ID
-DblackBoxTests.pubSubServiceAccountKey=YOUR_SERVICE_ACCOUNT_KEY (raw JSON, path to the key file, or base64-encoded JSON)
- 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

15
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/integration/AbstractIntegrationTest.java

@ -102,12 +102,15 @@ public abstract class AbstractIntegrationTest extends AbstractContainerTest {
testRestClient.setRootRuleChain(defaultRuleChainId);
if (device != null) {
testRestClient.deleteDevice(device.getId());
if (integration.getId() != null) {
testRestClient.deleteIntegration(integration.getId());
}
testRestClient.deleteConverter(integration.getDefaultConverterId());
if (integration.getDownlinkConverterId() != null) {
testRestClient.deleteConverter(integration.getDownlinkConverterId());
if (integration != null) {
if (integration.getId() != null) {
testRestClient.deleteIntegration(integration.getId());
}
testRestClient.deleteConverter(integration.getDefaultConverterId());
if (integration.getDownlinkConverterId() != null) {
testRestClient.deleteConverter(integration.getDownlinkConverterId());
}
integration = null;
}
if (secret != null) {
testRestClient.deleteSecret(secret.getId());

5
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/integration/ChirpStackIntegrationTest.java

@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.testng.SkipException;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@ -17,6 +18,7 @@ import org.thingsboard.server.common.data.event.EventType;
import org.thingsboard.server.common.data.id.RuleChainId;
import org.thingsboard.server.common.data.rule.RuleChainMetaData;
import org.thingsboard.server.common.data.rule.RuleNode;
import org.thingsboard.server.msa.ContainerTestSuite;
import org.thingsboard.server.msa.TestProperties;
import org.thingsboard.server.msa.WsClient;
import org.thingsboard.server.msa.integration.chirpstack.ChirpStackTestClient;
@ -74,6 +76,9 @@ public class ChirpStackIntegrationTest extends AbstractIntegrationTest {
@BeforeClass
public void beforeChirpStackClass() {
if (!ContainerTestSuite.getInstance().isActive()) {
throw new SkipException("ChirpStack tests need the docker-compose test environment");
}
chirpStackClient = new ChirpStackTestClient(TestProperties.getChirpStackRestUrl());
}

18
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/integration/PubSubIntegrationTest.java

@ -16,6 +16,7 @@ import org.apache.commons.lang3.RandomStringUtils;
import org.awaitility.Awaitility;
import org.testng.SkipException;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.thingsboard.common.util.JacksonUtil;
@ -62,6 +63,18 @@ public class PubSubIntegrationTest extends AbstractIntegrationTest {
private JsonNode uplinkConverterCode;
private WsClient wsClient;
private String projectId;
private String subscriptionId;
private String topicId;
private String serviceAccountKey;
@BeforeClass
public void beforePubSubClass() throws Exception {
projectId = requireProperty("blackBoxTests.pubSubProjectId");
subscriptionId = requireProperty("blackBoxTests.pubSubSubscriptionId");
topicId = requireProperty("blackBoxTests.pubSubTopicId");
serviceAccountKey = resolveServiceAccountKey(requireProperty("blackBoxTests.pubSubServiceAccountKey"));
}
@BeforeMethod
public void setUp() {
@ -79,11 +92,6 @@ public class PubSubIntegrationTest extends AbstractIntegrationTest {
@Test
public void shouldReceiveUplinkFromPubSubSubscription() throws Exception {
String projectId = requireProperty("blackBoxTests.pubSubProjectId");
String subscriptionId = requireProperty("blackBoxTests.pubSubSubscriptionId");
String topicId = requireProperty("blackBoxTests.pubSubTopicId");
String serviceAccountKey = resolveServiceAccountKey(requireProperty("blackBoxTests.pubSubServiceAccountKey"));
createPubSubIntegration(projectId, subscriptionId, serviceAccountKey);
wsClient = subscribeToWebSocket(device.getId(), "LATEST_TELEMETRY", CmdsType.TS_SUB_CMDS);

27
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/integration/TTNIntegrationTest.java

@ -9,6 +9,7 @@ import org.apache.commons.lang3.RandomStringUtils;
import org.awaitility.Awaitility;
import org.testng.SkipException;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.thingsboard.common.util.JacksonUtil;
@ -107,6 +108,20 @@ public class TTNIntegrationTest extends AbstractIntegrationTest {
// Coordinates for clearing the shared The Things Stack downlink queue in tearDown — set by the
// downlink test so a leftover queued downlink does not bleed into other runs.
private String[] downlinkQueueCoordinates;
private String region;
private String username;
private String password;
private String appId;
private String deviceId;
@BeforeClass
public void beforeTtnClass() {
region = requireProperty("blackBoxTests.ttnRegion");
username = requireProperty("blackBoxTests.ttnUsername");
password = requireProperty("blackBoxTests.ttnPassword");
appId = requireProperty("blackBoxTests.ttnAppId");
deviceId = requireProperty("blackBoxTests.ttnDeviceId");
}
@BeforeMethod
public void setUp() {
@ -132,12 +147,6 @@ public class TTNIntegrationTest extends AbstractIntegrationTest {
@Test
public void shouldReceiveSimulatedUplinkFromTheThingsStack() throws Exception {
String region = requireProperty("blackBoxTests.ttnRegion");
String username = requireProperty("blackBoxTests.ttnUsername");
String password = requireProperty("blackBoxTests.ttnPassword");
String appId = requireProperty("blackBoxTests.ttnAppId");
String deviceId = requireProperty("blackBoxTests.ttnDeviceId");
createTtnIntegration(region, username, password);
wsClient = subscribeToWebSocket(device.getId(), "LATEST_TELEMETRY", CmdsType.TS_SUB_CMDS);
@ -152,12 +161,6 @@ public class TTNIntegrationTest extends AbstractIntegrationTest {
@Test
public void shouldEnqueueDownlinkInTheThingsStack() throws Exception {
String region = requireProperty("blackBoxTests.ttnRegion");
String username = requireProperty("blackBoxTests.ttnUsername");
String password = requireProperty("blackBoxTests.ttnPassword");
String appId = requireProperty("blackBoxTests.ttnAppId");
String deviceId = requireProperty("blackBoxTests.ttnDeviceId");
JsonNode downlinkConverter = JacksonUtil.newObjectNode().put("encoder", DOWNLINK_CONVERTER_ENCODER);
createTtnIntegration(region, username, password, downlinkConverter);

Loading…
Cancel
Save