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

Adding alternate registry endpoint redirection test #542

Merged
merged 27 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
6 changes: 3 additions & 3 deletions .gencode_hash.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
b35646a2f3d7c30fd34e3ea6ab6a1070b39c469fd1de49cab1093ff32faaf06d gencode/docs/command_discovery.html
3e292717e9b220403c250eebcfb4132becb6f59546f0bd3c3ec3042c31986d48 gencode/docs/command_mapping.html
692ea694fbd8c88ebc1d7fed26363bd3e6b4e52061431a4d8c76bf0eddfaf2ff gencode/docs/config.html
d7a900e410265489c1527107d560b5e0cf19a220ee35abe1d61a698bcada5b4b gencode/docs/config.html
73b3beb740f5bc3ff26d173c356b2d3bf3b9892be83a704d3eeee7c9ff030230 gencode/docs/config_mapping.html
e6b9cc7798e71237416b092801356f51c5178f3aac35811a8cee8a0045ad96d8 gencode/docs/configuration_endpoint.html
b7ca70e3176f997f254c32bd8d53dff1462ac8a71c0e166aaa85193d67bff60b gencode/docs/configuration_execution.html
Expand Down Expand Up @@ -99,7 +99,7 @@ ceacfb4a1d0a4b4f4110b0e0717e57f2bbfd80ef18599d24fab19ddf497f399e gencode/java/u
64e5b9a2c5699a3ca3b13dc6cb0243ff5b4c90908a14e3f11c5298ae89c8b261 gencode/java/udmi/schema/SystemState.java
7d6dd13e368e7f073738fee69c15e18652a9b7d7ac63bde0a200f747e3aa1b1d gencode/java/udmi/schema/TargetTestingModel.java
d3968b92497e83a63f18cc0e74484a9807f1bb92db0c92d556ec2caaa143d645 gencode/java/udmi/schema/TestingModel.java
8a7dd590b84944de25392b1437184608edd2f8305a183eced8b1b40eae27c6d2 gencode/java/udmi/schema/TestingSystemConfig.java
7793d6d76a430dc7acf668d92d2df5f8e0625d6228207731f96e220f3b90e659 gencode/java/udmi/schema/TestingSystemConfig.java
ac6f8fd87c8986cce01e872460c15ff6fe71e3816f9bde610acfe25f7d38c8d4 gencode/java/udmi/schema/ValidationEvent.java
f7d117dc8b9764acf0c95a13a2bfdfbdf31d1a8ec83a707448aa4d7391ef07e2 gencode/java/udmi/schema/ValidationState.java
e007ddd1ceeae3603c85110c33e1bb4a418ff9c7a791ca0df25b7ea3caeafd36 gencode/java/udmi/schema/ValidationSummary.java
Expand All @@ -123,7 +123,7 @@ ac3facbd96f7cb2f7e387e7497d6a36af379a2687329571f250c5670f9933244 gencode/python
9eab64849e04b25203d5da47856c3f8dda2b96903e4dc43ab932ee35014700bd gencode/python/udmi/schema/config_pointset.py
33ce7ee99051d56dd3c4d69edf92583d0bb7fd751417948b71292ac2285d3c19 gencode/python/udmi/schema/config_pointset_point.py
ba37d2d54df565aba42ef055a0ec961175d180c2e8092a914e62029bc5388857 gencode/python/udmi/schema/config_system.py
97c2e5fadc6da0d84660f3296de885ab59f4b04154179b6717f77ec366f1544b gencode/python/udmi/schema/config_system_testing.py
cce623b34fd694880039a1c080214c33e00acaef5bc72276cf11a3bb2de40000 gencode/python/udmi/schema/config_system_testing.py
a1f527558554393623eb7f14a0ff6b3ce67e23578e2e716c206c6aa9a29ccee3 gencode/python/udmi/schema/configuration_endpoint.py
e8a1574074554b6144b178d2adedc76a1c7be5ae911b253deff4460d8d82c6ee gencode/python/udmi/schema/configuration_execution.py
7f4f8c1a6ead34bf72b9134b97a39001752eb0f9647fafaac82ced4bb2f46b88 gencode/python/udmi/schema/configuration_pubber.py
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ jobs:
env:
GCP_TARGET_PROJECT: ${{ secrets.GCP_TARGET_PROJECT }}
SEQUENCER_OPTS: ${{ secrets.SEQUENCER_OPTS }}
UDMI_ALT_REGISTRY: ${{ secrets.UDMI_ALT_REGISTRY }}
if: "${{ env.GCP_TARGET_PROJECT != '' }}"
run: |
bin/test_sequencer $GCP_TARGET_PROJECT
Expand Down
1 change: 1 addition & 0 deletions bin/sequencer
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ cat <<EOF > $VALIDATOR_CONFIG
"project_id": "$project_id",
"site_model": "$site_path",
"device_id": "$device_id",
"alt_registry": "$UDMI_ALT_REGISTRY",
"serial_no": "$serial_no",
"log_level": "$log_level",
"udmi_version": "$udmi_version",
Expand Down
2 changes: 2 additions & 0 deletions bin/test_sequencer
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ if [[ -n `which rot13` ]]; then
# Project is provided as a secret, so obfuscate to prevent redactions in server-side logs.
echo 'Using target project (rot13):' $(echo $project_id | rot13)
echo 'With SEQUENCER_OPTS (rot13):' $(echo $SEQUENCER_OPTS | rot13)
echo 'With UDMI_ALT_REGISTRY (rot13):' $(echo $UDMI_ALT_REGISTRY | rot13)
else
echo 'Using target project:' $project_id
echo 'With SEQUENCER_OPTS:' $SEQUENCER_OPTS
echo 'With UDMI_ALT_REGISTRY:' $UDMI_ALT_REGISTRY
fi

