Skip to content

Commit

Permalink
Squashed commit
Browse files Browse the repository at this point in the history
  • Loading branch information
grafnu committed Apr 7, 2024
1 parent 027aa8f commit e1ee0f0
Show file tree
Hide file tree
Showing 31 changed files with 353 additions and 533 deletions.
1 change: 1 addition & 0 deletions bin/diagnoser
110 changes: 0 additions & 110 deletions bin/registrar

This file was deleted.

1 change: 1 addition & 0 deletions bin/registrar
2 changes: 1 addition & 1 deletion bin/run_tests
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function test_wrap {
}

case "$1" in
install_dependencies)
install_dependencies)
sudo true # Proactively update before test_wrap is called.
test_wrap bin/setup_base
test_wrap bin/clone_model
Expand Down
15 changes: 11 additions & 4 deletions bin/support
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@ echo Copying cached config files to $OUT_DIR/
cp $CONFIG_FILES $OUT_DIR/ || true

site_model=
for config in $CONFIG_FILES; do
if [[ -f $config && -z $site_model ]]; then
site_model=$(jq -r .site_model $config)
site_model=$(realpath --relative-to=$PWD $site_model)
config_files=$(ls -t $OUT_DIR/*_config.json)
for config in $config_files; do
site_model=$(jq -r .site_model $config)
site_model=$(realpath --relative-to=$PWD $site_model)
if [[ $site_model != null ]]; then
echo Using site_model $site_model from cached $config
break
fi
done

if [[ $site_model == null ]]; then
echo Could not determine site_model from recent configs.
site_model=
fi

if [[ -n $UDMI_REGISTRY_SUFFIX && -n $site_model ]]; then
echo Relocating $site_model to $site_model${UDMI_REGISTRY_SUFFIX}
mv $site_model $site_model${UDMI_REGISTRY_SUFFIX}
Expand Down
33 changes: 14 additions & 19 deletions bin/test_regclean
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ project_id=$1
shift

[[ -n $GITHUB_RUN_NUMBER ]] && echo "Workflow run number $GITHUB_RUN_NUMBER" || true
echo "Run as: $0 $project_id"
echo "export TARGET_PROJECT=$TARGET_PROJECT"
echo "export UDMI_REGISTRY_SUFFIX=$UDMI_REGISTRY_SUFFIX"
echo "export UDMI_ALT_REGISTRY=$UDMI_ALT_REGISTRY"
Expand All @@ -47,15 +46,16 @@ mkdir -p out
if [[ -n $UDMI_REGISTRY_SUFFIX ]]; then
echo Using registry suffix $UDMI_REGISTRY_SUFFIX
registry_suffix=$UDMI_REGISTRY_SUFFIX
registry_arg="-e $UDMI_REGISTRY_SUFFIX"
else
registry_suffix=
registry_arg=
fi

registry_id=`jq -r .registry_id $site_path/cloud_iot_config.json`
cloud_region=`jq -r .cloud_region $site_path/cloud_iot_config.json`

site_arg=$site_path
registrar_project=$project_id
site_args="$site_path $project_id $registry_arg"

registry_prefix=
project_target=${project_id##*/}
Expand Down Expand Up @@ -113,8 +113,8 @@ rm -rf $fake_device && cp -a $clone_device $fake_device
jq ".localnet.families.vendor.addr = \"2183213\"" $fake_metadata | sponge $fake_metadata

echo Clean out the registry to make sure devices get removed...
echo bin/registrar $site_arg $registrar_project -d -x
bin/registrar $site_arg $registrar_project -d -x
echo bin/registrar $site_args -d -x
bin/registrar $site_args -d -x

echo Checking reported cloud version info
jq .cloud_version.udmi_ref $output_file
Expand All @@ -127,12 +127,12 @@ echo pubber/bin/run $pubber_config
! pubber/bin/run $pubber_config

