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

Enable metadata schema validation #504

Merged
merged 7 commits into from
Nov 21, 2022
Merged

Conversation

grafnu
Copy link
Collaborator

@grafnu grafnu commented Nov 14, 2022

Simple flag flip, and then an extra schema test file just for fun. Requested to aid in project validation work -- feature was added previously but not enabled by default.

@@ -18,7 +18,7 @@ clean_devices=$(fgrep 'Z"' ${TEST_SITE}/registration_summary.json | wc -l)
exit_status=0

echo Found ${clean_devices} clean devices.
[ "${clean_devices}" == 4 ] || exit_status=1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this automatic?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by automatic?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automatic = Can we derive the 4 from a calculation based on the test inputs

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm semi ok with this if we make it less of a hunt to figure out why it's 3, instead of it just being a bare int by itself in a file that calculates the rest. For example

Clean devices are: SNS-4 GAT-123 AHU-22

[ "${clean_devices}" == 3 ].....

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really not sure it's worth it in this case. The logic to calculate that
for just this one case would be relatively complicated (find all the files
that don't match a very specific pattern that just matches one file), and
then likely would end up bring more fragile than just having the raw
expected value -- and then you'd also have to worry about an inadvertent
change in the input data changing the expected and actual value for the
test...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok -- added named constant with detail about why it is what it is!

@@ -301,23 +301,28 @@ private Metadata readMetadataWithValidation(boolean validate) {
return null;
}

JsonNode mergedMetadata = getMergedMetadata(instance);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add unit tests for this function please. It might need to be broken up into pieces?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added class LocalDeviceTest with coverage for the two major caes

@grafnu
Copy link
Collaborator Author

grafnu commented Nov 18, 2022

Ok, added some tests for LocalDevice (for the new function), as well as comments at the high-level about clean devices.

@grafnu grafnu merged commit 50444ea into faucetsdn:master Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants