Skip to content

Commit

Permalink
Add new lengthy test
Browse files Browse the repository at this point in the history
  • Loading branch information
grafnu committed Oct 1, 2024
1 parent c122de2 commit 2bf9375
Show file tree
Hide file tree
Showing 11 changed files with 215 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/traces/lengthy/devices/AHU-1/001_events_pointset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"points" : {
"filter_alarm_pressure_status" : {
"present_value" : true
},
"filter_differential_pressure_sensor" : {
"present_value" : 11
}
},
"timestamp" : "2022-07-17T05:04:26Z",
"version" : "1.5.1"
}
14 changes: 14 additions & 0 deletions tests/traces/lengthy/devices/AHU-1/002_events_system.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"logentries" : [ {
"message" : "2022-07-19T05:04:36Z sending test message #70",
"category" : "device.testing",
"timestamp" : "2022-07-19T05:04:36Z",
"level" : 200
} ],
"metrics": {
"mem_total_mb": 25164.88,
"store_total_mb": null
},
"timestamp" : "2022-07-17T05:34:36+0000",
"version" : "1.5.1"
}
15 changes: 15 additions & 0 deletions tests/traces/lengthy/devices/AHU-1/003_events_pointset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"points" : {
"filter_alarm_pressure_status" : {
"present_value" : true
},
"filter_differential_pressure_setpoint" : {
"present_value" : 98
},
"filter_differential_pressure_sensor" : {
"present_value" : 11
}
},
"timestamp" : "2022-07-17T06:07:36Z", // Over threshold from _initial_ event
"version" : "1.5.1"
}
10 changes: 10 additions & 0 deletions tests/traces/lengthy/expected/devices/AHU-1/events_pointset.attr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"deviceNumId" : "00000062256946",
"publishTime" : "1999-10-20T01:02:03Z",
"subFolder" : "pointset",
"deviceRegistryId" : "ZZ-TRI-FECTA",
"subType" : "events",
"msgSource" : "003_events_pointset.json",
"deviceId" : "AHU-1",
"projectId" : "playback-project"
}
15 changes: 15 additions & 0 deletions tests/traces/lengthy/expected/devices/AHU-1/events_pointset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"points" : {
"filter_alarm_pressure_status" : {
"present_value" : true
},
"filter_differential_pressure_setpoint" : {
"present_value" : 98
},
"filter_differential_pressure_sensor" : {
"present_value" : 11
}
},
"timestamp" : "1999-10-20T01:02:03Z",
"version" : "1.5.1"
}
17 changes: 17 additions & 0 deletions tests/traces/lengthy/expected/devices/AHU-1/events_pointset.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"timestamp" : "1999-10-20T01:02:03Z",
"version" : "1.5.1",
"sub_folder" : "pointset",
"sub_type" : "events",
"status" : {
"message" : "Successful validation",
"category" : "validation.device.receive",
"timestamp" : "1999-10-20T01:02:03Z",
"level" : 200
},
"pointset" : {
"missing" : [ ],
"extra" : [ ]
},
"errors" : [ ]
}
10 changes: 10 additions & 0 deletions tests/traces/lengthy/expected/devices/AHU-1/events_system.attr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"deviceNumId" : "00000062256946",
"publishTime" : "2022-07-19T05:04:36+0000",
"subFolder" : "system",
"deviceRegistryId" : "ZZ-TRI-FECTA",
"subType" : "events",
"msgSource" : "002_events_system.json",
"deviceId" : "AHU-1",
"projectId" : "playback-project"
}
13 changes: 13 additions & 0 deletions tests/traces/lengthy/expected/devices/AHU-1/events_system.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"logentries" : [ {
"message" : "1999-10-20T01:02:03Z sending test message #70",
"category" : "device.testing",
"timestamp" : "1999-10-20T01:02:03Z",
"level" : 200
} ],
"metrics" : {
"mem_total_mb" : 25164.88
},
"timestamp" : "2022-07-19T05:04:36+0000",
"version" : "1.5.1"
}
13 changes: 13 additions & 0 deletions tests/traces/lengthy/expected/devices/AHU-1/events_system.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"timestamp" : "1999-10-20T01:02:03Z",
"version" : "1.5.1",
"sub_folder" : "system",
"sub_type" : "events",
"status" : {
"message" : "Successful validation",
"category" : "validation.device.receive",
"timestamp" : "1999-10-20T01:02:03Z",
"level" : 200
},
"errors" : [ ]
}
56 changes: 56 additions & 0 deletions tests/traces/lengthy/expected/validation_report.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"timestamp" : "1999-10-20T01:02:03Z",
"version" : "1.5.1",
"cloud_version" : {
"deployed_by" : "Default implementation for class com.google.daq.mqtt.validator.MessageReadingClient"
},
REDACTED,
"start_time" : "1999-10-20T01:02:03Z",
"summary" : {
"correct_devices" : [ "AHU-1" ],
"extra_devices" : [ ],
"missing_devices" : [ ],
"error_devices" : [ "AHU-22", "GAT-123", "SNS-4" ]
},
"devices" : {
"AHU-1" : {
"last_seen" : "1999-10-20T01:02:03Z",
"status" : {
"message" : "Successful validation",
"category" : "validation.device.receive",
"timestamp" : "1999-10-20T01:02:03Z",
"level" : 200
}
},
"AHU-22" : {
"last_seen" : "1999-10-20T01:02:03Z",
"status" : {
"message" : "While converting to json node: 2 schema violations found",
"detail" : "events_pointset: While converting to json node: 2 schema violations found @Validator.validateMessage(REDACTED); 2 schema violations found; object instance has properties which are not allowed by the schema: [\"yesvalue\"]; object has missing required properties ([\"version\"])",
"category" : "validation.device.schema",
"timestamp" : "1999-10-20T01:02:03Z",
"level" : 500
}
},
"GAT-123" : {
"last_seen" : "1999-10-20T01:02:03Z",
"status" : {
"message" : "missing pointset subblock",
"detail" : "state_update: missing pointset subblock",
"category" : "validation.device.schema",
"timestamp" : "1999-10-20T01:02:03Z",
"level" : 500
}
},
"SNS-4" : {
"last_seen" : "1999-10-20T01:02:03Z",
"status" : {
"message" : "Multiple validation errors",
"detail" : "While converting to json node: 1 schema violations found; Device has extra points: rocket_count, triangulating_axis_y; Unexpected character ('{' (code 123)): was expecting double-quote to start field name\n at [Source: (File), line: 1, column: 3]; While converting to json node: 1 schema violations found",
"category" : "validation.device.multiple",
"timestamp" : "1999-10-20T01:02:03Z",
"level" : 500
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
public class PlaybackTest extends TestBase {

public static final String SIMPLE_TRACE_DIR = "../tests/traces/simple";
public static final String LENGTHY_TRACE_DIR = "../tests/traces/lengthy";
private static final List<String> TRACE_DEVICES = List.of("--", "AHU-22", "SNS-4", "XXX", "YYY");

@Test
Expand Down Expand Up @@ -72,6 +73,45 @@ private List<ValidationEvents> reports(List<OutputBundle> outputMessages, String
.collect(Collectors.toList());
}

@Test
public void notMissingDevice() {
MessageReadingClient client = validateTrace(LENGTHY_TRACE_DIR);
assertEquals("trace message count", 3, client.messageCount);
List<OutputBundle> outputMessages = client.getOutputMessages();
OutputBundle lastBundle = outputMessages.get(outputMessages.size() - 1);
ValidationState finalReport = asValidationState(lastBundle.message);
try {
assertEquals("correct devices", 1, finalReport.summary.correct_devices.size());
assertEquals("extra devices", 0, finalReport.summary.extra_devices.size());
assertEquals("missing devices", 0, finalReport.summary.missing_devices.size());
assertEquals("error devices", 3, finalReport.summary.error_devices.size());
assertEquals("device summaries", 4, finalReport.devices.size());
assertEquals("AHU-1 status level", (Object) INFO.value(),
finalReport.devices.get("AHU-1").status.level);
assertEquals("AHU-22 status category", Category.VALIDATION_DEVICE_SCHEMA,
finalReport.devices.get("AHU-22").status.category);
assertEquals("SNS-4 status", Category.VALIDATION_DEVICE_MULTIPLE,
finalReport.devices.get("SNS-4").status.category);

List<ValidationEvents> deviceReports = reports(outputMessages, "AHU-1");

ValidationEvents firstReport = deviceReports.get(0);
assertEquals("missing points", 1, firstReport.pointset.missing.size());
String missingPointName = firstReport.pointset.missing.get(0);
assertEquals("missing point", FILTER_DIFFERENTIAL_PRESSURE_SETPOINT, missingPointName);
assertEquals("extra points", 0, firstReport.pointset.extra.size());
assertEquals("device status", (Integer) Level.ERROR.value(), firstReport.status.level);

ValidationEvents lastReport = deviceReports.get(deviceReports.size() - 1);
assertEquals("missing points", 0, lastReport.pointset.missing.size());
assertEquals("extra points", 0, lastReport.pointset.extra.size());
assertEquals("device status level", (Object) INFO.value(), lastReport.status.level);
} catch (Throwable e) {
outputMessages.forEach(message -> System.err.println(JsonUtil.stringify(message)));
throw e;
}
}

@Test
public void deviceArgs() {
MessageReadingClient client = validateTrace(SIMPLE_TRACE_DIR, TRACE_DEVICES);
Expand Down

0 comments on commit 2bf9375

Please sign in to comment.