echo Now recreate the registry from scratch!
echo bin/registrar $site_arg $registrar_project
bin/registrar $site_arg $registrar_project
echo bin/registrar $site_args
bin/registrar $site_args

echo Remove fake device from site model, so it will be blocked
rm -rf $fake_device
bin/registrar $site_arg $registrar_project -b
bin/registrar $site_args -b

echo Check $device_id again, but this time with success...
echo pubber/bin/run $pubber_config
Expand All @@ -156,16 +156,16 @@ sns_line=`fgrep -n SNS-4 sites/udmi_site_model/out/registration_summary.csv | cu

if [[ -n $solo_arg ]]; then
echo Deleting singular entry $solo_arg...
echo bin/registrar $site_arg $registrar_project -d $solo_arg
bin/registrar $site_arg $registrar_project -d $solo_arg
echo bin/registrar $site_args -d $solo_arg
bin/registrar $site_args -d $solo_arg
search "Deleting device $solo_arg \(1/1)" out/registrar.log
search "Deleted 1 devices" out/registrar.log

echo Sleeping to avoid IoT Core race condition...
sleep 20

echo bin/registrar /tmp/registrar_config.json $solo_arg
bin/registrar /tmp/registrar_config.json $solo_arg
echo bin/registrar $site_args $solo_arg
bin/registrar $site_args $solo_arg

echo Checking creation of one device
search "Processing 1 new devices..." out/registrar.log
Expand All @@ -178,13 +178,8 @@ fi

if [[ -n $UDMI_ALT_REGISTRY ]]; then
echo Registering alt registry $UDMI_ALT_REGISTRY...
site_file=$site_arg/cloud_iot_config.json
cp $site_file $site_file-tmp
jq ".registry_id = \"$UDMI_ALT_REGISTRY\"" $site_file-tmp > $site_file
echo bin/registrar $site_arg $registrar_project -u
bin/registrar $site_arg $registrar_project -u
mv $site_file-tmp $site_file
echo Done with registering alt registry
echo bin/registrar $site_args -a $UDMI_ALT_REGISTRY
bin/registrar $site_args -a $UDMI_ALT_REGISTRY
fi

echo Done with successful registry clean/create test
7 changes: 4 additions & 3 deletions bin/test_sites
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ shift $((OPTIND-1))

function redact_files {
for file in $@; do
if [[ $(basename $file) == exceptions.txt ]]; then
rm $file
continue
fi
sed -E -i \
-e 's-oading .*udmi/tests/-REDACTED/-' \
-e 's/at .*main\(.*\.java:[0-9]+\)/REDACTED/' \
-e '/at .*\(.*\.java:[0-9]+\)/d' \
-e '/\.\.\. [0-9]+ more/d' \
$file
done
}
Expand Down
17 changes: 17 additions & 0 deletions bin/toolrun
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -e

util_name=$(basename $0)
UDMI_ROOT=$(realpath $(dirname $0)/..)

source $UDMI_ROOT/etc/shell_common.sh

OUT_DIR=$UDMI_ROOT/out
mkdir -p $OUT_DIR
rm -f $OUT_DIR/$util_name.log

$UDMI_ROOT/validator/bin/build

JAVA_CLASS=com.google.daq.mqtt.util.Dispatcher

echo java -cp $UDMI_JAR $JAVA_CLASS $util_name "$@"
java -cp $UDMI_JAR $JAVA_CLASS $util_name "$@" 2>&1 | tee $OUT_DIR/$util_name.log
25 changes: 0 additions & 25 deletions bin/udmi

This file was deleted.

6 changes: 0 additions & 6 deletions bin/udmi-locate

This file was deleted.

12 changes: 0 additions & 12 deletions bin/udmi-pubber

This file was deleted.

60 changes: 0 additions & 60 deletions bin/udmi-validate

This file was deleted.

Loading

0 comments on commit e1ee0f0

Please sign in to comment.