diff --git a/.gencode_hash.txt b/.gencode_hash.txt index 93409ddfe..bee7ad0fa 100644 --- a/.gencode_hash.txt +++ b/.gencode_hash.txt @@ -3,7 +3,7 @@ b35646a2f3d7c30fd34e3ea6ab6a1070b39c469fd1de49cab1093ff32faaf06d gencode/docs/c 64bafb080b454189b7b64a95e049c3427fd1cca70cf0809a31150610f40e9525 gencode/docs/config.html 73b3beb740f5bc3ff26d173c356b2d3bf3b9892be83a704d3eeee7c9ff030230 gencode/docs/config_mapping.html cc4bb19794042f88f3a72b197b4d21736e5cebf6ec47ffac560430e9f580181f gencode/docs/configuration_endpoint.html -b7ca70e3176f997f254c32bd8d53dff1462ac8a71c0e166aaa85193d67bff60b gencode/docs/configuration_execution.html +eee42c93923612ad84086c2768fbdc1f1b617c67eb3665e85758a158d988ede5 gencode/docs/configuration_execution.html fa89df05f3db9b27f96b65d89d3fef4aa3c8ad8e758fcfc123627f88bf600d00 gencode/docs/configuration_pubber.html 0f0355e343cb8197dfbae1481c0eca3a0566d73181bc968e33fd469a1c94d1e6 gencode/docs/envelope.html 92da453dec3e27493216f8c3672b6203be9eb9b3086741c22fda9432c22504b7 gencode/docs/event.html @@ -23,7 +23,7 @@ f46367beaab5886ef87ce70b542611134c3565daa53e367de4f49dab51214f12 gencode/docs/r 7ed934930aee763e0beebc349725ba3909115e8d346bb762f28bcbe745bb163a gencode/docs/schema_extras.js 63cd94346f634ca2945982c147546cb1103fcfea4c42eac04b065ca838f5217f gencode/docs/state.html f10172c9b4cd350cae1f673077b07b1362168599b966a78d4ec4ef19b7bbf441 gencode/docs/state_mapping.html -552f85739f547960d2c1b96c99152ff831a036ce4d19908a5361b35a2d5f2132 gencode/docs/state_validation.html +e8c57cbcea8328957e5fbf2d73fd15bd43cf783380f31deda9e8f96f6f7e6475 gencode/docs/state_validation.html d39d7fe37a41c74a40080af7b0a429d201ab1fdff7444428c4b98eb7b38c332b gencode/java/udmi/schema/Asset.java b405ce628f7819b46b19950aeaba89ee938fea54261000616bc534b9f81bd59c gencode/java/udmi/schema/Auth_provider.java 0825a5cec83003bb0a6488c4ed7010a04ae0d3848ef36fe01bb4e6718ba7b96d gencode/java/udmi/schema/Aux.java @@ -51,7 +51,7 @@ dd2eb479a8e93a851c535c8b40fbd62e152bd60e0473f3b23800ec61f798bed0 gencode/java/u 06758aca1e0043ddf343b504030f47bb19260e99a82e2d66f12e86092a2434ca gencode/java/udmi/schema/Enumerate.java 017f8e237efa959b81d72f3dd2e78b915856198ceef02c041c657b30df93b7c2 gencode/java/udmi/schema/Envelope.java e9f5c77be81486b6b8c6d88f70f2d50583d8c3fafa2ac09ead80f44b8d5e751e gencode/java/udmi/schema/Event.java -69c3c12ce057b6ab8e27ab8cab6fb009bfd1c997652214b49e6f2a26a58f302c gencode/java/udmi/schema/ExecutionConfiguration.java +80708e2b4ee30deaf41806a80d006706b7d4bc0589e088c5c0bab0c28e772380 gencode/java/udmi/schema/ExecutionConfiguration.java 2e77a29988e6c17875d3f781be931e3b835bb310639f60d3bb28f24405a86bed gencode/java/udmi/schema/FamilyDiscoveryConfig.java ae4a645f199c8e24b3303463d428ca17af7603ae9ae9238397a6a82e752ab454 gencode/java/udmi/schema/FamilyDiscoveryEvent.java 5ad9bf328fa1500250ff8bc75f2044b3815c5c11cb368e1cc228ac8ca16639c2 gencode/java/udmi/schema/FamilyDiscoveryState.java @@ -105,7 +105,7 @@ ceacfb4a1d0a4b4f4110b0e0717e57f2bbfd80ef18599d24fab19ddf497f399e gencode/java/u d3968b92497e83a63f18cc0e74484a9807f1bb92db0c92d556ec2caaa143d645 gencode/java/udmi/schema/TestingModel.java 7793d6d76a430dc7acf668d92d2df5f8e0625d6228207731f96e220f3b90e659 gencode/java/udmi/schema/TestingSystemConfig.java ac6f8fd87c8986cce01e872460c15ff6fe71e3816f9bde610acfe25f7d38c8d4 gencode/java/udmi/schema/ValidationEvent.java -f7d117dc8b9764acf0c95a13a2bfdfbdf31d1a8ec83a707448aa4d7391ef07e2 gencode/java/udmi/schema/ValidationState.java +960c3a9ec9e309cd0dbd23c49a722a64e3b360c8771d8e6a4463ee21a44f94a6 gencode/java/udmi/schema/ValidationState.java e007ddd1ceeae3603c85110c33e1bb4a418ff9c7a791ca0df25b7ea3caeafd36 gencode/java/udmi/schema/ValidationSummary.java b77d953fd22e655c0f10ae32deeaa222769d971f8c38b3379eba45720fb910cc gencode/java/udmi/schema/VirtualEquipmentLinks.java 67553fdfe44896f487a7d4cf8161537e2595d48a96f8e44a1f9bac4a6d71591a gencode/python/udmi/schema/__init__.py @@ -129,7 +129,7 @@ ac3facbd96f7cb2f7e387e7497d6a36af379a2687329571f250c5670f9933244 gencode/python 7da3bdb37f338260d5f3829fa5fcbb9bbf9f146b514a68319c314a96c6b8ac12 gencode/python/udmi/schema/config_system.py cce623b34fd694880039a1c080214c33e00acaef5bc72276cf11a3bb2de40000 gencode/python/udmi/schema/config_system_testing.py bbaa2d9322d0c92282116c4a28edbb363d01681dc093e6463999f127aa108f51 gencode/python/udmi/schema/configuration_endpoint.py -e8a1574074554b6144b178d2adedc76a1c7be5ae911b253deff4460d8d82c6ee gencode/python/udmi/schema/configuration_execution.py +264f42c1455c4d0311b3f1cf925214f159d4728d82b3153d2b407588fb7b682c gencode/python/udmi/schema/configuration_execution.py 7f4f8c1a6ead34bf72b9134b97a39001752eb0f9647fafaac82ced4bb2f46b88 gencode/python/udmi/schema/configuration_pubber.py 998ce105f88686f27b85f3630a396ed04b106f830c133a684ea5c505ca95b1c3 gencode/python/udmi/schema/envelope.py ed8ace0196c5e99d20778cb4210aa88cfe44a5e4539af98a1e194b9a71fa538e gencode/python/udmi/schema/equipment_translation.py @@ -176,5 +176,5 @@ f2a76b32a5568d87a8c9ca8b32dc8a129bc7386f9522c5399d32db433be4cb70 gencode/python 8a601de0130081eec02724fd554749b7bd96d02874b0a3557d461cced41bd09b gencode/python/udmi/schema/state_system.py 8a0bf4294fb70533a056322a6bfc6f13a963381d2100d1468d8b6de757cd72e9 gencode/python/udmi/schema/state_system_hardware.py 37c55dce0e38dddad3cebb3d40270128a4dbb7b586657d1746bb96dac90e2ac1 gencode/python/udmi/schema/state_system_operation.py -231479e4dd7d961d59149580aba6a99cd466cea553400f338e9da2bf3ffbe78c gencode/python/udmi/schema/state_validation.py +b4ed0fc3cafb48d4dfb5fb54f5b1d48df2d57ac85a5c36591ca12ed97ca8e687 gencode/python/udmi/schema/state_validation.py 83a57db63df10d43b1789c3f115a515c23bb7bc7a8cc8c2accdc17d0cbac89fe gencode/python/udmi/schema/virtual_links.py diff --git a/.gitignore b/.gitignore index 743e4d10d..ef6f709c3 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ credentials.json /validator/.idea/libraries/ /pubber/build/ /pubber/out/ +/pubber/pubber/out/ /pubber/.idea/libraries/ /sites/ /attributes.json diff --git a/bin/test_locate b/bin/test_locate index c606e5e9c..24dd0f3c8 100755 --- a/bin/test_locate +++ b/bin/test_locate @@ -1,19 +1,34 @@ #!/bin/bash -e +function locate_help { + echo To clean config directories and stop-at-first-failure, use: + echo + echo $0 trial + echo + false +} + + ROOT=$(realpath $(dirname $0)/..) cd $ROOT +trial_run= +if [[ $1 == trial ]]; then + trial_run=true + shift +fi + failures=$(mktemp) working=$(mktemp) function test_locate { - udmi locate $2 > $working + udmi locate $2 > $working 2>&1 || true profile=$(echo $(fgrep profile: $working | cut -d: -f2)) site_model=$(echo $(fgrep site_model: $working | cut -d: -f2)) - if [[ -n $4 ]]; then + if [[ -n $4 && $4 != null ]]; then expected_site=$(realpath --relative-base $PWD $ROOT/$4) else - expected_site= + expected_site=$4 fi if [[ $profile == $3 && $site_model == $expected_site ]]; then result=PASS @@ -27,6 +42,14 @@ function test_locate { echo " site_model expected:" $expected_site was $site_model >> $failures fi echo $result $1 + if [[ -n $trial_run && $result != PASS ]]; then + echo ====================== + cat $working + echo ====================== + cat $failures + echo ====================== + return 1 + fi } # Make sure udmi is in the path. @@ -42,9 +65,14 @@ cat < $PROFILE_TEMPLATE } EOF +if [[ -n $trial_run ]]; then + echo Cleaning config directories... + rm -rf $HOME/.udmi $ROOT/$SITE_PATH/.udmi +fi + [[ ! -d $ROOT/$SITE_PATH ]] && (echo $ROOT/$SITE_PATH not found, check your setup. && false) -[[ -d $HOME/.udmi ]] && (echo $HOME/.udmi exists, remove before testing && false) -[[ -d $ROOT/$SITE_PATH/.udmi ]] && (echo $ROOT/$SITE_PATH/.udmi exists, remove before testing && false) +[[ -d $HOME/.udmi ]] && (echo $HOME/.udmi exists; locate_help) +[[ -d $ROOT/$SITE_PATH/.udmi ]] && (echo $ROOT/$SITE_PATH/.udmi exists; locate_help) rm -rf $HOME/.udmi $ROOT/$SITE_PATH/.udmi mkdir -p $HOME/.udmi $ROOT/$SITE_PATH/.udmi @@ -62,12 +90,12 @@ test_locate user_missing bar "" "" echo Remove user default profile... rm -f $HOME/.udmi/default_profile.json -test_locate default_missing "" "" "" +test_locate default_missing "" .udmi/default_profile.json null echo Create empty user default profile... echo {} > $HOME/.udmi/default_profile.json -test_locate default_empty "" .udmi/default_profile.json "" +test_locate default_empty "" .udmi/default_profile.json null cd $ROOT/$SITE_PATH echo Testing from $PWD @@ -77,9 +105,9 @@ cp $PROFILE_TEMPLATE .udmi/ cp $PROFILE_TEMPLATE .udmi/profile_bar.json test_locate site_default "" .udmi/default_profile.json $SITE_PATH -test_locate site_missing foo "" $SITE_PATH +test_locate site_missing foo $HOME/.udmi/profile_foo.json $SITE_PATH test_locate site_profile bar .udmi/profile_bar.json $SITE_PATH -test_locate site_nothing baz "" $SITE_PATH +test_locate site_nothing baz "" "" echo Cleanup .udmi directories... rm -rf $HOME/.udmi $ROOT/$SITE_PATH/.udmi diff --git a/bin/test_trace b/bin/test_trace index 11abd0f5a..77513a0d7 100755 --- a/bin/test_trace +++ b/bin/test_trace @@ -13,6 +13,9 @@ trace_in=validator/traces/${trace_name}.in site_model=sites/udmi_site_model site_out=$site_model/out +# Use a static/constant value to make output stable. +export UDMI_TOOLS=test_trace + rm -rf $site_out validator/bin/validate -- schema trace $trace_in $site_model diff --git a/bin/test_validator b/bin/test_validator index f6d115075..c3edfdb67 100755 --- a/bin/test_validator +++ b/bin/test_validator @@ -41,7 +41,7 @@ bin/reset_config $site_path $project_id $device_id bin/reset_config $site_path $project_id $proxy_id echo Starting validator, output in $VALIDATOR_OUT -bin/validator $site_path $project_id > $VALIDATOR_OUT 2>&1 & +udmi validate -s $site_path -p $project_id > $VALIDATOR_OUT 2>&1 & vpid=$! echo Started validator pid $vpid diff --git a/bin/udmi-locate b/bin/udmi-locate index a06cfbfd2..b4c11bd5b 100755 --- a/bin/udmi-locate +++ b/bin/udmi-locate @@ -1,10 +1,6 @@ #!/bin/bash -e -UDMI_ROOT=$(realpath $(dirname $(readlink -f $0))/..) - -source $UDMI_ROOT/etc/shell_common.sh - -source $UDMI_ROOT/etc/find_udmi_profile.sh +source $(realpath $(dirname $(readlink -f $0))/..)/etc/udmi_preamble.sh echo profile: ${udmi_profile} -echo site_model: ${site_model} +echo site_model: ${udmi_site} diff --git a/bin/udmi-pubber b/bin/udmi-pubber index e1d3552ca..ad304e4f2 100755 --- a/bin/udmi-pubber +++ b/bin/udmi-pubber @@ -1,18 +1,12 @@ #!/bin/bash -e -UDMI_ROOT=$(realpath $(dirname $(readlink -f $0))/..) +source $(realpath $(dirname $(readlink -f $0))/..)/etc/udmi_preamble.sh -cd $UDMI_ROOT +[[ $udmi_site != null ]] || udmi_help site_model not defined +[[ $udmi_project != null ]] || udmi_help project_id not defined +[[ $udmi_device != null ]] || udmi_help device_id not defined +[[ $udmi_serial != null ]] || udmi_help serial_id not defined -source etc/shell_common.sh - -source etc/find_udmi_profile.sh - -source etc/extract_parameters.sh - -[[ $udmi_project != null ]] || (echo project_id not defined && false) -[[ $udmi_device != null ]] || (echo device_id not defined && false) -[[ $udmi_serial != null ]] || (echo serial_id not defined && false) - -echo $UDMI_ROOT/bin/pubber $site_model $udmi_project $udmi_device $udmi_serial $* -$UDMI_ROOT/bin/pubber $site_model $udmi_project $udmi_device $udmi_serial $* +cmd="$UDMI_ROOT/bin/pubber $udmi_site $udmi_project $udmi_device $udmi_serial $*" +echo $cmd +$cmd diff --git a/bin/udmi-validate b/bin/udmi-validate new file mode 100755 index 000000000..f9d026a4b --- /dev/null +++ b/bin/udmi-validate @@ -0,0 +1,60 @@ +#!/bin/bash -e + +source $(realpath $(dirname $(readlink -f $0))/..)/etc/udmi_preamble.sh + +CONFIG_FILE=/tmp/validator_config.json + +echo $udmi_site +[[ $udmi_site != null ]] || udmi_help site_model not defined +[[ $udmi_project != null ]] || udmi_help project_id not defined + +[[ $udmi_feed != null ]] || udmi_feed= + +SUMMARY_FILE=out/validation_report.json +rm -f $SUMMARY_FILE + +$UDMI_ROOT/validator/bin/build + +echo Writing config to $CONFIG_FILE +cat < $CONFIG_FILE +{ + "project_id": "$udmi_project", + "site_model": "$udmi_site", + "log_level": "$udmi_loglevel", + "udmi_root": "$UDMI_ROOT", + "feed_name": "$udmi_feed", + "udmi_version": "$udmi_version", + "key_file": "$site_path/validator/rsa_private.pkcs8" +} +EOF + +JAVA_CMD="java -cp $UDMI_JAR com.google.daq.mqtt.validator.Validator" + +cmd="$JAVA_CMD $CONFIG_FILE" +if [[ $udmi_runsec != null ]]; then + cmd="timeout ${udmi_runsec}s $cmd" +fi + +echo $cmd +result=0 +$cmd || result=$? + +if [[ $result != 124 ]]; then + echo abnormal termination not due to timeout. + false +fi + +[[ -f $SUMMARY_FILE ]] || (echo missing summary file $SUMMARY_FILE && false) + +mkdir -p out/devices + +error_files=$(find out/devices/ -name \*.out) +echo +if [[ -n $error_files ]]; then + echo Device validation error files: + find out/devices/ -name \*.out +else + echo No device validation errors found. +fi +echo +echo Report summary in $SUMMARY_FILE diff --git a/etc/extract_parameters.sh b/etc/extract_parameters.sh index 2a9209173..386fbb2b2 100644 --- a/etc/extract_parameters.sh +++ b/etc/extract_parameters.sh @@ -11,23 +11,53 @@ fi udmi_device=$(jq -r .device_id $udmi_profile) udmi_project=$(jq -r .project_id $udmi_profile) udmi_serial=$(jq -r .serial_no $udmi_profile) +udmi_runsec=$(jq -r .run_sec $udmi_profile) +udmi_keyfile=$(jq -r .key_file $udmi_profile) +udmi_feed=$(jq -r .feed_name $udmi_profile) -while getopts "d:p:x:" opt; do +while getopts "p:d:x:l:s:k:f:" opt; do case $opt in - d) - udmi_device=${OPTARG} - ;; p) udmi_project=${OPTARG} ;; + s) + udmi_site=${OPTARG} + ;; + d) + udmi_device=${OPTARG} + ;; x) udmi_serial=${OPTARG} ;; + l) + udmi_runsec=${OPTARG} + ;; + k) + udmi_keyfile=${OPTARG} + ;; + f) + udmi_feed=${OPTARG} + ;; \?) - echo "Usage: [-d device] [-p project] [-x serial]" + echo "Usage: [-p project] [-s site] [-d device] [-x serial] [-l length] [-k key_file] [-f feed_name]" false ;; esac done shift $((OPTIND-1)) + +function udmi_help { + echo + echo $* + echo + echo 'Common udmi profile paramaeters (or command line option):' + echo ' project_id (-p): the cloud project id' + echo ' site_model (-s): the udmi site model' + echo ' device_id (-d): the device id to test/validate' + echo ' serial_no (-x): the device serial number for test' + echo ' run_sec (-l): the test run length in seconds' + echo ' key_file (-k): reflector device private key file' + echo ' feed_name (-f): PubSub cloud feed subscription name' + false +} diff --git a/etc/find_udmi_profile.sh b/etc/find_udmi_profile.sh index eadc52e43..559c04714 100644 --- a/etc/find_udmi_profile.sh +++ b/etc/find_udmi_profile.sh @@ -7,8 +7,8 @@ # a. Look for working site_model directory and use ${site_mode}/.udmi/defailt_profile.json # b. Look in ~/.udmi/default_profile.json # 2. Specific profile specified as file wiht .json extension -# a. Site defined in profile # a. Site derived from working path (parent with .udmi directory) +# b. Site defined in profile # 3. Semantic profile specificed (no .json) # a. Working site derived from current working directory, look in ${site_mode}/.udmi/profile_${profile}.json # b. Look in ~/.udmi/profile_${profile}.json @@ -16,69 +16,76 @@ function find_or_extract { if [[ -f $1 ]]; then - site_model=$(jq -r .site_model < $1) + udmi_site=$(jq -r .site_model < $1) profile_dir=$(dirname $1) - if [[ -z ${site_model} ]]; then - site_model=$(cd ${profile_dir}; find_site_model_root) - elif [[ ${site_model} == "null" ]]; then - site_model= - elif [[ ${site_model} =~ ^/ ]]; then + if [[ -z ${udmi_site} ]]; then + udmi_site=$(cd ${profile_dir}; find_site_model_root) + elif [[ ${udmi_site} == "null" ]]; then + udmi_site= + elif [[ ${udmi_site} =~ ^/ ]]; then true # model is absolue, so don't munge. else - site_model=$(realpath --relative-base ${PWD} ${profile_dir}/${site_model}) + udmi_site=$(realpath --relative-base ${PWD} ${profile_dir}/${udmi_site}) fi - echo ${site_model} + echo ${udmi_site} fi } +udmi_site=$(find_site_model_root) udmi_profile= + if [[ -z $1 || $1 =~ ^- ]]; then # No argument specified - site_model=$(find_site_model_root) - if [[ -d ${site_model}/.udmi ]]; then - echo Using working site model $site_model - udmi_profile=${site_model}/.udmi/default_profile.json + if [[ -d ${udmi_site}/.udmi ]]; then + udmi_profile=${udmi_site}/.udmi/default_profile.json echo Using site model default udmi profile $udmi_profile else udmi_profile=~/.udmi/default_profile.json echo Using user default udmi profile $udmi_profile - site_model=$(find_or_extract $udmi_profile) - echo Extracted site model $site_model + fi + if [[ ! -f ${udmi_profile} ]]; then + echo Creating empty default profile ${udmi_profile} + mkdir -p $(dirname ${udmi_profile}) + echo {} > ${udmi_profile} fi elif [[ $1 =~ .json$ ]]; then # Explicit .json file udmi_profile=$1 + echo Using explicit udmi profile $udmi_profile shift - site_model=$(find_or_extract $udmi_profile) else # Semantic profile (no .json suffix) profile_name=$1 shift - site_model=$(find_site_model_root) - if [[ ! -f ${site_model}/cloud_iot_config.json ]]; then - site_model= + if [[ -n ${udmi_site} ]]; then + udmi_profile=${udmi_site}/.udmi/profile_${profile_name}.json + alt_profile="or $udmi_profile" fi - if [[ -n ${site_model} ]]; then - udmi_profile=${site_model}/.udmi/profile_${profile_name}.json - else + if [[ ! -f ${udmi_profile} ]]; then udmi_profile=~/.udmi/profile_${profile_name}.json - site_model=$(find_or_extract $udmi_profile) fi - if [[ -z ${site_model} ]]; then + if [[ ! -f ${udmi_profile} ]]; then + echo Missing named udmi profile $udmi_profile $alt_profile udmi_profile= + false + else + echo Using named udmi profile $udmi_profile fi fi -if [[ ! -f ${udmi_profile} ]]; then - echo Invalid/empty udmi_profile ${udmi_profile} - udmi_profile= -else - udmi_profile=$(realpath --relative-base $PWD ${udmi_profile}) +udmi_profile=$(realpath --relative-base $PWD ${udmi_profile}) + +profile_udmi_site=$(find_or_extract $udmi_profile) +if [[ -n $profile_udmi_site ]]; then + udmi_site=$profile_udmi_site + echo Using extracted site model $udmi_site +elif [[ -n $udmi_site ]]; then + echo Using implicit site model $udmi_site fi -if [[ ! -f ${site_model}/cloud_iot_config.json ]]; then - echo Invalid/empty site_model ${site_model} - site_model= +if [[ -n $udmi_site ]]; then + udmi_site=$(realpath --relative-base $PWD ${udmi_site}) else - site_model=$(realpath --relative-base $PWD ${site_model}) + udmi_site=null + echo No implicit or explicit site model found. fi diff --git a/etc/shell_common.sh b/etc/shell_common.sh index 09b8be843..7773df7eb 100644 --- a/etc/shell_common.sh +++ b/etc/shell_common.sh @@ -14,3 +14,9 @@ function find_site_model_root { cd .. done } + + +UDMI_JAR=$UDMI_ROOT/validator/build/libs/validator-1.0-SNAPSHOT-all.jar + +udmi_version=$(cd $UDMI_ROOT; git describe --dirty --always) +export UDMI_TOOLS=$udmi_version diff --git a/etc/udmi_preamble.sh b/etc/udmi_preamble.sh new file mode 100644 index 000000000..11e0f2c72 --- /dev/null +++ b/etc/udmi_preamble.sh @@ -0,0 +1,8 @@ + +UDMI_ROOT=$(realpath $(dirname $(readlink -f $0))/..) + +source $UDMI_ROOT/etc/shell_common.sh + +source $UDMI_ROOT/etc/find_udmi_profile.sh + +source $UDMI_ROOT/etc/extract_parameters.sh diff --git a/gencode/docs/configuration_execution.html b/gencode/docs/configuration_execution.html index bd9c123b6..a66fa5434 100644 --- a/gencode/docs/configuration_execution.html +++ b/gencode/docs/configuration_execution.html @@ -157,6 +157,39 @@

