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

Fix testing pipeline for cases with bad device state #773

Merged
merged 16 commits into from
Nov 23, 2023
Merged
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 @@ d40bfc9f4a30c56986435dc08f1e5f42401e5ac043359a1e359011c913cad673 gencode/docs/c
08583688b20f892c0b453f41787ac01a46ac601663736bcd6ed6f57be0758e79 gencode/docs/configuration_endpoint.html
6cf94d6cb600c75cde32a64bd78acb3ed3b54adfad08dbf6bb159b467e8925c9 gencode/docs/configuration_execution.html
d0f6ea11943f46c955891b3b49a25a9bffcf558fcabb9ed2b0f7667d8413953b gencode/docs/configuration_pod.html
1fbd42e4591a609d7f8869c6d1942477d96221ee01ee9bf4aae0bc23d570f301 gencode/docs/configuration_pubber.html
61c9af0f2000f541a43e0e663fc4b370051aa720f619fe9c1ff5d9bf7cf04bf7 gencode/docs/configuration_pubber.html
96186777da06f95eae1d16d73555445d23608a9301636ea1ccd17922b3fe4019 gencode/docs/event.html
587e048c161273b927de67b899204bf0e183db64e59ae513f833e5eff406b1ab gencode/docs/event_discovery.html
0f99534574718e07e655e33e76e06b56e6a96a7a42ae1457dc97dabc581d848f gencode/docs/event_mapping.html
Expand Down Expand Up @@ -99,7 +99,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
87fd10ad778d7d2c1d800343de76430f80ea7701ffb60859bd4a6102fae3d243 gencode/java/udmi/schema/PubberOptions.java
33ea843f84b9fe9c097956035df45d08fe6a8379aac06e6935525100da2e55dd gencode/java/udmi/schema/PubberOptions.java
703ed0cecb60f284b52e76dc4d612eb798ba3e8781cc40698a46611b36e6b0c9 gencode/java/udmi/schema/SchemaValidationState.java
6da1708f597a0c64ce30dcbe739095fc7ebc091d63b98af88c73f70706af31ca gencode/java/udmi/schema/SequenceValidationState.java
9da49b22341a65580d085fd9d00eaadcaefcf7b813988ef844c617aa4b8a9a4f gencode/java/udmi/schema/SetupUdmiConfig.java
Expand Down Expand Up @@ -182,7 +182,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
07ffd16404e2788249448da9fda6572b6930c5241441dedcc803fab5bf236a10 gencode/python/udmi/schema/options_pubber.py
64de889b73e6d7704907796aae4246a0e3650ff0dae6b43c0e35a71df732a9f3 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
4 changes: 3 additions & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jobs:
name: Sequencer Tests
runs-on: ubuntu-latest
needs: pretest
timeout-minutes: 15
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -286,6 +286,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() }}
run: bin/test_sequcheck
- name: Itemized validation
if: ${{ always() }}
run: bin/test_itemcheck
3 changes: 3 additions & 0 deletions bin/test_itemized
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ while read -u 7 action test_name pubber_opts; do

done 7< $INPUT_FILE

sed -E -i $RESULTS_OUT \
-e 's/(Pipeline type event error: While processing message ).*/\1REDACTED/'

if [[ -z $TARGET_TEST && -z $MATRIX_SHARD_COUNT ]]; then
bin/test_itemcheck
else
Expand Down
1 change: 1 addition & 0 deletions etc/schema_itemized.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ gateway_proxy_events
pointset_remove_point
pointset_request_extraneous
pointset_sample_rate
state_make_model
system_last_update
system_last_update RESULT fail schemas event_pointset_stable STABLE 5 Schema violations found
system_last_update RESULT pass schemas event_system_stable STABLE 5 All schema validations passed
Expand Down
6 changes: 6 additions & 0 deletions etc/test_itemized.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ TEST broken_config configStateDelay
TEST broken_config noState
TEST broken_config badCategory
TEST system_last_update extraField=fnooz
TEST state_make_model badState

# Test with various device metadata.json options
WITH AHU-1 noState
Expand All @@ -27,6 +28,11 @@ WITH GAT-123
TEST gateway_proxy_events
TEST gateway_proxy_events noProxy

# Test gateway configurations that doesn't do state
WITH GAT-123 noState
TEST gateway_proxy_events noState
TEST gateway_proxy_events badState

