-
Notifications
You must be signed in to change notification settings - Fork 44
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
Downgrade config generation #362
Conversation
bin/test_sites
Outdated
testdir=${OPTARG} | ||
;; | ||
\?) | ||
echo "Usage: $0 [-f] [-n] [-d TEST_DATA_DIR]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove -f -n ?
assertTrue("subsystem", simpleConfig.get("localnet").has("subsystem")); | ||
} | ||
|
||
private JsonNode getSimpleTestConfig(String filename) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a popular java junit convention for whether helper methods go at top (above tests) or bottom? Whichever it is--it may be this--can we do it? I'll follow.
There's not one (junit convention) that I'm aware of... Usually with this
sort of thing I try to go with "more interesting stuff at the top" and so
tend to shove helper methods to the bottom. Staticy stuff (so class or
initialization) things tend to go up top. If you think of "helper methods"
as more-privaty, then I would say the rough order is *static -> public ->
private,* but that's really just something I made up in my head right now
(which is essentially how this method is organized). The other
(conflicting) bit is that helper methods should go "closest" to where they
are most commonly used.... I'm sure that applies sometimes too! (Either
way, open to suggestions.)
…On Fri, Jun 17, 2022 at 8:14 AM John R ***@***.***> wrote:
***@***.**** approved this pull request.
------------------------------
In bin/test_sites
<#362 (comment)>:
> +
+schemadir=schema
+testdir=tests
+
+while getopts "d:" opt; do
+ case $opt in
+ d)
+ testdir=${OPTARG}
+ ;;
+ \?)
+ echo "Usage: $0 [-f] [-n] [-d TEST_DATA_DIR]"
+ exit -1
+ ;;
+ esac
+done
+
get the shift $[$OPTIND-1] I think it is in here
------------------------------
In bin/test_sites
<#362 (comment)>:
> +errorfile=`mktemp`
+rm -f $errorfile
+
+build=y
+force=n
+
+schemadir=schema
+testdir=tests
+
+while getopts "d:" opt; do
+ case $opt in
+ d)
+ testdir=${OPTARG}
+ ;;
+ \?)
+ echo "Usage: $0 [-f] [-n] [-d TEST_DATA_DIR]"
remove -f -n ?
------------------------------
In
validator/src/test/java/com/google/daq/mqtt/registrar/MessageDowngraderTest.java
<#362 (comment)>:
> + assertEquals("version node", simpleConfig.get("version"), new TextNode(LOCALNET_VERSION));
+ assertTrue("families", simpleConfig.get("localnet").has("families"));
+ assertTrue("subsystem", !simpleConfig.get("localnet").has("subsystem"));
+ }
+
+ @test
+ public void families() {
+ JsonNode simpleConfig = getSimpleTestConfig(LOCALNET_CONFIG_FILE);
+ MessageDowngrader downgrader = new MessageDowngrader(CONFIG_SCHEMA, simpleConfig);
+ downgrader.downgrade(new TextNode(OLD_VERSION));
+ assertEquals("version node", simpleConfig.get("version"), new TextNode(OLD_VERSION));
+ assertTrue("families", !simpleConfig.get("localnet").has("families"));
+ assertTrue("subsystem", simpleConfig.get("localnet").has("subsystem"));
+ }
+
+ private JsonNode getSimpleTestConfig(String filename) {
Is there a popular java junit convention for whether helper methods go at
top (above tests) or bottom? Whichever it is--it may be this--can we do it?
I'll follow.
—
Reply to this email directly, view it on GitHub
<#362 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIEPD5BGL7RVBCLB37YM7TVPSI5ZANCNFSM5Y2DCFCA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Addresses #334 and b/234435528
Main contribution is a new MessageDowngrader class that is used to downgrade a configuration message when it's applied for a device: validator/src/main/java/com/google/daq/mqtt/registrar/MessageDowngrader.java
tests/downgrade.site is a small test site_model (rather than using the external udmi_site_model) that is used for an integration test on this (runs bin/registrar and compares the output against redacted expected files).
There's also a unit tests for the MessageDowngrader class (and supporting .json files for consumption)
Everything else is all the other bits to make it fit together, or testing infrastructure.