Merge pull request #13565 from irynamatveieva/cf-old-telemetry-ts
Fixed updating CF state when old telemetry sent
This commit is contained in:
commit
dfc0183c41
@ -107,7 +107,7 @@ public class SingleValueArgumentEntry implements ArgumentEntry {
|
|||||||
@Override
|
@Override
|
||||||
public boolean updateEntry(ArgumentEntry entry) {
|
public boolean updateEntry(ArgumentEntry entry) {
|
||||||
if (entry instanceof SingleValueArgumentEntry singleValueEntry) {
|
if (entry instanceof SingleValueArgumentEntry singleValueEntry) {
|
||||||
if (singleValueEntry.getTs() == this.ts) {
|
if (singleValueEntry.getTs() <= this.ts) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -555,7 +555,7 @@ public class CalculatedFieldIntegrationTest extends CalculatedFieldControllerTes
|
|||||||
});
|
});
|
||||||
|
|
||||||
long tsABeforeTsB = tsB - 300L;
|
long tsABeforeTsB = tsB - 300L;
|
||||||
doPost("/api/plugins/telemetry/DEVICE/" + testDevice.getUuidId() + "/timeseries/" + DataConstants.SERVER_SCOPE, JacksonUtil.toJsonNode(String.format("{\"ts\": %s, \"values\": {\"b\":10}}", tsABeforeTsB)));
|
doPost("/api/plugins/telemetry/DEVICE/" + testDevice.getUuidId() + "/timeseries/" + DataConstants.SERVER_SCOPE, JacksonUtil.toJsonNode(String.format("{\"ts\": %s, \"values\": {\"a\":10}}", tsABeforeTsB)));
|
||||||
|
|
||||||
await().alias("update telemetry with ts less than latest -> save result with latest ts").atMost(TIMEOUT, TimeUnit.SECONDS)
|
await().alias("update telemetry with ts less than latest -> save result with latest ts").atMost(TIMEOUT, TimeUnit.SECONDS)
|
||||||
.pollInterval(POLL_INTERVAL, TimeUnit.SECONDS)
|
.pollInterval(POLL_INTERVAL, TimeUnit.SECONDS)
|
||||||
@ -563,7 +563,7 @@ public class CalculatedFieldIntegrationTest extends CalculatedFieldControllerTes
|
|||||||
ObjectNode c = getLatestTelemetry(testDevice.getId(), "c");
|
ObjectNode c = getLatestTelemetry(testDevice.getId(), "c");
|
||||||
assertThat(c).isNotNull();
|
assertThat(c).isNotNull();
|
||||||
assertThat(c.get("c").get(0).get("ts").asText()).isEqualTo(Long.toString(tsB));// also tsB, since this is the latest timestamp
|
assertThat(c.get("c").get(0).get("ts").asText()).isEqualTo(Long.toString(tsB));// also tsB, since this is the latest timestamp
|
||||||
assertThat(c.get("c").get(0).get("value").asText()).isEqualTo("11.0");
|
assertThat(c.get("c").get(0).get("value").asText()).isEqualTo("15.0");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -53,7 +53,7 @@ public class SingleValueArgumentEntryTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testUpdateEntryWithThaSameTs() {
|
void testUpdateEntryWithTheSameTs() {
|
||||||
assertThat(entry.updateEntry(new SingleValueArgumentEntry(ts, new LongDataEntry("key", 13L), 363L))).isFalse();
|
assertThat(entry.updateEntry(new SingleValueArgumentEntry(ts, new LongDataEntry("key", 13L), 363L))).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +81,11 @@ public class SingleValueArgumentEntryTest {
|
|||||||
assertThat(entry.updateEntry(new SingleValueArgumentEntry(ts + 18, new LongDataEntry("key", 11L), 364L))).isTrue();
|
assertThat(entry.updateEntry(new SingleValueArgumentEntry(ts + 18, new LongDataEntry("key", 11L), 364L))).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testUpdateEntryWithOldTs() {
|
||||||
|
assertThat(entry.updateEntry(new SingleValueArgumentEntry(ts - 10, new LongDataEntry("key", 14L), 365L))).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testToTbelCfArgWhenJsonIsObject() {
|
void testToTbelCfArgWhenJsonIsObject() {
|
||||||
entry = new SingleValueArgumentEntry(ts, new JsonDataEntry("key", "{\"test\": 10}"), 370L);
|
entry = new SingleValueArgumentEntry(ts, new JsonDataEntry("key", "{\"test\": 10}"), 370L);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user