site_path=sites/udmi_site_model
Expand Down
49 changes: 41 additions & 8 deletions docs/specs/sequences/generated.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ Some caveats:
<!-- START GENERATED, do not edit anything after this line! -->
* [broken_config](#broken_config): Check that the device correctly handles a broken (non-json) config message.
* [device_config_acked](#device_config_acked): Check that the device MQTT-acknowledges a sent config.
* [endpoint_config_connection_error](#endpoint_config_connection_error): Push endpoint config message to device that results in a connection error.
* [endpoint_config_connection_success_reconnect](#endpoint_config_connection_success_reconnect): Push endpoint config message to device that results in successful reconnect to the same endpoint.
* [endpoint_connection_error](#endpoint_connection_error): Push endpoint config message to device that results in a connection error.
* [endpoint_connection_success_alternate](#endpoint_connection_success_alternate): Check connection to an alternate project.
* [endpoint_connection_success_reconnect](#endpoint_connection_success_reconnect): Check a successful reconnect to the same endpoint.
* [extra_config](#extra_config): Check that the device correctly handles an extra out-of-schema field
* [periodic_scan](#periodic_scan)
* [self_enumeration](#self_enumeration)
Expand Down Expand Up @@ -73,21 +74,53 @@ Check that the device MQTT-acknowledges a sent config.

1. Wait for config acked

## endpoint_config_connection_error
## endpoint_connection_error

Push endpoint config message to device that results in a connection error.

1. Update config before blobset entry config status is error:
* Add `blobset` = { "blobs": { "_iot_endpoint_config": { "phase": `final`, "content_type": `application/json`, "base64": `endpoint_base64_payload` } } }
* Add `blobset` = { "blobs": { "_iot_endpoint_config": { "phase": `final`, "content_type": `application/json`, "base64": `endpoint_base64_payload`, "nonce": `endpoint_nonce` } } }
1. Wait for blobset entry config status is error
1. Update config before endpoint config blobset state not defined:
* Remove `blobset.blobs._iot_endpoint_config`
1. Wait for endpoint config blobset state not defined

## endpoint_config_connection_success_reconnect
## endpoint_connection_success_alternate

Push endpoint config message to device that results in successful reconnect to the same endpoint.
Check connection to an alternate project.

1. Update config before blobset phase is FINAL and stateStatus is null:
1. Wait for initial last_config matches config timestamp
1. Update config before blobset phase is apply and stateStatus is null:
* Add `blobset` = { "blobs": { "_iot_endpoint_config": { "phase": `final`, "content_type": `application/json`, "base64": `endpoint_base64_payload`, "nonce": `endpoint_nonce` } } }
1. Wait for blobset phase is apply and stateStatus is null
1. Update config before blobset phase is final and stateStatus is null:
* Add `system.testing.endpoint_type` = `alternate`
1. Wait for blobset phase is final and stateStatus is null
1. Wait for alternate last_config matches config timestamp
1. Update config before endpoint config blobset state not defined:
* Remove `blobset.blobs._iot_endpoint_config`
1. Wait for endpoint config blobset state not defined
1. Update config before blobset phase is apply and stateStatus is null:
* Add `blobset.blobs._iot_endpoint_config` = { "phase": `final`, "content_type": `application/json`, "base64": `endpoint_base64_payload`, "nonce": `endpoint_nonce` }
1. Wait for blobset phase is apply and stateStatus is null
1. Update config before blobset phase is final and stateStatus is null:
* Remove `system.testing.endpoint_type`
1. Wait for blobset phase is final and stateStatus is null
1. Wait for restored last_config matches config timestamp
1. Update config before endpoint config blobset state not defined:
* Remove `blobset.blobs._iot_endpoint_config`
1. Wait for endpoint config blobset state not defined

## endpoint_connection_success_reconnect

Check a successful reconnect to the same endpoint.

1. Update config before blobset phase is final and stateStatus is null:
* Add `blobset` = { "blobs": { "_iot_endpoint_config": { "phase": `final`, "content_type": `application/json`, "base64": `endpoint_base64_payload`, "nonce": `endpoint_nonce` } } }
1. Wait for blobset phase is FINAL and stateStatus is null
1. Wait for blobset phase is final and stateStatus is null
1. Update config before endpoint config blobset state not defined:
* Remove `blobset.blobs._iot_endpoint_config`
1. Wait for endpoint config blobset state not defined

## extra_config

Expand Down
5 changes: 3 additions & 2 deletions etc/sequencer.out
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
RESULT pass broken_config Sequence complete
RESULT pass device_config_acked Sequence complete
RESULT pass endpoint_config_connection_error Sequence complete
RESULT pass endpoint_config_connection_success_reconnect Sequence complete
RESULT pass endpoint_connection_error Sequence complete
RESULT pass endpoint_connection_success_alternate Sequence complete
RESULT pass endpoint_connection_success_reconnect Sequence complete
RESULT pass extra_config Sequence complete
RESULT pass periodic_scan Sequence complete
RESULT pass self_enumeration Sequence complete
Expand Down
48 changes: 48 additions & 0 deletions gencode/docs/config.html

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

13 changes: 11 additions & 2 deletions gencode/java/udmi/schema/TestingSystemConfig.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/config_system_testing.py

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

4 changes: 4 additions & 0 deletions schema/config_system_testing.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"sequence_name": {
"description": "The sequence name currently being tested (for debug logging)",
"type": "string"
},
"endpoint_type": {
"description": "Designator for the kind of endpoint being used for this test",
"type": "string"
}
}
}
8 changes: 8 additions & 0 deletions validator/sequences/endpoint_connection_error/sequence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

## endpoint_connection_error

Push endpoint config message to device that results in a connection error.

1. Update config before blobset entry config status is error:
* Add `blobset` = { "blobs": { "_iot_endpoint_config": { "phase": `final`, "content_type": `application/json`, "base64": `endpoint_base64_payload`, "nonce": `endpoint_nonce` } } }
1. Wait for blobset entry config status is error
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

## endpoint_connection_success_alternate

Check connection to an alternate project.

1. Wait for initial last_config matches config timestamp
1. Update config before blobset phase is apply and stateStatus is null:
* Add `blobset` = { "blobs": { "_iot_endpoint_config": { "phase": `final`, "content_type": `application/json`, "base64": `endpoint_base64_payload`, "nonce": `endpoint_nonce` } } }
1. Wait for blobset phase is apply and stateStatus is null
1. Update config before blobset phase is final and stateStatus is null:
* Add `system.testing.endpoint_type` = `alternate`
1. Wait for blobset phase is final and stateStatus is null
1. Wait for alternate last_config matches config timestamp
1. Update config before endpoint config blobset state not defined:
* Remove `blobset.blobs._iot_endpoint_config`
1. Wait for endpoint config blobset state not defined
1. Update config before blobset phase is apply and stateStatus is null:
* Add `blobset.blobs._iot_endpoint_config` = { "phase": `final`, "content_type": `application/json`, "base64": `endpoint_base64_payload`, "nonce": `endpoint_nonce` }
1. Wait for blobset phase is apply and stateStatus is null
1. Update config before blobset phase is final and stateStatus is null:
* Remove `system.testing.endpoint_type`
1. Wait for blobset phase is final and stateStatus is null
1. Wait for restored last_config matches config timestamp
1. Update config before endpoint config blobset state not defined:
* Remove `blobset.blobs._iot_endpoint_config`
1. Wait for endpoint config blobset state not defined
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

## endpoint_connection_success_reconnect

Check a successful reconnect to the same endpoint.

1. Update config before blobset phase is final and stateStatus is null:
* Add `blobset` = { "blobs": { "_iot_endpoint_config": { "phase": `final`, "content_type": `application/json`, "base64": `endpoint_base64_payload`, "nonce": `endpoint_nonce` } } }
1. Wait for blobset phase is final and stateStatus is null
1. Update config before endpoint config blobset state not defined:
* Remove `blobset.blobs._iot_endpoint_config`
1. Wait for endpoint config blobset state not defined
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class IotReflectorClient implements MessagePublisher {

private final MqttPublisher mqttPublisher;
private final String subscriptionId;
private final String siteName;
private final String registryId;
private final String projectId;
private boolean active;

Expand All @@ -62,7 +62,7 @@ public IotReflectorClient(ExecutionConfiguration iotConfig) {
e);
}

siteName = iotConfig.registry_id;
registryId = iotConfig.registry_id;
projectId = iotConfig.project_id;
String cloudRegion =
iotConfig.reflect_region == null ? iotConfig.cloud_region : iotConfig.reflect_region;
Expand All @@ -72,7 +72,7 @@ public IotReflectorClient(ExecutionConfiguration iotConfig) {

try {
mqttPublisher = new MqttPublisher(projectId, cloudRegion, UDMS_REFLECT,
siteName, keyBytes, IOT_KEY_ALGORITHM, this::messageHandler, this::errorHandler);
registryId, keyBytes, IOT_KEY_ALGORITHM, this::messageHandler, this::errorHandler);
} catch (Exception e) {
throw new RuntimeException("While connecting MQTT endpoint " + subscriptionId, e);
}
Expand Down Expand Up @@ -115,10 +115,10 @@ private void messageHandler(String topic, String payload) {
private String parseMessageTopic(String topic, Map<String, String> attributes) {
String[] parts = topic.substring(1).split("/");
assert "devices".equals(parts[0]);
assert siteName.equals(parts[1]);
assert registryId.equals(parts[1]);
String messageCategory = parts[2];
attributes.put("category", messageCategory);
attributes.put("deviceRegistryId", siteName);
attributes.put("deviceRegistryId", registryId);
if (messageCategory.equals("commands")) {
assert "devices".equals(parts[3]);
attributes.put("deviceId", parts[4]);
Expand Down Expand Up @@ -169,7 +169,7 @@ public Validator.MessageBundle takeNextMessage() {
@Override
public void publish(String deviceId, String topic, String data) {
String reflectorTopic = String.format("events/devices/%s/%s", deviceId, topic);
mqttPublisher.publish(siteName, reflectorTopic, data);
mqttPublisher.publish(registryId, reflectorTopic, data);
}

@Override
Expand All @@ -179,7 +179,7 @@ public void close() {
}

public void setReflectorState(String stateData) {
mqttPublisher.publish(siteName, "state", stateData);
mqttPublisher.publish(registryId, "state", stateData);
}

static class MessageBundle {
Expand Down
Loading