Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Augment existing writeback tests for correct no-writeback point status #847

Merged
merged 3 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 28 additions & 27 deletions etc/schema_itemized.out
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,34 @@
07 valid_serial_no RESULT pass schemas state_update_beta BETA 5/5 Schema validation passed
08 writeback_success
09 writeback_success
10 pointset_publish_interval
11 system_mode_restart
12 config_logging
13 broken_config
14 broken_config RESULT pass schemas device_state_beta BETA 5/5 Schema validation passed
14 broken_config RESULT pass schemas event_system_beta BETA 5/5 Schema validation passed
14 broken_config RESULT pass schemas state_update_beta BETA 5/5 Schema validation passed
15 broken_config
16 broken_config RESULT pass schemas device_state_beta BETA 5/5 Schema validation passed
16 broken_config RESULT pass schemas event_system_beta BETA 5/5 Schema validation passed
16 broken_config RESULT pass schemas state_update_beta BETA 5/5 Schema validation passed
17 broken_config
18 system_last_update RESULT fail schemas state_update_stable STABLE 5/5 Schema violations found
18 system_last_update RESULT pass schemas device_state_stable STABLE 5/5 Schema validation passed
18 system_last_update RESULT pass schemas event_system_stable STABLE 5/5 Schema validation passed
19 system_last_update RESULT fail schemas device_state_stable STABLE 5/5 Schema violations found
10 writeback_success
11 pointset_publish_interval
12 system_mode_restart
13 config_logging
14 broken_config
15 broken_config RESULT pass schemas device_state_beta BETA 5/5 Schema validation passed
15 broken_config RESULT pass schemas event_system_beta BETA 5/5 Schema validation passed
15 broken_config RESULT pass schemas state_update_beta BETA 5/5 Schema validation passed
16 broken_config
17 broken_config RESULT pass schemas device_state_beta BETA 5/5 Schema validation passed
17 broken_config RESULT pass schemas event_system_beta BETA 5/5 Schema validation passed
17 broken_config RESULT pass schemas state_update_beta BETA 5/5 Schema validation passed
18 broken_config
19 system_last_update RESULT fail schemas state_update_stable STABLE 5/5 Schema violations found
19 system_last_update RESULT pass schemas device_state_stable STABLE 5/5 Schema validation passed
19 system_last_update RESULT pass schemas event_system_stable STABLE 5/5 Schema validation passed
19 system_last_update RESULT pass schemas state_update_stable STABLE 5/5 Schema validation passed
20 state_make_model
24 valid_serial_no
25 system_last_update
26 system_min_loglevel
27 system_min_loglevel RESULT pass schemas device_state_alpha ALPHA 5/5 Schema validation passed
27 system_min_loglevel RESULT pass schemas event_system_alpha ALPHA 5/5 Schema validation passed
31 gateway_proxy_events
20 system_last_update RESULT fail schemas device_state_stable STABLE 5/5 Schema violations found
20 system_last_update RESULT pass schemas event_system_stable STABLE 5/5 Schema validation passed
20 system_last_update RESULT pass schemas state_update_stable STABLE 5/5 Schema validation passed
21 state_make_model
25 valid_serial_no
26 system_last_update
27 system_min_loglevel
28 system_min_loglevel RESULT pass schemas device_state_alpha ALPHA 5/5 Schema validation passed
28 system_min_loglevel RESULT pass schemas event_system_alpha ALPHA 5/5 Schema validation passed
32 gateway_proxy_events
36 gateway_proxy_events
33 gateway_proxy_events
37 gateway_proxy_events
41 device_config_acked
42 bad_target_family
38 gateway_proxy_events
42 device_config_acked
43 bad_target_family
1 change: 1 addition & 0 deletions etc/test_itemized.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ TEST pointset_remove_point noState
TEST too_much_state spamState
TEST feature_enumeration featureEnableSwap
TEST valid_serial_no noLastStart
TEST writeback_success extraPoint=filter_differential_pressure_setpoint
TEST writeback_success noWriteback
TEST writeback_success noPointState
TEST pointset_publish_interval fixedSampleRate=10
Expand Down
55 changes: 28 additions & 27 deletions etc/test_itemized.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,35 @@
05 RESULT fail system too_much_state ALPHA 0/5 Failed check that No more than 6 state updates in 60s
06 RESULT fail enumeration.features feature_enumeration PREVIEW 0/5 Failed check that feature enumeration matches metadata; missing { enumeration }, extra { unknown }
07 RESULT pass system valid_serial_no BETA 5/5 Sequence complete
08 RESULT fail writeback writeback_success ALPHA 0/5 Because point filter_differential_pressure_setpoint is null, expected applied
08 RESULT fail writeback writeback_success ALPHA 0/5 Because point filter_differential_pressure_setpoint is applied, expected null
09 RESULT fail writeback writeback_success ALPHA 0/5 Because point filter_differential_pressure_setpoint is null, expected applied
10 RESULT fail pointset pointset_publish_interval BETA 0/5 Failed check that time period between successive pointset events is between 5 and 8 seconds
11 RESULT fail system.mode system_mode_restart ALPHA 0/5 Failed check that restart count increased by one
12 RESULT fail system config_logging BETA 0/5 Bad message version string 1.4.
13 CPBLTY pass system broken_config.logging ALPHA 1/1 Capability supported
13 RESULT fail system broken_config BETA 0/5 Because no status to report
10 RESULT fail writeback writeback_success ALPHA 0/5 Because point filter_differential_pressure_setpoint is null, expected applied
11 RESULT fail pointset pointset_publish_interval BETA 0/5 Failed check that time period between successive pointset events is between 5 and 8 seconds
12 RESULT fail system.mode system_mode_restart ALPHA 0/5 Failed check that restart count increased by one
13 RESULT fail system config_logging BETA 0/5 Bad message version string 1.4.
14 CPBLTY pass system broken_config.logging ALPHA 1/1 Capability supported
14 RESULT pass system broken_config BETA 5/5 Sequence complete
15 CPBLTY skip system broken_config.logging ALPHA 0/0 Never executed
15 RESULT fail system broken_config BETA 0/4 Timeout waiting for initial device state
16 CPBLTY fail system broken_config.logging ALPHA 0/1 While log category `system.config.apply` level `NOTICE` to be logged
16 RESULT pass system broken_config BETA 4/5 Sequence complete
17 CPBLTY fail system broken_config.logging ALPHA 0/1 While log category `system.config.receive` level `DEBUG` to be logged
17 RESULT fail system broken_config BETA 0/5 expected:<system.config.[parse]> but was:<system.config.[apply]>
18 CPBLTY pass system system_last_update.subblocks ALPHA 1/1 Capability supported
18 RESULT pass system system_last_update STABLE 6/6 Sequence complete
14 RESULT fail system broken_config BETA 0/5 Because no status to report
15 CPBLTY pass system broken_config.logging ALPHA 1/1 Capability supported
15 RESULT pass system broken_config BETA 5/5 Sequence complete
16 CPBLTY skip system broken_config.logging ALPHA 0/0 Never executed
16 RESULT fail system broken_config BETA 0/4 Timeout waiting for initial device state
17 CPBLTY fail system broken_config.logging ALPHA 0/1 While log category `system.config.apply` level `NOTICE` to be logged
17 RESULT pass system broken_config BETA 4/5 Sequence complete
18 CPBLTY fail system broken_config.logging ALPHA 0/1 While log category `system.config.receive` level `DEBUG` to be logged
18 RESULT fail system broken_config BETA 0/5 expected:<system.config.[parse]> but was:<system.config.[apply]>
19 CPBLTY pass system system_last_update.subblocks ALPHA 1/1 Capability supported
19 RESULT pass system system_last_update STABLE 6/6 Sequence complete
20 RESULT fail system state_make_model BETA 0/5 Failed check that no significant system status exists; deviceState.system not defined
24 RESULT skip system valid_serial_no BETA 0/0 State testing disabled
25 CPBLTY skip system system_last_update.subblocks ALPHA 0/0 Never executed
25 RESULT skip system system_last_update STABLE 0/0 State testing disabled
26 RESULT fail system system_min_loglevel ALPHA 0/5 Received state update with no-state device
27 RESULT pass system system_min_loglevel ALPHA 5/5 Sequence complete
31 RESULT pass gateway gateway_proxy_events BETA 5/5 Sequence complete
32 RESULT fail gateway gateway_proxy_events BETA 0/5 Timeout waiting for Missing data from AHU-22
36 RESULT pass gateway gateway_proxy_events BETA 5/5 Sequence complete
37 RESULT fail gateway gateway_proxy_events BETA 0/5 Received state update with no-state device
41 RESULT skip system device_config_acked BETA 0/0 No config check for proxy device
42 RESULT pass gateway bad_target_family PREVIEW 5/5 Sequence complete
20 CPBLTY pass system system_last_update.subblocks ALPHA 1/1 Capability supported
20 RESULT pass system system_last_update STABLE 6/6 Sequence complete
21 RESULT fail system state_make_model BETA 0/5 Failed check that no significant system status exists; deviceState.system not defined
25 RESULT skip system valid_serial_no BETA 0/0 State testing disabled
26 CPBLTY skip system system_last_update.subblocks ALPHA 0/0 Never executed
26 RESULT skip system system_last_update STABLE 0/0 State testing disabled
27 RESULT fail system system_min_loglevel ALPHA 0/5 Received state update with no-state device
28 RESULT pass system system_min_loglevel ALPHA 5/5 Sequence complete
32 RESULT pass gateway gateway_proxy_events BETA 5/5 Sequence complete
33 RESULT fail gateway gateway_proxy_events BETA 0/5 Timeout waiting for Missing data from AHU-22
37 RESULT pass gateway gateway_proxy_events BETA 5/5 Sequence complete
38 RESULT fail gateway gateway_proxy_events BETA 0/5 Received state update with no-state device
42 RESULT skip system device_config_acked BETA 0/0 No config check for proxy device
43 RESULT pass gateway bad_target_family PREVIEW 5/5 Sequence complete
14 changes: 12 additions & 2 deletions pubber/src/main/java/daq/pubber/PointsetManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import static com.google.udmi.util.GeneralUtils.ifNotTrueThen;
import static com.google.udmi.util.GeneralUtils.ifNullThen;
import static com.google.udmi.util.GeneralUtils.ifTrueGet;
import static com.google.udmi.util.GeneralUtils.ifTrueThen;
import static java.lang.String.format;
import static java.util.Objects.requireNonNull;
import static java.util.Objects.requireNonNullElseGet;
Expand All @@ -28,6 +29,7 @@
import udmi.schema.PointPointsetEvent;
import udmi.schema.PointPointsetModel;
import udmi.schema.PointPointsetState;
import udmi.schema.PointPointsetState.Value_state;
import udmi.schema.PointsetConfig;
import udmi.schema.PointsetEvent;
import udmi.schema.PointsetModel;
Expand Down Expand Up @@ -139,11 +141,19 @@ private void restorePoint(String pointName) {
}

