Skip to content

Commit

Permalink
Adding device state change monitoring (#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
grafnu authored Dec 7, 2023
1 parent eba1e22 commit d207962
Show file tree
Hide file tree
Showing 33 changed files with 451 additions and 127 deletions.
6 changes: 3 additions & 3 deletions .gencode_hash.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cde866298a8a54168d3582b50ec93160209d07338d3d6c58d215855bc35cb158 gencode/docs/c
08583688b20f892c0b453f41787ac01a46ac601663736bcd6ed6f57be0758e79 gencode/docs/configuration_endpoint.html
6cf94d6cb600c75cde32a64bd78acb3ed3b54adfad08dbf6bb159b467e8925c9 gencode/docs/configuration_execution.html
6f8a3766b840e96881e3573d594e28864917efb288e068d6c82de55deb576694 gencode/docs/configuration_pod.html
fe6dabc7b6634449d457df758bcd441e7ecb87d8461c7e1ce26364f6b7f66f7f gencode/docs/configuration_pubber.html
dc77a21a05f9f98a23403a1db0c3b468ef50d028e4c4934734d08e15f36b1d57 gencode/docs/configuration_pubber.html
69bee6bfcd2f786d95cfd563ecb497296361c8945a1422385f78d25008f38ef1 gencode/docs/event.html
0a41807b999f80bd283fcee03e6df5845e13b122d9be7c7d4723b19a334b89d5 gencode/docs/event_discovery.html
79331072f185ca6e875b2e658e7e0dc471cd40be6b973ce9ee3f371aca474e9b gencode/docs/event_mapping.html
Expand Down Expand Up @@ -100,7 +100,7 @@ fc3a9415c04d8a06954dbdbfdff5d68ab113cce3948532c19df555778ffb04fa gencode/java/u
ca2e7566106818ca7e5190c8041eb86f0c9b3251b0bda8c3ea7ce11a0c891a0a gencode/java/udmi/schema/Position.java
3df66bb1a37a9e0b2b6cf392f8c64d404a73c83e5e13c02bb4844f09b9a04b70 gencode/java/udmi/schema/Properties.java
d5e11dc354995681b894bcb62e4e21da7f0be68aaa3643a3dc5aa13610741f29 gencode/java/udmi/schema/PubberConfiguration.java
2fa3172b3ee42593da30c45dd47eb586f962e5b667c98a08410b1d8b525f22b9 gencode/java/udmi/schema/PubberOptions.java
3bff2c98c8d41816b44c7623d542428a6378d3c7a4f9440ae35b395fb1f1e386 gencode/java/udmi/schema/PubberOptions.java
703ed0cecb60f284b52e76dc4d612eb798ba3e8781cc40698a46611b36e6b0c9 gencode/java/udmi/schema/SchemaValidationState.java
dc7c549b3358f9b2ceccc8633af3d0fca7eed7c05c94c3396815363b889b4c16 gencode/java/udmi/schema/SequenceValidationState.java
9da49b22341a65580d085fd9d00eaadcaefcf7b813988ef844c617aa4b8a9a4f gencode/java/udmi/schema/SetupUdmiConfig.java
Expand Down Expand Up @@ -183,7 +183,7 @@ b48ae013d203eb31cc388a084c0cc6f93d4d5534336d4da2ecbccd84a085ea2b gencode/python
5c50847e136a033ea511209238bb570499b43fbee6189dae06603132dcb9f01f gencode/python/udmi/schema/model_testing_target.py
7c9a755ae06c44fc2b8117d7918b6401ce08a7218b86033fb3320eda7286e581 gencode/python/udmi/schema/monitoring.py
3a3873c7db8d5fa13b43629031d36417a4ec4838d612a7b8c2fce7c22fdee009 gencode/python/udmi/schema/monitoring_metric.py
6dd7eb5e89d98715d7aa13d8e7362b2e1d821543a8b879a65e8fbf0abf4cc3de gencode/python/udmi/schema/options_pubber.py
743395d4b764d4fd2614aef85cab680498e5f2560767bc24f424d6594f14d75c gencode/python/udmi/schema/options_pubber.py
6c5f3dd1c5ca9d821e3c48298af118fc7eafd97af9265dfd34b2ed8642efca77 gencode/python/udmi/schema/persistent_device.py
a58f8c98e837a5b56126ca0f410e02f1e9cfcd80a8cb429e0ef522defab1f690 gencode/python/udmi/schema/properties.py
e604cf0280fe772de5f4e5ecf10dc6c564b6177eeff9cd9fb8b385af8fe10a95 gencode/python/udmi/schema/state.py
Expand Down
40 changes: 21 additions & 19 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: bin/run_tests all_tests
run: bin/run_tests all_tests
- name: all test output
if: ${{ always() }}
if: ${{ !cancelled() }}
run: more out/test_*

spelling:
Expand Down Expand Up @@ -154,33 +154,33 @@ jobs:
- name: registrar clean
run: bin/test_regclean $TARGET_PROJECT
- name: sequence tests clean
if: ${{ always() }}
if: ${{ !cancelled() }}
run: bin/test_sequencer clean nocheck $TARGET_PROJECT
- name: sequence tests alpha
if: ${{ always() }}
if: ${{ !cancelled() }}
run: bin/test_sequencer alpha nocheck $TARGET_PROJECT
- name: sequence test post-process
if: ${{ always() }}
if: ${{ !cancelled() }}
run: egrep ' test .* after .*s ' out/sequencer.log | tee out/timing_sequencer.out
- name: itemized sequencer tests
if: ${{ always() }}
if: ${{ !cancelled() }}
run: bin/test_itemized $TARGET_PROJECT
- name: output files
if: ${{ always() }}
if: ${{ !cancelled() }}
run: more out/*.out* | cat
- name: pubber logs
if: ${{ always() }}
if: ${{ !cancelled() }}
run: more out/pubber.log* pubber/out/*.json | cat
- name: itemized test post-process
if: ${{ always() }}
if: ${{ !cancelled() }}
run: egrep ' test .* after .*s ' out/sequencer.log-* | tee out/timing_itemized.out
- name: support bundle
if: ${{ always() }}
if: ${{ !cancelled() }}
run: |
bin/support ${{ github.repository_owner }}_${{ github.job }}_
tar -tzvf *udmi-support*.tgz
- uses: actions/upload-artifact@v3
if: ${{ always() }}
if: ${{ !cancelled() }}
with:
if-no-files-found: error
name: udmi-support_${{ github.run_id }}
Expand All @@ -206,23 +206,25 @@ jobs:
- name: registrar clean
run: bin/test_regclean solo $TARGET_PROJECT
- name: telemetry validator
if: ${{ !cancelled() }}
run: bin/test_validator $TARGET_PROJECT
- name: validator result
if: ${{ always() }}
if: ${{ !cancelled() }}
run: cat /tmp/validator.out || true
- name: message captures
if: ${{ always() }}
if: ${{ !cancelled() }}
run: |
cd sites/udmi_site_model/out
find . -type f | sort | xargs ls -l
find . -type f | sort | xargs more | cat
- name: nostate sequences
if: ${{ !cancelled() }}
run: bin/test_sequencer nostate full $TARGET_PROJECT
- name: support bundle
if: ${{ always() }}
if: ${{ !cancelled() }}
run: UDMI_REGISTRY_SUFFIX=_b bin/support ${{ github.repository_owner }}_${{ github.job }}_
- uses: actions/upload-artifact@v3
if: ${{ always() }}
if: ${{ !cancelled() }}
with:
if-no-files-found: error
name: udmi-support_${{ github.run_id }}
Expand Down Expand Up @@ -252,13 +254,13 @@ jobs:
- name: bin/test_redirect
run: bin/test_redirect $TARGET_PROJECT
- name: pubber.log
if: ${{ always() }}
if: ${{ !cancelled() }}
run: more out/pubber.log* | cat
- name: support bundle
if: ${{ always() }}
if: ${{ !cancelled() }}
run: UDMI_REGISTRY_SUFFIX=_r bin/support ${{ github.repository_owner }}_${{ github.job }}_
- uses: actions/upload-artifact@v3
if: ${{ always() }}
if: ${{ !cancelled() }}
with:
if-no-files-found: error
name: udmi-support_${{ github.run_id }}
Expand Down Expand Up @@ -289,8 +291,8 @@ jobs:
ls -d sites/udmi_site_model*/out*/devices/AHU-1/tests/*
find out* -name 'schema*.out*' -size +0 | xargs more | cat
- name: Sequencer validation
if: ${{ always() }}
if: ${{ !cancelled() }}
run: bin/test_sequcheck
- name: Itemized validation
if: ${{ always() }}
if: ${{ !cancelled() }}
run: bin/test_itemcheck
4 changes: 4 additions & 0 deletions bin/support
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ if [[ -n $UDMI_REGISTRY_SUFFIX && -n $site_model ]]; then
site_model=$site_model${UDMI_REGISTRY_SUFFIX}
fi

echo Lingering pubber processes:
ps ax | fgrep pubber | fgrep java || true
echo

echo tar --exclude-vcs -czf /tmp/$ARCHIVE $site_model $OUT_DIR
tar --exclude-vcs -czf /tmp/$ARCHIVE $site_model $OUT_DIR
mv /tmp/$ARCHIVE .
Expand Down
4 changes: 4 additions & 0 deletions bin/test_itemized
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ while read -u 7 action test_name pubber_opts; do
echo bin/sequencer $seq_opts $SITE_PATH $PROJECT_ID $DEVICE_ID $serial_no $test_name
bin/sequencer $seq_opts $SITE_PATH $PROJECT_ID $DEVICE_ID $serial_no $test_name

echo Cleaning up pubber processes...
(ps ax | fgrep pubber | fgrep java) || true
kill $(ps ax | fgrep pubber | fgrep java | awk '{print $1}') || true
sleep 2
! (ps ax | fgrep pubber | fgrep java) || fail Unexpected lingering pubber processes

egrep "(RESULT|CPBLTY) [a-z]+ [a-z.]+ $test_name[^ ]* " $SEQUENCER_OUT | while read result; do
echo $test_marker ${result/* NOTICE /} >> $RESULTS_OUT
Expand Down
7 changes: 5 additions & 2 deletions bin/test_sequcheck
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ diff -u out/schema.out $UDMI_ROOT/etc/schema${suffix}.out || failures+="schema "
cp $UDMI_ROOT/docs/specs/sequences/generated.md out/generated.tmp # Save for test/comparison
bin/gencode_seq || failures+="gencode "

echo Comparing diff out/generated.tmp docs/specs/sequences/generated.md
diff -u out/generated.tmp $UDMI_ROOT/docs/specs/sequences/generated.md || failures+="gencode_seq "
mv $UDMI_ROOT/docs/specs/sequences/generated.md out/generated.out
mv out/generated.tmp $UDMI_ROOT/docs/specs/sequences/generated.md

echo Comparing diff out/generated.out docs/specs/sequences/generated.md
diff -u out/generated.out $UDMI_ROOT/docs/specs/sequences/generated.md || failures+="gencode_seq "

SAMPLE_TEST_ROW="| system | system_min_loglevel | alpha | pass | Sequence complete |"
target=sites/udmi_site_model/out/devices/AHU-1/results.md
Expand Down
23 changes: 23 additions & 0 deletions common/src/main/java/com/google/udmi/util/DiffEntry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.google.udmi.util;

import static java.lang.String.format;

public record DiffEntry(DiffAction action, String key, String value) {
public enum DiffAction {
ADD("Add"),
SET("Set"),
REMOVE("Remove");

final String value;

DiffAction(String value) {
this.value = value;
}
}

@Override
public String toString() {
return action == DiffAction.REMOVE ? format("%s `%s`", action().value, key)
: format("%s `%s` = %s", action().value, key, value);
}
}
8 changes: 6 additions & 2 deletions common/src/main/java/com/google/udmi/util/GeneralUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public static String[] arrayOf(String... args) {
return args;
}

public static String changedLines(List<String> nullableChanges) {
List<String> changes = ofNullable(nullableChanges).orElse(ImmutableList.of());
public static String changedLines(List<DiffEntry> nullableChanges) {
List<DiffEntry> changes = ofNullable(nullableChanges).orElse(ImmutableList.of());
String terminator = changes.size() == 0 ? "." : ":";
String header = format("Changed %d fields%s%s", changes.size(), terminator, SEPARATOR);
return (header + INDENTED_LINES.join(changes)).trim();
Expand Down Expand Up @@ -288,6 +288,10 @@ public static <T> void ifTrueThen(Object conditional, Runnable action, Runnable
}
}

public static <T> T ifNotTrueGet(Object conditional, Supplier<T> supplier) {
return isTrue(conditional) ? null : supplier.get();
}

public static boolean isTrue(Object value) {
return Boolean.TRUE.equals(value);
}
Expand Down
4 changes: 3 additions & 1 deletion docs/specs/sequences/generated.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,6 @@ Check that a device publishes correct software information in state messages

Check that last_update state is correctly set in response to a config update.

1. Wait for state last_config matches config timestamp
1. Wait for state last_config matches first config timestamp
1. Force config update to trigger another config update
1. Wait for state last_config matches new config timestamp
18 changes: 9 additions & 9 deletions etc/schema.out
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
RESULT pass schemas event_pointset_alpha ALPHA 5/5 All schema validations passed
RESULT pass schemas event_pointset_beta BETA 5/5 All schema validations passed
RESULT pass schemas event_pointset_stable STABLE 5/5 All schema validations passed
RESULT pass schemas event_system_alpha ALPHA 5/5 All schema validations passed
RESULT pass schemas event_system_beta BETA 5/5 All schema validations passed
RESULT pass schemas event_system_stable STABLE 5/5 All schema validations passed
RESULT pass schemas state_update_alpha ALPHA 5/5 All schema validations passed
RESULT pass schemas state_update_beta BETA 5/5 All schema validations passed
RESULT pass schemas state_update_stable STABLE 5/5 All schema validations passed
RESULT pass schemas device_state_alpha ALPHA 5/5 Schema validation passed
RESULT pass schemas device_state_beta BETA 5/5 Schema validation passed
RESULT pass schemas device_state_stable STABLE 5/5 Schema validation passed
RESULT pass schemas event_pointset_beta BETA 5/5 Schema validation passed
RESULT pass schemas event_system_alpha ALPHA 5/5 Schema validation passed
RESULT pass schemas event_system_stable STABLE 5/5 Schema validation passed
RESULT pass schemas state_update_alpha ALPHA 5/5 Schema validation passed
RESULT pass schemas state_update_beta BETA 5/5 Schema validation passed
RESULT pass schemas state_update_stable STABLE 5/5 Schema validation passed
36 changes: 22 additions & 14 deletions etc/schema_itemized.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,37 @@
04 pointset_remove_point
05 too_much_state
06 feature_enumeration
07 valid_serial_no RESULT pass schemas event_pointset_alpha ALPHA 5/5 All schema validations passed
07 valid_serial_no RESULT pass schemas event_system_alpha ALPHA 5/5 All schema validations passed
07 valid_serial_no RESULT pass schemas state_update_alpha ALPHA 5/5 All schema validations passed
07 valid_serial_no RESULT pass schemas device_state_alpha ALPHA 5/5 Schema validation passed
07 valid_serial_no RESULT pass schemas event_system_alpha ALPHA 5/5 Schema validation passed
07 valid_serial_no RESULT pass schemas state_update_alpha ALPHA 5/5 Schema validation passed
08 writeback_success
09 writeback_success
10 pointset_sample_rate
11 system_mode_restart
12 config_logging
13 broken_config
14 broken_config
14 broken_config RESULT pass schemas device_state_alpha ALPHA 5/5 Schema validation passed
14 broken_config RESULT pass schemas event_system_alpha ALPHA 5/5 Schema validation passed
14 broken_config RESULT pass schemas state_update_alpha ALPHA 5/5 Schema validation passed
15 broken_config
16 broken_config
16 broken_config RESULT pass schemas device_state_alpha ALPHA 5/5 Schema validation passed
16 broken_config RESULT pass schemas event_system_alpha ALPHA 5/5 Schema validation passed
16 broken_config RESULT pass schemas state_update_alpha ALPHA 5/5 Schema validation passed
17 broken_config
18 system_last_update RESULT fail schemas event_pointset_stable STABLE 5/5 Schema violations found
18 system_last_update RESULT fail schemas state_update_stable STABLE 5/5 Schema violations found
18 system_last_update RESULT pass schemas event_system_stable STABLE 5/5 All schema validations passed
19 state_make_model
23 valid_serial_no
24 system_last_update
25 system_min_loglevel
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
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
30 gateway_proxy_events
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
35 gateway_proxy_events
32 gateway_proxy_events
36 gateway_proxy_events
40 device_config_acked
37 gateway_proxy_events
41 device_config_acked
5 changes: 3 additions & 2 deletions etc/schema_nostate.out
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
RESULT pass schemas event_pointset_beta BETA 5/5 All schema validations passed
RESULT pass schemas event_system_beta BETA 5/5 All schema validations passed
RESULT pass schemas device_state_beta BETA 5/5 Schema validation passed
RESULT pass schemas event_pointset_beta BETA 5/5 Schema validation passed
RESULT pass schemas event_system_beta BETA 5/5 Schema validation passed
2 changes: 1 addition & 1 deletion etc/sequencer_nostate.out
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ RESULT skip pointset pointset_request_extraneous BETA 0/0 State testing disabled
RESULT skip pointset pointset_sample_rate BETA 0/0 State testing disabled
RESULT skip system state_make_model BETA 0/0 State testing disabled
RESULT skip system state_software BETA 0/0 State testing disabled
RESULT fail system system_last_update STABLE 0/5 Timeout waiting for state last_config matches config timestamp
RESULT fail system system_last_update STABLE 0/5 Timeout waiting for state last_config matches first config timestamp
1 change: 1 addition & 0 deletions etc/test_itemized.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ TEST broken_config noState
TEST broken_config noLog
TEST broken_config badCategory
TEST system_last_update extraField=fnooz
TEST system_last_update dupeState
TEST state_make_model badState

# Test with various device metadata.json options
Expand Down
21 changes: 11 additions & 10 deletions etc/test_itemized.out
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
17 CPBLTY fail system broken_config.logging ALPHA 0/1 Timeout after 30s waiting for log category `system.config.receive` level `DEBUG` to be logged
17 RESULT fail system broken_config ALPHA 0/5 expected:<system.config.[parse]> but was:<system.config.[apply]>
18 RESULT pass system system_last_update STABLE 5/5 Sequence complete
19 RESULT fail system state_make_model BETA 0/5 Timeout waiting for no applicable system status
23 RESULT skip system valid_serial_no ALPHA 0/0 State testing disabled
24 RESULT fail system system_last_update STABLE 0/5 Timeout waiting for state last_config matches config timestamp
25 RESULT fail system system_min_loglevel ALPHA 0/5 Received state update with no-state device
26 RESULT pass system system_min_loglevel ALPHA 5/5 Sequence complete
30 RESULT pass gateway gateway_proxy_events ALPHA 5/5 Sequence complete
31 RESULT fail gateway gateway_proxy_events ALPHA 0/5 Timeout waiting for Missing data from AHU-22
35 RESULT pass gateway gateway_proxy_events ALPHA 5/5 Sequence complete
36 RESULT fail gateway gateway_proxy_events ALPHA 0/5 Received state update with no-state device
40 RESULT skip system device_config_acked BETA 0/0 No config check for proxy device
19 RESULT pass system system_last_update STABLE 5/5 Sequence complete
20 RESULT fail system state_make_model BETA 0/5 Timeout waiting for no applicable system status
24 RESULT skip system valid_serial_no ALPHA 0/0 State testing disabled
25 RESULT fail system system_last_update STABLE 0/5 Timeout waiting for state last_config matches first config timestamp
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 ALPHA 5/5 Sequence complete
32 RESULT fail gateway gateway_proxy_events ALPHA 0/5 Timeout waiting for Missing data from AHU-22
36 RESULT pass gateway gateway_proxy_events ALPHA 5/5 Sequence complete
37 RESULT fail gateway gateway_proxy_events ALPHA 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
Loading

0 comments on commit d207962

Please sign in to comment.