# Test proxy device configurations
WITH AHU-22
TEST device_config_acked
5 changes: 4 additions & 1 deletion etc/test_itemized.out
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ RESULT skip system device_config_acked BETA 5 No config check for proxy device
RESULT fail system device_config_acked BETA 5 timeout waiting for config acked
RESULT fail enumeration.features feature_enumeration PREVIEW 5 Failed check that feature enumeration matches metadata; missing { enumeration }, extra { unknown }
RESULT pass gateway gateway_proxy_events ALPHA 5 Sequence complete
RESULT pass gateway gateway_proxy_events ALPHA 5 Sequence complete
RESULT pass gateway gateway_proxy_events ALPHA 5 Sequence complete
RESULT fail gateway gateway_proxy_events ALPHA 5 timeout waiting for Missing data from AHU-22
RESULT fail pointset pointset_remove_point BETA 5 timeout waiting for no applicable system status
RESULT fail pointset pointset_remove_point BETA 5 timeout waiting for pointset state reports same points as defined in config
RESULT fail pointset pointset_remove_point BETA 5 timeout waiting for pointset status does not contain removed point
RESULT fail pointset pointset_request_extraneous BETA 5 timeout waiting for pointset event contains correct points with present_value
RESULT fail pointset pointset_sample_rate BETA 5 Failed check that time period between successive pointset events is between 1 and 5 seconds
RESULT fail system state_make_model BETA 5 Pipeline type event error: While processing message REDACTED
RESULT pass system system_last_update STABLE 5 Sequence complete
RESULT fail system system_last_update STABLE 5 timeout waiting for state last_config matches config timestamp
RESULT fail system system_min_loglevel ALPHA 5 Received state update with no-state device
Expand Down
40 changes: 40 additions & 0 deletions gencode/docs/configuration_pubber.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion gencode/java/udmi/schema/PubberOptions.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions gencode/python/udmi/schema/options_pubber.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pubber/src/main/java/daq/pubber/MqttPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private void publishCore(String deviceId, String topicSuffix, Object data, Runna
}
} catch (Exception e) {
errorCounter.incrementAndGet();
warn(format("Publish failed for %s: %s", deviceId, e));
warn(format("Publish %s failed for %s: %s", topicSuffix, deviceId, e));
if (getGatewayId(deviceId) == null) {
closeMqttClient(deviceId);
if (mqttClients.isEmpty()) {
Expand Down Expand Up @@ -640,8 +640,8 @@ private class MqttCallbackHandler implements MqttCallback {
public void connectionLost(Throwable cause) {
boolean connected = cleanClients(deviceId).isConnected();
warn("MQTT Connection Lost: " + connected + cause);
onError.accept(new ConnectionClosedException());
close();
onError.accept(new ConnectionClosedException());
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion pubber/src/main/java/daq/pubber/Pubber.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public class Pubber extends ManagerBase implements ManagerHost {
private static final ImmutableMap<Class<?>, String> MESSAGE_TOPIC_SUFFIX_MAP =
new ImmutableMap.Builder<Class<?>, String>()
.put(State.class, MqttDevice.STATE_TOPIC)
.put(SystemState.class, MqttDevice.STATE_TOPIC) // Used for badState option
.put(SystemEvent.class, getEventsSuffix("system"))
.put(PointsetEvent.class, getEventsSuffix("pointset"))
.put(ExtraPointsetEvent.class, getEventsSuffix("pointset"))
Expand Down Expand Up @@ -1407,7 +1408,7 @@ private void publishStateMessage() {
deviceState.timestamp = getNow();
info(format("Update state %s last_config %s", isoConvert(deviceState.timestamp),
isoConvert(deviceState.system.last_config)));
publishStateMessage(deviceState);
publishStateMessage(isTrue(options.badState) ? deviceState.system : deviceState);
}

private void publishStateMessage(Object stateToSend) {
Expand Down
3 changes: 3 additions & 0 deletions schema/options_pubber.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
"noState": {
"type": "boolean"
},
"badState": {
"type": "boolean"
},
"featureEnableSwap": {
"type": "boolean"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig;
import com.clearblade.cloud.iot.v1.devicetypes.DeviceCredential;
import com.clearblade.cloud.iot.v1.devicetypes.DeviceName;
import com.clearblade.cloud.iot.v1.devicetypes.DeviceState;
import com.clearblade.cloud.iot.v1.devicetypes.FieldMask;
import com.clearblade.cloud.iot.v1.devicetypes.GatewayAuthMethod;
import com.clearblade.cloud.iot.v1.devicetypes.GatewayConfig;
Expand Down Expand Up @@ -628,8 +629,8 @@ public String fetchState(String deviceRegistryId, String deviceId) {
.setNumStates(1).build();
ListDeviceStatesResponse response = requireNonNull(
deviceManagerClient.listDeviceStates(request), "Null response returned");
String state = (String) response.getDeviceStatesList().get(0).getBinaryData();
return state;
List<DeviceState> deviceStatesList = response.getDeviceStatesList();
return deviceStatesList.isEmpty() ? null : (String) deviceStatesList.get(0).getBinaryData();
} catch (Exception e) {
throw new RuntimeException("While fetching state for device " + devicePath, e);
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading