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

Don't block registar devices, and refactor a bit to enable Registrar unit testing #451

Merged
merged 126 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from 122 commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
fe1150a
Examples for discovery
grafnu Apr 7, 2022
452ac6d
Reverting some changes
grafnu Apr 7, 2022
453373a
Cleanup
grafnu Apr 7, 2022
8b06ded
Reconciling examples
grafnu Apr 8, 2022
70cf462
Merge branch 'master' into examples
grafnu Apr 8, 2022
ad88b07
Docs tweaks
grafnu Apr 8, 2022
a822c5f
Updating docs
grafnu Apr 8, 2022
3beb3ed
REmoving provisioning example
grafnu Apr 8, 2022
0e3c0e0
Adding mapping_format
grafnu Apr 8, 2022
9dce1fa
Adding guid
grafnu Apr 9, 2022
35aa164
Updating examples
grafnu Apr 11, 2022
7d58c8e
Adding staged eqip.txt
grafnu Apr 11, 2022
400d7fd
Updating staged_equp_repsonse
grafnu Apr 12, 2022
b22ff27
Clean up validator
grafnu Apr 13, 2022
deaad1f
Merge branch 'master' into mapping
grafnu Apr 13, 2022
fa9797a
Merge branch 'master' into iotschema
grafnu Apr 22, 2022
41fc033
Merge branch 'master' into mapping
grafnu Apr 22, 2022
80b4230
Merge branch 'master' into iotschema
grafnu Jun 3, 2022
88a5e1f
Merge branch 'master' into mapping
grafnu Jun 3, 2022
e6d8c18
Merge branch 'master' into mapping
grafnu Jun 9, 2022
754a17b
Merge branch 'master' into mapping
grafnu Jun 17, 2022
ba037a8
Adjusting schema locations
grafnu Jun 17, 2022
a3ed46b
Update and rename
grafnu Jun 17, 2022
2940a2e
Docs tweaks
grafnu Jun 17, 2022
b556798
Merge branch 'master' into iotschema
grafnu Jun 17, 2022
e2f4ad3
Merge branch 'master' into iotschema
grafnu Jun 21, 2022
302e517
Merge branch 'master' into mapping
grafnu Jun 24, 2022
4661000
Merge branch 'master' into iotschema
grafnu Jun 24, 2022
28664a4
Merge branch 'master' into iotschema
grafnu Jun 25, 2022
92cd22e
Merge branch 'master' into mapping
grafnu Jun 25, 2022
e036d00
Merge remote-tracking branch 'faucet/master' into mapping
grafnu Jun 27, 2022
10241d2
Merge branch 'master' into mapping
grafnu Jul 16, 2022
9022b94
Merge branch 'master' into iotschema
grafnu Jul 16, 2022
5a9bdb6
Merge branch 'master' into mapping
grafnu Aug 2, 2022
b8887b5
Merge branch 'master' into iotschema
grafnu Aug 2, 2022
f9720b7
Merge branch 'master' into mapping
grafnu Aug 3, 2022
482c184
Merge branch 'master' into iotschema
grafnu Aug 3, 2022
a39e1e5
Merge branch 'master' into mapping
grafnu Aug 7, 2022
7822375
Force reset of udmif
grafnu Aug 7, 2022
bc7c784
Merge branch 'master' into iotschema
grafnu Aug 7, 2022
512f91d
Merge branch 'master' into mapping
grafnu Aug 8, 2022
744e500
Merge branch 'master' into iotschema
grafnu Aug 8, 2022
ccc39fa
Merge branch 'master' into iotschema
grafnu Aug 8, 2022
cf5b682
Cleanup of UDMIF
grafnu Aug 8, 2022
1f98143
Merge branch 'master' into mapping
grafnu Aug 8, 2022
eb32056
Updating with simpler model
grafnu Aug 9, 2022
5168ada
Update text
grafnu Aug 9, 2022
f7e8994
Refactor SiteModel errors
grafnu Aug 9, 2022
3b7774b
Extract common utils
grafnu Aug 9, 2022
256f38c
Fix javadoc
grafnu Aug 9, 2022
874e87f
Cleanup projectId handling
grafnu Aug 9, 2022
2760033
Cleanup extras
grafnu Aug 9, 2022
b0412d1
Docs revert
grafnu Aug 9, 2022
10c08e4
Fixing projectId handling
grafnu Aug 9, 2022
1806e2b
Starting refactor of Registrar
grafnu Aug 9, 2022
7c7f78c
Adding endpoint schema
grafnu Aug 9, 2022
f757f63
Moving endpoint configuration
grafnu Aug 9, 2022
48c5ba5
Clean up package and imports
grafnu Aug 9, 2022
59aa2bc
Merge branch 'sitemodel' into iotschema
grafnu Aug 9, 2022
f39bdcb
Move endpoint configuration
grafnu Aug 9, 2022
2e5a215
Using gencode
grafnu Aug 9, 2022
5e4fc4b
Basic options
grafnu Aug 9, 2022
d5d1c2f
Adding pubber configuration
grafnu Aug 9, 2022
88a852b
Options refactoring
grafnu Aug 9, 2022
81f5e25
Cleaning up options
grafnu Aug 9, 2022
75f3d3c
Fixing issues
grafnu Aug 9, 2022
c9e8a91
Fixing typos
grafnu Aug 9, 2022
8c8c247
Minor cleanups
grafnu Aug 9, 2022
0d81a96
Optimize imports
grafnu Aug 9, 2022
88c4ed7
Syntax error
grafnu Aug 9, 2022
5afd658
Merge branch 'iotschema' into registrar
grafnu Aug 9, 2022
c9b3d69
Sanitize configuration to provide some extra defaults
grafnu Aug 9, 2022
d424b64
Fixing some links
grafnu Aug 9, 2022
afe232f
Updating tweaks
grafnu Aug 9, 2022
7ec7550
Merge branch 'iotschema' into registrar
grafnu Aug 9, 2022
e972b78
hello
grafnu Aug 9, 2022
f4efd32
Fix docs links
grafnu Aug 9, 2022
23dd310
Merge branch 'iotschema' into registrar
grafnu Aug 10, 2022
b0a2b53
Merge remote-tracking branch 'faucet/master' into registrar
grafnu Aug 10, 2022
426366d
Merge remote-tracking branch 'faucet/master' into registrar
grafnu Aug 10, 2022
444de0e
Merge branch 'master' into registrar
grafnu Aug 15, 2022
4fac4ca
Merge branch 'master' into registrar
grafnu Aug 15, 2022
dbd997b
Merge branch 'master' into registrar
grafnu Aug 19, 2022
b2d2069
Merge branch 'master' into registrar
grafnu Aug 19, 2022
d3d9c9e
Merge branch 'master' into registrar
grafnu Aug 20, 2022
1f714af
Merge branch 'master' into registrar
grafnu Aug 24, 2022
b9a1708
Merge branch 'master' into registrar
grafnu Aug 25, 2022
fbd85e3
Merge branch 'master' into registrar
grafnu Aug 25, 2022
a400467
Merge branch 'master' into registrar
grafnu Aug 26, 2022
76d276b
Merge branch 'master' into registrar
grafnu Aug 27, 2022
68b1aef
Merge branch 'master' into registrar
grafnu Aug 29, 2022
704fc68
Merge branch 'master' into registrar
grafnu Aug 30, 2022
936f90a
Learning materials
grafnu Aug 31, 2022
5a77189
Merge remote-tracking branch 'faucet/master'
grafnu Aug 31, 2022
d762521
Merge branch 'master' into registrar
grafnu Aug 31, 2022
efcae5e
Learning Presentation materals
grafnu Aug 31, 2022
f38028a
Merge branch 'master' into registrar
grafnu Aug 31, 2022
2ed52e3
Updating learning readme.md copy text (#437)
grafnu Aug 31, 2022
a43895c
Merge branch 'master' into registrar
grafnu Aug 31, 2022
84c686a
Merge branch 'master' into registrar
grafnu Sep 2, 2022
f5ff6cd
Remove learning
grafnu Sep 2, 2022
97902fe
Merge branch 'master' into registrar
grafnu Sep 2, 2022
7271a1f
Merge branch 'master' into registrar
grafnu Sep 5, 2022
178240c
Merge branch 'master' into registrar
grafnu Sep 6, 2022
4bc8fec
Merge branch 'master' into registrar
grafnu Sep 6, 2022
9d1517b
Merge branch 'master' into registrar
grafnu Sep 7, 2022
7fbfdaf
Refactoring
grafnu Sep 8, 2022
f7c12a2
Registrar test cleanup
grafnu Sep 8, 2022
384bc1b
Fix test suite name
grafnu Sep 8, 2022
2a1f0ba
Add failure debugging
grafnu Sep 8, 2022
e375ea3
Add debug, maybe
grafnu Sep 8, 2022
9d2aa83
Enable debug potential
grafnu Sep 8, 2022
818ece9
Add causing exception
grafnu Sep 8, 2022
36fd789
Add more causes
grafnu Sep 8, 2022
17d653f
Slight debugging
grafnu Sep 11, 2022
9e96ebe
Refactoring IoT Core provider
grafnu Sep 11, 2022
55c127f
Linty fixes
grafnu Sep 11, 2022
2e8e943
Mock provider for unit-testing
grafnu Sep 11, 2022
f0c2d49
Linty
grafnu Sep 11, 2022
9079b2b
Adding more registrar unit tests
grafnu Sep 11, 2022
d6c5032
Linty
grafnu Sep 11, 2022
62961ca
Merge branch 'master' into registrar
grafnu Sep 11, 2022
ec6921e
Merge branch 'master' into registrar
grafnu Sep 14, 2022
2e561ab
Merge branch 'master' into registrar
grafnu Sep 14, 2022
2a423ee
Adding interface javadoc
grafnu Sep 14, 2022
fca6133
Adding interface javadoc
grafnu Sep 15, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
fgrep 'Done with pubber run, exit code 193' pubber.out.2 # last_start auto-kill check

udmi:
name: Sequence tests
name: Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 20
needs: redirect # Access to UDMI-REFLECTOR is mutually exclusive
Expand Down
41 changes: 20 additions & 21 deletions bin/test_registrar
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,29 @@ exit_status=0
echo Found ${devices} clean devices.
[ "${devices}" == 4 ] || exit_status=1

if [[ -f ${TEST_SITE}/site_metadata.json ]]; then
# Test site_metadata settings for system.location.site.
site=$(jq -r .system.location.site < ${TEST_SITE}/site_metadata.json)

# Test site_metadata settings for system.location.site.
site=$(jq -r .system.location.site < ${TEST_SITE}/site_metadata.json)

sm_devices=0
for name in ${TEST_SITE}/devices/* ; do
sm_devices=0
for name in ${TEST_SITE}/devices/* ; do
if [[ -f ${name}/out/metadata_norm.json ]]; then
supplied_site=$(jq -r ".system.location.site" < ${name}/metadata.json)
# If no site value is supplied in per-device metadata, expect default.
if [[ "${supplied_site}" == "null" ]]; then
jq -e ".system.location.site == \"${site}\"" \
${name}/out/metadata_norm.json > /dev/null \
&& sm_devices=$[sm_devices+1]
else
jq -e ".system.location.site == \"${supplied_site}\"" \
${name}/out/metadata_norm.json > /dev/null \
&& sm_devices=$[sm_devices+1]
fi
supplied_site=$(jq -r ".system.location.site" < ${name}/metadata.json)
# If no site value is supplied in per-device metadata, expect default.
if [[ "${supplied_site}" == "null" ]]; then
jq -e ".system.location.site == \"${site}\"" \
${name}/out/metadata_norm.json > /dev/null \
&& sm_devices=$[sm_devices+1]
else
jq -e ".system.location.site == \"${supplied_site}\"" \
${name}/out/metadata_norm.json > /dev/null \
&& sm_devices=$[sm_devices+1]
fi
fi
done
done

echo Found ${sm_devices} devices with correct site_metadata values.
[ "${sm_devices}" == "${devices}" ] || exit_status=1
fi
echo Found ${sm_devices} devices with correct site_metadata values.
[ "${sm_devices}" == "${devices}" ] || exit_status=1

echo Done with registrar test, exit code $exit_status
exit $exit_status

2 changes: 1 addition & 1 deletion tests/downgrade.site/registration_summary.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"DWN-2" : "devices/DWN-2"
},
"Version" : {
"main" : "1.3.13-87-g8566aca1"
"main" : "unknown"
}
}
2 changes: 1 addition & 1 deletion validator/bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export JAVA_HOME=$JAVA_HOME_11_X64
echo Building validataor in $PWD

rm -rf build
./gradlew shadow $check
./gradlew shadow $check $*

ls -l $jarfile

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.net.URI;
import java.time.Duration;
import java.time.Instant;
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Date;
Expand Down Expand Up @@ -76,7 +77,6 @@ public class Registrar {
private final Map<String, JsonSchema> schemas = new HashMap<>();
private final String generation = getGenerationString();
private CloudIotManager cloudIotManager;
private File siteDir;
private File schemaBase;
private PubSubPusher updatePusher;
private PubSubPusher feedPusher;
Expand All @@ -91,6 +91,8 @@ public class Registrar {
private Map<String, Map<String, String>> lastErrorSummary;
private boolean validateMetadata = false;
private List<String> deviceList;
private boolean blockUnknown;
private File siteDir;

/**
* Main entry point for registrar.
Expand Down Expand Up @@ -130,7 +132,8 @@ static void processArgs(List<String> argList, Registrar registrar) {
registrar.setValidateMetadata(true);
break;
case "--":
break;
registrar.setDeviceList(argList);
return;
default:
if (option.startsWith("-")) {
throw new RuntimeException("Unknown cmdline option " + option);
Expand Down Expand Up @@ -176,6 +179,8 @@ private void setValidateMetadata(boolean validateMetadata) {

private void setDeviceList(List<String> deviceList) {
this.deviceList = deviceList;
Preconditions.checkNotNull(cloudIotManager, "cloudIotManager not yet defined");
blockUnknown = false;
}

private void setFeedTopic(String feedTopic) {
Expand Down Expand Up @@ -250,6 +255,7 @@ private void initializeCloudProject() {
if (cloudIotManager.getUpdateTopic() != null) {
updatePusher = new PubSubPusher(projectId, cloudIotManager.getUpdateTopic());
}
blockUnknown = cloudIotManager.cloudIotConfig.block_unknown;
}

private String getGenerationString() {
Expand All @@ -263,11 +269,7 @@ private String getGenerationString() {
}

private void processDevices() {
processDevices(this.deviceList);
}

private void processDevices(List<String> devices) {
Set<String> deviceSet = calculateDevices(devices);
Set<String> deviceSet = calculateDevices();
AtomicInteger updatedCount = new AtomicInteger();
AtomicInteger processedCount = new AtomicInteger();
try {
Expand Down Expand Up @@ -413,11 +415,11 @@ private void updateCloudIoT(LocalDevice localDevice) {
}
}

private Set<String> calculateDevices(List<String> devices) {
if (devices == null) {
private Set<String> calculateDevices() {
if (deviceList == null) {
return null;
}
return devices.stream().map(this::deviceNameFromPath).collect(Collectors.toSet());
return deviceList.stream().map(this::deviceNameFromPath).collect(Collectors.toSet());
}

private String deviceNameFromPath(String device) {
Expand All @@ -433,7 +435,7 @@ private String deviceNameFromPath(String device) {

private ExceptionMap blockExtraDevices(Set<String> extraDevices) {
ExceptionMap exceptionMap = new ExceptionMap("Block devices errors");
if (!cloudIotManager.cloudIotConfig.block_unknown) {
if (!blockUnknown) {
return exceptionMap;
}
for (String extraName : extraDevices) {
Expand Down Expand Up @@ -533,9 +535,9 @@ private void shutdown() {
private Set<String> fetchCloudDevices() {
boolean requiresCloud = updateCloudIoT || (idleLimit != null);
if (requiresCloud) {
Set<String> devices = cloudIotManager.fetchDeviceList();
System.err.printf("Fetched %d devices from cloud registry %s%n",
devices.size(), cloudIotManager.getRegistryPath());
Set<String> devices = cloudIotManager.fetchDeviceIds();
System.err.printf("Fetched %d devices from cloud registry %s%n", devices.size(),
cloudIotManager.getRegistryId());
return devices;
} else {
System.err.println("Skipping remote registry fetch");
Expand Down Expand Up @@ -731,6 +733,10 @@ protected Map<String, JsonSchema> getSchemas() {
return schemas;
}

public List<Object> getMockActions() {
return cloudIotManager.getMockActions();
}

class RelativeDownloader implements URIDownloader {

@Override
Expand Down

This file was deleted.

Loading