Browse Source

Merge remote-tracking branch 'upstream/master' into edge-3.3-locale-updates

pull/4918/head
Volodymyr Babak 5 years ago
parent
commit
c84552551c
  1. 26
      application/src/test/java/org/thingsboard/server/transport/mqtt/attributes/request/AbstractMqttAttributesRequestIntegrationTest.java
  2. 1
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/uplink/DefaultLwM2MUplinkMsgHandler.java
  3. 3
      dao/src/main/resources/sql/schema-entities-hsql.sql
  4. 1
      dao/src/main/resources/sql/schema-ts-hsql.sql
  5. 42
      msa/black-box-tests/pom.xml
  6. 9
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ThingsBoardDbInstaller.java
  7. 2
      msa/js-executor/pom.xml
  8. 27
      msa/pom.xml
  9. 2
      msa/web-ui/pom.xml
  10. 61
      pom.xml
  11. 3
      ui-ngx/pom.xml

26
application/src/test/java/org/thingsboard/server/transport/mqtt/attributes/request/AbstractMqttAttributesRequestIntegrationTest.java

@ -66,7 +66,7 @@ public abstract class AbstractMqttAttributesRequestIntegrationTest extends Abstr
postAttributesAndSubscribeToTopic(savedDevice, client);
Thread.sleep(1000);
Thread.sleep(2000);
TestMqttCallback callback = getTestMqttCallback();
client.setCallback(callback);
@ -86,13 +86,13 @@ public abstract class AbstractMqttAttributesRequestIntegrationTest extends Abstr
assertNotNull(savedDevice);
Thread.sleep(1000);
Thread.sleep(2000);
doPostAsync("/api/plugins/telemetry/DEVICE/" + savedDevice.getId().getId() + "/attributes/SHARED_SCOPE", POST_ATTRIBUTES_PAYLOAD, String.class, status().isOk());
Thread.sleep(1000);
Thread.sleep(2000);
client.subscribe(MqttTopics.GATEWAY_ATTRIBUTES_RESPONSE_TOPIC, MqttQoS.AT_LEAST_ONCE.value());
client.subscribe(MqttTopics.GATEWAY_ATTRIBUTES_RESPONSE_TOPIC, MqttQoS.AT_LEAST_ONCE.value()).waitForCompletion(TimeUnit.MINUTES.toMillis(1));
TestMqttCallback clientAttributesCallback = getTestMqttCallback();
client.setCallback(clientAttributesCallback);
@ -105,13 +105,13 @@ public abstract class AbstractMqttAttributesRequestIntegrationTest extends Abstr
protected void postAttributesAndSubscribeToTopic(Device savedDevice, MqttAsyncClient client) throws Exception {
doPostAsync("/api/plugins/telemetry/DEVICE/" + savedDevice.getId().getId() + "/attributes/SHARED_SCOPE", POST_ATTRIBUTES_PAYLOAD, String.class, status().isOk());
client.publish(MqttTopics.DEVICE_ATTRIBUTES_TOPIC, new MqttMessage(POST_ATTRIBUTES_PAYLOAD.getBytes()));
client.subscribe(MqttTopics.DEVICE_ATTRIBUTES_RESPONSES_TOPIC, MqttQoS.AT_MOST_ONCE.value());
client.publish(MqttTopics.DEVICE_ATTRIBUTES_TOPIC, new MqttMessage(POST_ATTRIBUTES_PAYLOAD.getBytes())).waitForCompletion(TimeUnit.MINUTES.toMillis(1));
client.subscribe(MqttTopics.DEVICE_ATTRIBUTES_RESPONSES_TOPIC, MqttQoS.AT_MOST_ONCE.value()).waitForCompletion(TimeUnit.MINUTES.toMillis(1));
}
protected void postGatewayDeviceClientAttributes(MqttAsyncClient client) throws Exception {
String postClientAttributes = "{\"" + "Gateway Device Request Attributes" + "\":{\"attribute1\":\"value1\",\"attribute2\":true,\"attribute3\":42.0,\"attribute4\":73,\"attribute5\":{\"someNumber\":42,\"someArray\":[1,2,3],\"someNestedObject\":{\"key\":\"value\"}}}}";
client.publish(MqttTopics.GATEWAY_ATTRIBUTES_TOPIC, new MqttMessage(postClientAttributes.getBytes()));
client.publish(MqttTopics.GATEWAY_ATTRIBUTES_TOPIC, new MqttMessage(postClientAttributes.getBytes())).waitForCompletion(TimeUnit.MINUTES.toMillis(1));
}
protected void validateResponse(MqttAsyncClient client, CountDownLatch latch, TestMqttCallback callback) throws MqttException, InterruptedException, InvalidProtocolBufferException {
@ -119,8 +119,8 @@ public abstract class AbstractMqttAttributesRequestIntegrationTest extends Abstr
String payloadStr = "{\"clientKeys\":\"" + keys + "\", \"sharedKeys\":\"" + keys + "\"}";
MqttMessage mqttMessage = new MqttMessage();
mqttMessage.setPayload(payloadStr.getBytes());
client.publish(MqttTopics.DEVICE_ATTRIBUTES_REQUEST_TOPIC_PREFIX + "1", mqttMessage);
latch.await(3, TimeUnit.SECONDS);
client.publish(MqttTopics.DEVICE_ATTRIBUTES_REQUEST_TOPIC_PREFIX + "1", mqttMessage).waitForCompletion(TimeUnit.MINUTES.toMillis(1));
latch.await(1, TimeUnit.MINUTES);
assertEquals(MqttQoS.AT_MOST_ONCE.value(), callback.getQoS());
String expectedRequestPayload = "{\"client\":{\"attribute1\":\"value1\",\"attribute2\":true,\"attribute3\":42.0,\"attribute4\":73,\"attribute5\":{\"someNumber\":42,\"someArray\":[1,2,3],\"someNestedObject\":{\"key\":\"value\"}}},\"shared\":{\"attribute1\":\"value1\",\"attribute2\":true,\"attribute3\":42.0,\"attribute4\":73,\"attribute5\":{\"someNumber\":42,\"someArray\":[1,2,3],\"someNestedObject\":{\"key\":\"value\"}}}}";
assertEquals(JacksonUtil.toJsonNode(expectedRequestPayload), JacksonUtil.toJsonNode(new String(callback.getPayloadBytes(), StandardCharsets.UTF_8)));
@ -130,8 +130,8 @@ public abstract class AbstractMqttAttributesRequestIntegrationTest extends Abstr
String payloadStr = "{\"id\": 1, \"device\": \"" + "Gateway Device Request Attributes" + "\", \"client\": true, \"keys\": [\"attribute1\", \"attribute2\", \"attribute3\", \"attribute4\", \"attribute5\"]}";
MqttMessage mqttMessage = new MqttMessage();
mqttMessage.setPayload(payloadStr.getBytes());
client.publish(MqttTopics.GATEWAY_ATTRIBUTES_REQUEST_TOPIC, mqttMessage);
callback.getLatch().await(3, TimeUnit.SECONDS);
client.publish(MqttTopics.GATEWAY_ATTRIBUTES_REQUEST_TOPIC, mqttMessage).waitForCompletion(TimeUnit.MINUTES.toMillis(1));
callback.getLatch().await(1, TimeUnit.MINUTES);
assertEquals(MqttQoS.AT_LEAST_ONCE.value(), callback.getQoS());
String expectedRequestPayload = "{\"id\":1,\"device\":\"" + "Gateway Device Request Attributes" + "\",\"values\":{\"attribute1\":\"value1\",\"attribute2\":true,\"attribute3\":42.0,\"attribute4\":73,\"attribute5\":{\"someNumber\":42,\"someArray\":[1,2,3],\"someNestedObject\":{\"key\":\"value\"}}}}";
assertEquals(JacksonUtil.toJsonNode(expectedRequestPayload), JacksonUtil.toJsonNode(new String(callback.getPayloadBytes(), StandardCharsets.UTF_8)));
@ -141,8 +141,8 @@ public abstract class AbstractMqttAttributesRequestIntegrationTest extends Abstr
String payloadStr = "{\"id\": 1, \"device\": \"" + "Gateway Device Request Attributes" + "\", \"client\": false, \"keys\": [\"attribute1\", \"attribute2\", \"attribute3\", \"attribute4\", \"attribute5\"]}";
MqttMessage mqttMessage = new MqttMessage();
mqttMessage.setPayload(payloadStr.getBytes());
client.publish(MqttTopics.GATEWAY_ATTRIBUTES_REQUEST_TOPIC, mqttMessage);
callback.getLatch().await(3, TimeUnit.SECONDS);
client.publish(MqttTopics.GATEWAY_ATTRIBUTES_REQUEST_TOPIC, mqttMessage).waitForCompletion(TimeUnit.MINUTES.toMillis(1));
callback.getLatch().await(1, TimeUnit.MINUTES);
assertEquals(MqttQoS.AT_LEAST_ONCE.value(), callback.getQoS());
String expectedRequestPayload = "{\"id\":1,\"device\":\"" + "Gateway Device Request Attributes" + "\",\"values\":{\"attribute1\":\"value1\",\"attribute2\":true,\"attribute3\":42.0,\"attribute4\":73,\"attribute5\":{\"someNumber\":42,\"someArray\":[1,2,3],\"someNestedObject\":{\"key\":\"value\"}}}}";
assertEquals(JacksonUtil.toJsonNode(expectedRequestPayload), JacksonUtil.toJsonNode(new String(callback.getPayloadBytes(), StandardCharsets.UTF_8)));

1
common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/uplink/DefaultLwM2MUplinkMsgHandler.java

@ -422,6 +422,7 @@ public class DefaultLwM2MUplinkMsgHandler extends LwM2MExecutorAwareService impl
private void sendReadRequests(LwM2mClient lwM2MClient, Lwm2mDeviceProfileTransportConfiguration profile, Set<String> supportedObjects) {
Set<String> targetIds = new HashSet<>(profile.getObserveAttr().getAttribute());
targetIds.addAll(profile.getObserveAttr().getTelemetry());
targetIds = diffSets(profile.getObserveAttr().getObserve(), targetIds);
targetIds = targetIds.stream().filter(target -> isSupportedTargetId(supportedObjects, target)).collect(Collectors.toSet());
CountDownLatch latch = new CountDownLatch(targetIds.size());

3
dao/src/main/resources/sql/schema-entities-hsql.sql

@ -14,6 +14,9 @@
-- limitations under the License.
--
SET DATABASE SQL SYNTAX PGS TRUE;
SET DATABASE TRANSACTION CONTROL MVCC;
CREATE TABLE IF NOT EXISTS admin_settings (
id uuid NOT NULL CONSTRAINT admin_settings_pkey PRIMARY KEY,
created_time bigint NOT NULL,

1
dao/src/main/resources/sql/schema-ts-hsql.sql

@ -15,6 +15,7 @@
--
SET DATABASE SQL SYNTAX PGS TRUE;
SET DATABASE TRANSACTION CONTROL MVCC;
CREATE TABLE IF NOT EXISTS ts_kv (
entity_id uuid NOT NULL,

42
msa/black-box-tests/pom.xml

@ -34,7 +34,6 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<main.dir>${basedir}/../..</main.dir>
<blackBoxTests.skip>true</blackBoxTests.skip>
<testcontainers.version>1.11.4</testcontainers.version>
<zeroturnaround.version>1.10</zeroturnaround.version>
<httpclient.version>4.5.13</httpclient.version>
@ -92,8 +91,47 @@
<groupId>org.thingsboard</groupId>
<artifactId>rest-client</artifactId>
</dependency>
<dependency>
<groupId>org.thingsboard.msa</groupId>
<artifactId>js-executor</artifactId>
<type>docker-info</type>
</dependency>
<dependency>
<groupId>org.thingsboard.msa</groupId>
<artifactId>web-ui</artifactId>
<type>docker-info</type>
</dependency>
<dependency>
<groupId>org.thingsboard.msa</groupId>
<artifactId>tb-node</artifactId>
<type>docker-info</type>
</dependency>
<dependency>
<groupId>org.thingsboard.msa.transport</groupId>
<artifactId>coap</artifactId>
<type>docker-info</type>
</dependency>
<dependency>
<groupId>org.thingsboard.msa.transport</groupId>
<artifactId>http</artifactId>
<type>docker-info</type>
</dependency>
<dependency>
<groupId>org.thingsboard.msa.transport</groupId>
<artifactId>mqtt</artifactId>
<type>docker-info</type>
</dependency>
<dependency>
<groupId>org.thingsboard.msa.transport</groupId>
<artifactId>lwm2m</artifactId>
<type>docker-info</type>
</dependency>
<dependency>
<groupId>org.thingsboard.msa.transport</groupId>
<artifactId>snmp</artifactId>
<type>docker-info</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>

9
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ThingsBoardDbInstaller.java

@ -15,6 +15,7 @@
*/
package org.thingsboard.server.msa;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.rules.ExternalResource;
import org.testcontainers.utility.Base58;
@ -136,13 +137,15 @@ public class ThingsBoardDbInstaller extends ExternalResource {
File tbLogsDir = new File(targetDir);
tbLogsDir.mkdirs();
dockerCompose.withCommand("run -d --rm --name tb-logs-container -v " + volumeName + ":/root alpine tail -f /dev/null");
String logsContainerName = "tb-logs-container-" + RandomStringUtils.randomAlphanumeric(10);
dockerCompose.withCommand("run -d --rm --name " + logsContainerName + " -v " + volumeName + ":/root alpine tail -f /dev/null");
dockerCompose.invokeDocker();
dockerCompose.withCommand("cp tb-logs-container:/root/. "+tbLogsDir.getAbsolutePath());
dockerCompose.withCommand("cp " + logsContainerName + ":/root/. "+tbLogsDir.getAbsolutePath());
dockerCompose.invokeDocker();
dockerCompose.withCommand("rm -f tb-logs-container");
dockerCompose.withCommand("rm -f " + logsContainerName);
dockerCompose.invokeDocker();
}

2
msa/js-executor/pom.xml

@ -59,7 +59,6 @@
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.7.5</version>
<configuration>
<installDirectory>target</installDirectory>
<workingDirectory>${basedir}</workingDirectory>
@ -149,7 +148,6 @@
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.7.5</version>
<configuration>
<installDirectory>target</installDirectory>
<workingDirectory>${basedir}</workingDirectory>

27
msa/pom.xml

@ -33,6 +33,8 @@
<main.dir>${basedir}/..</main.dir>
<docker.repo>thingsboard</docker.repo>
<dockerfile.skip>true</dockerfile.skip>
<blackBoxTests.skip>true</blackBoxTests.skip>
<dockerfile-maven.version>1.4.13</dockerfile-maven.version>
</properties>
<modules>
@ -41,16 +43,37 @@
<module>web-ui</module>
<module>tb-node</module>
<module>transport</module>
<module>black-box-tests</module>
</modules>
<profiles>
<profile>
<id>black-box-tests</id>
<activation>
<property>
<name>blackBoxTests.skip</name>
<value>false</value>
</property>
</activation>
<modules>
<module>black-box-tests</module>
</modules>
</profile>
</profiles>
<build>
<extensions>
<extension>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-extension</artifactId>
<version>${dockerfile-maven.version}</version>
</extension>
</extensions>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.13</version>
<version>${dockerfile-maven.version}</version>
</plugin>
</plugins>
</pluginManagement>

2
msa/web-ui/pom.xml

@ -68,7 +68,6 @@
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.7.5</version>
<configuration>
<installDirectory>target</installDirectory>
<workingDirectory>${basedir}</workingDirectory>
@ -196,7 +195,6 @@
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.7.5</version>
<configuration>
<installDirectory>target</installDirectory>
<workingDirectory>${basedir}</workingDirectory>

61
pom.xml

@ -635,6 +635,11 @@
<artifactId>gradle-maven-plugin</artifactId>
<version>1.0.10</version>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.12.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
@ -960,6 +965,62 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.thingsboard.msa</groupId>
<artifactId>js-executor</artifactId>
<version>${project.version}</version>
<type>docker-info</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.thingsboard.msa</groupId>
<artifactId>web-ui</artifactId>
<version>${project.version}</version>
<type>docker-info</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.thingsboard.msa</groupId>
<artifactId>tb-node</artifactId>
<version>${project.version}</version>
<type>docker-info</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.thingsboard.msa.transport</groupId>
<artifactId>coap</artifactId>
<version>${project.version}</version>
<type>docker-info</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.thingsboard.msa.transport</groupId>
<artifactId>http</artifactId>
<version>${project.version}</version>
<type>docker-info</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.thingsboard.msa.transport</groupId>
<artifactId>mqtt</artifactId>
<version>${project.version}</version>
<type>docker-info</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.thingsboard.msa.transport</groupId>
<artifactId>lwm2m</artifactId>
<version>${project.version}</version>
<type>docker-info</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.thingsboard.msa.transport</groupId>
<artifactId>snmp</artifactId>
<version>${project.version}</version>
<type>docker-info</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.thingsboard</groupId>
<artifactId>dao</artifactId>

3
ui-ngx/pom.xml

@ -45,7 +45,6 @@
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.7.5</version>
<configuration>
<installDirectory>target</installDirectory>
<workingDirectory>${basedir}</workingDirectory>
@ -85,7 +84,6 @@
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.7.5</version>
<configuration>
<installDirectory>target</installDirectory>
<workingDirectory>${basedir}</workingDirectory>
@ -117,7 +115,6 @@
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.7.5</version>
<configuration>
<installDirectory>target</installDirectory>
<workingDirectory>${basedir}</workingDirectory>

Loading…
Cancel
Save