replaced thread sleeps in telemetry tests
This commit is contained in:
parent
d7291d1171
commit
0879b1afae
@ -148,13 +148,12 @@ public class MqttAttributesIntegrationTest extends AbstractMqttIntegrationTest {
|
|||||||
|
|
||||||
assertNotNull(secondDevice);
|
assertNotNull(secondDevice);
|
||||||
|
|
||||||
// todo removed sleep
|
List<String> firstDeviceActualKeys = getActualKeysList(firstDevice.getId(), expectedKeys);
|
||||||
Thread.sleep(2000);
|
assertNotNull(firstDeviceActualKeys);
|
||||||
|
|
||||||
List<String> firstDeviceActualKeys = doGetAsyncTyped("/api/plugins/telemetry/DEVICE/" + firstDevice.getId() + "/keys/attributes/CLIENT_SCOPE", new TypeReference<>() {});
|
|
||||||
Set<String> firstDeviceActualKeySet = new HashSet<>(firstDeviceActualKeys);
|
Set<String> firstDeviceActualKeySet = new HashSet<>(firstDeviceActualKeys);
|
||||||
|
|
||||||
List<String> secondDeviceActualKeys = doGetAsyncTyped("/api/plugins/telemetry/DEVICE/" + secondDevice.getId() + "/keys/attributes/CLIENT_SCOPE", new TypeReference<>() {});
|
List<String> secondDeviceActualKeys = getActualKeysList(secondDevice.getId(), expectedKeys);
|
||||||
|
assertNotNull(secondDeviceActualKeys);
|
||||||
Set<String> secondDeviceActualKeySet = new HashSet<>(secondDeviceActualKeys);
|
Set<String> secondDeviceActualKeySet = new HashSet<>(secondDeviceActualKeys);
|
||||||
|
|
||||||
Set<String> expectedKeySet = new HashSet<>(expectedKeys);
|
Set<String> expectedKeySet = new HashSet<>(expectedKeys);
|
||||||
@ -173,6 +172,21 @@ public class MqttAttributesIntegrationTest extends AbstractMqttIntegrationTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<String> getActualKeysList(DeviceId deviceId, List<String> expectedKeys) throws Exception {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
long end = System.currentTimeMillis() + 3000;
|
||||||
|
List<String> firstDeviceActualKeys = null;
|
||||||
|
while (start <= end) {
|
||||||
|
firstDeviceActualKeys = doGetAsyncTyped("/api/plugins/telemetry/DEVICE/" + deviceId + "/keys/attributes/CLIENT_SCOPE", new TypeReference<>() {});
|
||||||
|
if (firstDeviceActualKeys.size() == expectedKeys.size()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(100);
|
||||||
|
start += 100;
|
||||||
|
}
|
||||||
|
return firstDeviceActualKeys;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected void assertAttributesValues(List<Map<String, Object>> deviceValues, Set<String> keySet) throws JsonProcessingException {
|
protected void assertAttributesValues(List<Map<String, Object>> deviceValues, Set<String> keySet) throws JsonProcessingException {
|
||||||
for (Map<String, Object> map : deviceValues) {
|
for (Map<String, Object> map : deviceValues) {
|
||||||
|
|||||||
@ -123,20 +123,11 @@ public abstract class AbstractMqttTimeseriesIntegrationTest extends AbstractMqtt
|
|||||||
client.publishAndWait(topic, payload);
|
client.publishAndWait(topic, payload);
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
|
|
||||||
String deviceId = savedDevice.getId().getId().toString();
|
DeviceId deviceId = savedDevice.getId();
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
List<String> actualKeys = getActualKeysList(deviceId, expectedKeys);
|
||||||
long end = System.currentTimeMillis() + 5000;
|
long end;
|
||||||
|
long start;
|
||||||
List<String> actualKeys = null;
|
|
||||||
while (start <= end) {
|
|
||||||
actualKeys = doGetAsyncTyped("/api/plugins/telemetry/DEVICE/" + deviceId + "/keys/timeseries", new TypeReference<>() {});
|
|
||||||
if (actualKeys.size() == expectedKeys.size()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Thread.sleep(100);
|
|
||||||
start += 100;
|
|
||||||
}
|
|
||||||
assertNotNull(actualKeys);
|
assertNotNull(actualKeys);
|
||||||
|
|
||||||
Set<String> actualKeySet = new HashSet<>(actualKeys);
|
Set<String> actualKeySet = new HashSet<>(actualKeys);
|
||||||
@ -207,13 +198,10 @@ public abstract class AbstractMqttTimeseriesIntegrationTest extends AbstractMqtt
|
|||||||
|
|
||||||
assertNotNull(secondDevice);
|
assertNotNull(secondDevice);
|
||||||
|
|
||||||
// TODO remove sleep
|
List<String> firstDeviceActualKeys = getActualKeysList(firstDevice.getId(), expectedKeys);
|
||||||
Thread.sleep(2000);
|
|
||||||
|
|
||||||
List<String> firstDeviceActualKeys = doGetAsyncTyped("/api/plugins/telemetry/DEVICE/" + firstDevice.getId() + "/keys/timeseries", new TypeReference<>() {});
|
|
||||||
Set<String> firstDeviceActualKeySet = new HashSet<>(firstDeviceActualKeys);
|
Set<String> firstDeviceActualKeySet = new HashSet<>(firstDeviceActualKeys);
|
||||||
|
|
||||||
List<String> secondDeviceActualKeys = doGetAsyncTyped("/api/plugins/telemetry/DEVICE/" + secondDevice.getId() + "/keys/timeseries", new TypeReference<>() {});
|
List<String> secondDeviceActualKeys = getActualKeysList(secondDevice.getId(), expectedKeys);
|
||||||
Set<String> secondDeviceActualKeySet = new HashSet<>(secondDeviceActualKeys);
|
Set<String> secondDeviceActualKeySet = new HashSet<>(secondDeviceActualKeys);
|
||||||
|
|
||||||
Set<String> expectedKeySet = new HashSet<>(expectedKeys);
|
Set<String> expectedKeySet = new HashSet<>(expectedKeys);
|
||||||
@ -231,6 +219,22 @@ public abstract class AbstractMqttTimeseriesIntegrationTest extends AbstractMqtt
|
|||||||
assertGatewayDeviceData(secondDeviceValues, expectedKeys);
|
assertGatewayDeviceData(secondDeviceValues, expectedKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<String> getActualKeysList(DeviceId deviceId, List<String> expectedKeys) throws Exception {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
long end = System.currentTimeMillis() + 3000;
|
||||||
|
|
||||||
|
List<String> actualKeys = null;
|
||||||
|
while (start <= end) {
|
||||||
|
actualKeys = doGetAsyncTyped("/api/plugins/telemetry/DEVICE/" + deviceId + "/keys/timeseries", new TypeReference<>() {});
|
||||||
|
if (actualKeys.size() == expectedKeys.size()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(100);
|
||||||
|
start += 100;
|
||||||
|
}
|
||||||
|
return actualKeys;
|
||||||
|
}
|
||||||
|
|
||||||
protected String getGatewayTelemetryJsonPayload(String deviceA, String deviceB, String firstTsValue, String secondTsValue) {
|
protected String getGatewayTelemetryJsonPayload(String deviceA, String deviceB, String firstTsValue, String secondTsValue) {
|
||||||
String payload = "[{\"ts\": " + firstTsValue + ", \"values\": " + PAYLOAD_VALUES_STR + "}, " +
|
String payload = "[{\"ts\": " + firstTsValue + ", \"values\": " + PAYLOAD_VALUES_STR + "}, " +
|
||||||
"{\"ts\": " + secondTsValue + ", \"values\": " + PAYLOAD_VALUES_STR + "}]";
|
"{\"ts\": " + secondTsValue + ", \"values\": " + PAYLOAD_VALUES_STR + "}]";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user