pointsetState.points.put(pointName, ifNotNullGet(managedPoints.get(pointName),
AbstractPoint::getState, invalidPoint(pointName)));
this::getTweakedPointState, invalidPoint(pointName)));
pointsetEvent.points.put(pointName, ifNotNullGet(managedPoints.get(pointName),
AbstractPoint::getData, new PointPointsetEvent()));
}

private PointPointsetState getTweakedPointState(AbstractPoint point) {
PointPointsetState state = point.getState();
// Tweak for testing: erroneously apply an applied state here.
ifTrueThen(point.getName().equals(options.extraPoint),
() -> state.value_state = ofNullable(state.value_state).orElse(Value_state.APPLIED));
return state;
}

private void suspendPoint(String pointName) {
pointsetState.points.remove(pointName);
pointsetEvent.points.remove(pointName);
Expand Down Expand Up @@ -172,7 +182,7 @@ private void updateState(AbstractPoint point) {
}

if (point.isDirty()) {
PointPointsetState state = point.getState(); // Always call to clear the dirty bit
PointPointsetState state = getTweakedPointState(point); // Always call to clear the dirty bit
PointPointsetState useState = ifTrueGet(options.noPointState, PointPointsetState::new, state);
pointsetState.points.put(pointName, useState);
updateState();
Expand Down
Loading