+ + + + +
+
+
+

+ +

+
+ +
+
+ + Type: string
+ + + + + + +
@@ -421,6 +454,39 @@

+

+ + + +
+
+
+

+ +

+
+ +
+
+ + Type: string
+ + + + + + +
diff --git a/gencode/docs/state_validation.html b/gencode/docs/state_validation.html index 3f96cec09..bd72f6552 100644 --- a/gencode/docs/state_validation.html +++ b/gencode/docs/state_validation.html @@ -97,6 +97,40 @@

+

+ + + +
+
+
+

+ +

+
+ +
+
+ + Type: string
+

Version of the tools for this run

+
+ + + + + +
@@ -131,6 +165,40 @@

+

+ + + +
+
+
+

+ +

+
+ +
+
+ + Type: string
+

timestamp of when the validation report was started

+
+ + + + + +
diff --git a/gencode/java/udmi/schema/ExecutionConfiguration.java b/gencode/java/udmi/schema/ExecutionConfiguration.java index 9f9482799..07f674834 100644 --- a/gencode/java/udmi/schema/ExecutionConfiguration.java +++ b/gencode/java/udmi/schema/ExecutionConfiguration.java @@ -19,6 +19,7 @@ "cloud_region", "site_name", "update_topic", + "feed_name", "reflect_region", "site_model", "device_id", @@ -27,6 +28,7 @@ "serial_no", "log_level", "udmi_version", + "udmi_root", "alt_project", "alt_registry", "block_unknown" @@ -42,6 +44,8 @@ public class ExecutionConfiguration { public String site_name; @JsonProperty("update_topic") public String update_topic; + @JsonProperty("feed_name") + public String feed_name; @JsonProperty("reflect_region") public String reflect_region; @JsonProperty("site_model") @@ -58,6 +62,8 @@ public class ExecutionConfiguration { public String log_level; @JsonProperty("udmi_version") public String udmi_version; + @JsonProperty("udmi_root") + public String udmi_root; @JsonProperty("alt_project") public String alt_project; @JsonProperty("alt_registry") @@ -78,9 +84,11 @@ public int hashCode() { result = ((result* 31)+((this.log_level == null)? 0 :this.log_level.hashCode())); result = ((result* 31)+((this.site_model == null)? 0 :this.site_model.hashCode())); result = ((result* 31)+((this.registry_id == null)? 0 :this.registry_id.hashCode())); + result = ((result* 31)+((this.feed_name == null)? 0 :this.feed_name.hashCode())); result = ((result* 31)+((this.site_name == null)? 0 :this.site_name.hashCode())); result = ((result* 31)+((this.update_topic == null)? 0 :this.update_topic.hashCode())); result = ((result* 31)+((this.project_id == null)? 0 :this.project_id.hashCode())); + result = ((result* 31)+((this.udmi_root == null)? 0 :this.udmi_root.hashCode())); result = ((result* 31)+((this.serial_no == null)? 0 :this.serial_no.hashCode())); result = ((result* 31)+((this.reflect_region == null)? 0 :this.reflect_region.hashCode())); return result; @@ -95,7 +103,7 @@ public boolean equals(Object other) { return false; } ExecutionConfiguration rhs = ((ExecutionConfiguration) other); - return ((((((((((((((((this.alt_registry == rhs.alt_registry)||((this.alt_registry!= null)&&this.alt_registry.equals(rhs.alt_registry)))&&((this.block_unknown == rhs.block_unknown)||((this.block_unknown!= null)&&this.block_unknown.equals(rhs.block_unknown))))&&((this.cloud_region == rhs.cloud_region)||((this.cloud_region!= null)&&this.cloud_region.equals(rhs.cloud_region))))&&((this.device_id == rhs.device_id)||((this.device_id!= null)&&this.device_id.equals(rhs.device_id))))&&((this.key_file == rhs.key_file)||((this.key_file!= null)&&this.key_file.equals(rhs.key_file))))&&((this.udmi_version == rhs.udmi_version)||((this.udmi_version!= null)&&this.udmi_version.equals(rhs.udmi_version))))&&((this.alt_project == rhs.alt_project)||((this.alt_project!= null)&&this.alt_project.equals(rhs.alt_project))))&&((this.log_level == rhs.log_level)||((this.log_level!= null)&&this.log_level.equals(rhs.log_level))))&&((this.site_model == rhs.site_model)||((this.site_model!= null)&&this.site_model.equals(rhs.site_model))))&&((this.registry_id == rhs.registry_id)||((this.registry_id!= null)&&this.registry_id.equals(rhs.registry_id))))&&((this.site_name == rhs.site_name)||((this.site_name!= null)&&this.site_name.equals(rhs.site_name))))&&((this.update_topic == rhs.update_topic)||((this.update_topic!= null)&&this.update_topic.equals(rhs.update_topic))))&&((this.project_id == rhs.project_id)||((this.project_id!= null)&&this.project_id.equals(rhs.project_id))))&&((this.serial_no == rhs.serial_no)||((this.serial_no!= null)&&this.serial_no.equals(rhs.serial_no))))&&((this.reflect_region == rhs.reflect_region)||((this.reflect_region!= null)&&this.reflect_region.equals(rhs.reflect_region)))); + return ((((((((((((((((((this.alt_registry == rhs.alt_registry)||((this.alt_registry!= null)&&this.alt_registry.equals(rhs.alt_registry)))&&((this.block_unknown == rhs.block_unknown)||((this.block_unknown!= null)&&this.block_unknown.equals(rhs.block_unknown))))&&((this.cloud_region == rhs.cloud_region)||((this.cloud_region!= null)&&this.cloud_region.equals(rhs.cloud_region))))&&((this.device_id == rhs.device_id)||((this.device_id!= null)&&this.device_id.equals(rhs.device_id))))&&((this.key_file == rhs.key_file)||((this.key_file!= null)&&this.key_file.equals(rhs.key_file))))&&((this.udmi_version == rhs.udmi_version)||((this.udmi_version!= null)&&this.udmi_version.equals(rhs.udmi_version))))&&((this.alt_project == rhs.alt_project)||((this.alt_project!= null)&&this.alt_project.equals(rhs.alt_project))))&&((this.log_level == rhs.log_level)||((this.log_level!= null)&&this.log_level.equals(rhs.log_level))))&&((this.site_model == rhs.site_model)||((this.site_model!= null)&&this.site_model.equals(rhs.site_model))))&&((this.registry_id == rhs.registry_id)||((this.registry_id!= null)&&this.registry_id.equals(rhs.registry_id))))&&((this.feed_name == rhs.feed_name)||((this.feed_name!= null)&&this.feed_name.equals(rhs.feed_name))))&&((this.site_name == rhs.site_name)||((this.site_name!= null)&&this.site_name.equals(rhs.site_name))))&&((this.update_topic == rhs.update_topic)||((this.update_topic!= null)&&this.update_topic.equals(rhs.update_topic))))&&((this.project_id == rhs.project_id)||((this.project_id!= null)&&this.project_id.equals(rhs.project_id))))&&((this.udmi_root == rhs.udmi_root)||((this.udmi_root!= null)&&this.udmi_root.equals(rhs.udmi_root))))&&((this.serial_no == rhs.serial_no)||((this.serial_no!= null)&&this.serial_no.equals(rhs.serial_no))))&&((this.reflect_region == rhs.reflect_region)||((this.reflect_region!= null)&&this.reflect_region.equals(rhs.reflect_region)))); } } diff --git a/gencode/java/udmi/schema/ValidationState.java b/gencode/java/udmi/schema/ValidationState.java index ca594b4a6..ec0f44861 100644 --- a/gencode/java/udmi/schema/ValidationState.java +++ b/gencode/java/udmi/schema/ValidationState.java @@ -20,7 +20,9 @@ @JsonPropertyOrder({ "timestamp", "version", + "tools", "last_updated", + "start_time", "status", "summary", "devices" @@ -42,6 +44,13 @@ public class ValidationState { @JsonProperty("version") @JsonPropertyDescription("Version of the UDMI schema") public java.lang.String version; + /** + * Version of the tools for this run + * + */ + @JsonProperty("tools") + @JsonPropertyDescription("Version of the tools for this run") + public java.lang.String tools; /** * Last time this validation report was updated * (Required) @@ -50,6 +59,13 @@ public class ValidationState { @JsonProperty("last_updated") @JsonPropertyDescription("Last time this validation report was updated") public Date last_updated; + /** + * timestamp of when the validation report was started + * + */ + @JsonProperty("start_time") + @JsonPropertyDescription("timestamp of when the validation report was started") + public Date start_time; /** * Entry *

@@ -79,9 +95,11 @@ public class ValidationState { public int hashCode() { int result = 1; result = ((result* 31)+((this.summary == null)? 0 :this.summary.hashCode())); + result = ((result* 31)+((this.start_time == null)? 0 :this.start_time.hashCode())); result = ((result* 31)+((this.last_updated == null)? 0 :this.last_updated.hashCode())); result = ((result* 31)+((this.devices == null)? 0 :this.devices.hashCode())); result = ((result* 31)+((this.version == null)? 0 :this.version.hashCode())); + result = ((result* 31)+((this.tools == null)? 0 :this.tools.hashCode())); result = ((result* 31)+((this.timestamp == null)? 0 :this.timestamp.hashCode())); result = ((result* 31)+((this.status == null)? 0 :this.status.hashCode())); return result; @@ -96,7 +114,7 @@ public boolean equals(Object other) { return false; } ValidationState rhs = ((ValidationState) other); - return (((((((this.summary == rhs.summary)||((this.summary!= null)&&this.summary.equals(rhs.summary)))&&((this.last_updated == rhs.last_updated)||((this.last_updated!= null)&&this.last_updated.equals(rhs.last_updated))))&&((this.devices == rhs.devices)||((this.devices!= null)&&this.devices.equals(rhs.devices))))&&((this.version == rhs.version)||((this.version!= null)&&this.version.equals(rhs.version))))&&((this.timestamp == rhs.timestamp)||((this.timestamp!= null)&&this.timestamp.equals(rhs.timestamp))))&&((this.status == rhs.status)||((this.status!= null)&&this.status.equals(rhs.status)))); + return (((((((((this.summary == rhs.summary)||((this.summary!= null)&&this.summary.equals(rhs.summary)))&&((this.start_time == rhs.start_time)||((this.start_time!= null)&&this.start_time.equals(rhs.start_time))))&&((this.last_updated == rhs.last_updated)||((this.last_updated!= null)&&this.last_updated.equals(rhs.last_updated))))&&((this.devices == rhs.devices)||((this.devices!= null)&&this.devices.equals(rhs.devices))))&&((this.version == rhs.version)||((this.version!= null)&&this.version.equals(rhs.version))))&&((this.tools == rhs.tools)||((this.tools!= null)&&this.tools.equals(rhs.tools))))&&((this.timestamp == rhs.timestamp)||((this.timestamp!= null)&&this.timestamp.equals(rhs.timestamp))))&&((this.status == rhs.status)||((this.status!= null)&&this.status.equals(rhs.status)))); } } diff --git a/gencode/python/udmi/schema/configuration_execution.py b/gencode/python/udmi/schema/configuration_execution.py index b3b97105f..f153b54be 100644 --- a/gencode/python/udmi/schema/configuration_execution.py +++ b/gencode/python/udmi/schema/configuration_execution.py @@ -9,6 +9,7 @@ def __init__(self): self.cloud_region = None self.site_name = None self.update_topic = None + self.feed_name = None self.reflect_region = None self.site_model = None self.device_id = None @@ -17,6 +18,7 @@ def __init__(self): self.serial_no = None self.log_level = None self.udmi_version = None + self.udmi_root = None self.alt_project = None self.alt_registry = None self.block_unknown = None @@ -30,6 +32,7 @@ def from_dict(source): result.cloud_region = source.get('cloud_region') result.site_name = source.get('site_name') result.update_topic = source.get('update_topic') + result.feed_name = source.get('feed_name') result.reflect_region = source.get('reflect_region') result.site_model = source.get('site_model') result.device_id = source.get('device_id') @@ -38,6 +41,7 @@ def from_dict(source): result.serial_no = source.get('serial_no') result.log_level = source.get('log_level') result.udmi_version = source.get('udmi_version') + result.udmi_root = source.get('udmi_root') result.alt_project = source.get('alt_project') result.alt_registry = source.get('alt_registry') result.block_unknown = source.get('block_unknown') @@ -69,6 +73,8 @@ def to_dict(self): result['site_name'] = self.site_name # 5 if self.update_topic: result['update_topic'] = self.update_topic # 5 + if self.feed_name: + result['feed_name'] = self.feed_name # 5 if self.reflect_region: result['reflect_region'] = self.reflect_region # 5 if self.site_model: @@ -85,6 +91,8 @@ def to_dict(self): result['log_level'] = self.log_level # 5 if self.udmi_version: result['udmi_version'] = self.udmi_version # 5 + if self.udmi_root: + result['udmi_root'] = self.udmi_root # 5 if self.alt_project: result['alt_project'] = self.alt_project # 5 if self.alt_registry: diff --git a/gencode/python/udmi/schema/state_validation.py b/gencode/python/udmi/schema/state_validation.py index e7b9fddb7..8ace945cb 100644 --- a/gencode/python/udmi/schema/state_validation.py +++ b/gencode/python/udmi/schema/state_validation.py @@ -58,7 +58,9 @@ class ValidationState: def __init__(self): self.timestamp = None self.version = None + self.tools = None self.last_updated = None + self.start_time = None self.status = None self.summary = None self.devices = None @@ -70,7 +72,9 @@ def from_dict(source): result = ValidationState() result.timestamp = source.get('timestamp') result.version = source.get('version') + result.tools = source.get('tools') result.last_updated = source.get('last_updated') + result.start_time = source.get('start_time') result.status = Entry.from_dict(source.get('status')) result.summary = ValidationSummary.from_dict(source.get('summary')) result.devices = DeviceValidationEvent.map_from(source.get('devices')) @@ -98,8 +102,12 @@ def to_dict(self): result['timestamp'] = self.timestamp # 5 if self.version: result['version'] = self.version # 5 + if self.tools: + result['tools'] = self.tools # 5 if self.last_updated: result['last_updated'] = self.last_updated # 5 + if self.start_time: + result['start_time'] = self.start_time # 5 if self.status: result['status'] = self.status.to_dict() # 4 if self.summary: diff --git a/schema/configuration_execution.json b/schema/configuration_execution.json index 668e8a017..6b2a1b1ee 100644 --- a/schema/configuration_execution.json +++ b/schema/configuration_execution.json @@ -19,6 +19,9 @@ "update_topic": { "type": "string" }, + "feed_name": { + "type": "string" + }, "reflect_region": { "type": "string" }, @@ -43,6 +46,9 @@ "udmi_version": { "type": "string" }, + "udmi_root": { + "type": "string" + }, "alt_project": { "type": "string" }, diff --git a/schema/state_validation.json b/schema/state_validation.json index db25a7678..a3b4672c1 100644 --- a/schema/state_validation.json +++ b/schema/state_validation.json @@ -16,11 +16,20 @@ "description": "Version of the UDMI schema", "type": "string" }, + "tools": { + "description": "Version of the tools for this run", + "type": "string" + }, "last_updated": { "description": "Last time this validation report was updated", "format": "date-time", "type": "string" }, + "start_time": { + "description": "timestamp of when the validation report was started", + "format": "date-time", + "type": "string" + }, "status": { "$ref": "file:common.json#/definitions/entry" }, diff --git a/validator/src/main/java/com/google/daq/mqtt/util/ConfigUtil.java b/validator/src/main/java/com/google/daq/mqtt/util/ConfigUtil.java index a40b1ff8f..ce5ac7a6d 100644 --- a/validator/src/main/java/com/google/daq/mqtt/util/ConfigUtil.java +++ b/validator/src/main/java/com/google/daq/mqtt/util/ConfigUtil.java @@ -20,6 +20,7 @@ public abstract class ConfigUtil { public static final String EXCEPTIONS_JSON = "exceptions.json"; public static final String UDMI_VERSION = "1.4.0"; + public static final String UDMI_TOOLS = System.getenv("UDMI_TOOLS"); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper() .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) diff --git a/validator/src/main/java/com/google/daq/mqtt/validator/Validator.java b/validator/src/main/java/com/google/daq/mqtt/validator/Validator.java index 33ed82f25..b3ff9a0cc 100644 --- a/validator/src/main/java/com/google/daq/mqtt/validator/Validator.java +++ b/validator/src/main/java/com/google/daq/mqtt/validator/Validator.java @@ -9,11 +9,11 @@ import static com.google.daq.mqtt.util.Common.TIMESTAMP_PROPERTY_KEY; import static com.google.daq.mqtt.util.Common.VERSION_PROPERTY_KEY; import static com.google.daq.mqtt.util.Common.removeNextArg; +import static com.google.daq.mqtt.util.ConfigUtil.UDMI_TOOLS; import static com.google.daq.mqtt.util.ConfigUtil.UDMI_VERSION; import static com.google.daq.mqtt.util.ConfigUtil.readExecutionConfiguration; import static com.google.udmi.util.JsonUtil.JSON_SUFFIX; import static com.google.udmi.util.JsonUtil.OBJECT_MAPPER; -import static com.google.udmi.util.JsonUtil.stringify; import static java.util.Objects.requireNonNull; import com.fasterxml.jackson.core.type.TypeReference; @@ -129,6 +129,7 @@ public class Validator { private static final String VALIDATION_EVENT_TOPIC = "validation/event"; private static final String VALIDATION_STATE_TOPIC = "validation/state"; private static final String POINTSET_SUBFOLDER = "pointset"; + private static final Date START_TIME = new Date(); private final Map expectedDevices = new TreeMap<>(); private final Set extraDevices = new TreeSet<>(); private final Set processedDevices = new TreeSet<>(); @@ -207,7 +208,6 @@ private List parseArgs(List argList) { setSchemaSpec(removeNextArg(argList)); break; case "-t": - cloudIotManager = new CloudIotManager(config.project_id, new File(config.site_model)); validatePubSub(removeNextArg(argList)); break; case "-f": @@ -238,9 +238,22 @@ private List parseArgs(List argList) { return argList; } + private void validatePubSub(String instName) { + cloudIotManager = new CloudIotManager(config.project_id, new File(config.site_model)); + String registryId = getRegistryId(); + String updateTopic = cloudIotManager.getUpdateTopic(); + client = new PubSubClient(config.project_id, registryId, instName, updateTopic); + if (updateTopic != null) { + dataSinks.add(client); + } + } + private void processProfile(File profilePath) { config = ConfigUtil.readExecutionConfiguration(profilePath); setSiteDir(config.site_model); + if (!Strings.isNullOrEmpty(config.feed_name)) { + validatePubSub(config.feed_name); + } } MessageReadingClient getMessageReadingClient() { @@ -330,9 +343,11 @@ private void initializeExpectedDevices(String siteDir) { * @param schemaPath schema specification directory */ public void setSchemaSpec(String schemaPath) { - File schemaFile = new File(schemaPath).getAbsoluteFile(); + File schemaPart = new File(schemaPath); + boolean rawPath = schemaPart.isAbsolute() || Strings.isNullOrEmpty(config.udmi_root); + File schemaFile = rawPath ? schemaPart : new File(new File(config.udmi_root), schemaPath); if (schemaFile.isFile()) { - schemaRoot = schemaFile.getParentFile(); + schemaRoot = Optional.ofNullable(schemaFile.getParentFile()).orElse(new File(".")); schemaSpec = schemaFile.getName(); } else if (schemaFile.isDirectory()) { schemaRoot = schemaFile; @@ -358,15 +373,6 @@ private Map getSchemaMap() { return schemaMap; } - private void validatePubSub(String instName) { - String registryId = getRegistryId(); - String updateTopic = cloudIotManager.getUpdateTopic(); - client = new PubSubClient(config.project_id, registryId, instName, updateTopic); - if (updateTopic != null) { - dataSinks.add(client); - } - } - private String getRegistryId() { return config.registry_id; } @@ -383,7 +389,9 @@ void messageLoop() { return; } sendInitializationQuery(); + System.err.println("Running udmi tools version " + UDMI_TOOLS); System.err.println("Entering message loop on " + client.getSubscriptionId()); + processValidationReport(); ScheduledFuture reportSender = simulatedMessages ? null : executor.scheduleAtFixedRate(this::processValidationReport, REPORT_INTERVAL_SEC, REPORT_INTERVAL_SEC, TimeUnit.SECONDS); @@ -743,6 +751,8 @@ private ValidationState makeValidationReport(ValidationSummary summary, report.timestamp = new Date(); report.summary = summary; report.devices = devices; + report.tools = UDMI_TOOLS; + report.start_time = START_TIME; return report; } diff --git a/validator/traces/simple.out/validation_report.json b/validator/traces/simple.out/validation_report.json index 37c283d1b..c95d34023 100644 --- a/validator/traces/simple.out/validation_report.json +++ b/validator/traces/simple.out/validation_report.json @@ -1,6 +1,8 @@ { "timestamp" : "1999-10-20T01:02:03Z", "version" : "1.4.0", + "tools" : "test_trace", + "start_time" : "1999-10-20T01:02:03Z", "summary" : { "correct_devices" : [ "AHU-1", "GAT-123" ], "extra_devices" : [ ],