Skip to content

Commit

Permalink
Add base gateway sequence test (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
grafnu committed Nov 9, 2023
1 parent af05eed commit 2fb77e8
Show file tree
Hide file tree
Showing 29 changed files with 362 additions and 205 deletions.
6 changes: 3 additions & 3 deletions .gencode_hash.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ d40bfc9f4a30c56986435dc08f1e5f42401e5ac043359a1e359011c913cad673 gencode/docs/c
08583688b20f892c0b453f41787ac01a46ac601663736bcd6ed6f57be0758e79 gencode/docs/configuration_endpoint.html
6cf94d6cb600c75cde32a64bd78acb3ed3b54adfad08dbf6bb159b467e8925c9 gencode/docs/configuration_execution.html
d0f6ea11943f46c955891b3b49a25a9bffcf558fcabb9ed2b0f7667d8413953b gencode/docs/configuration_pod.html
1f00351201985451aaa1a3e3247fc138b8bea7943b801c18cd5618f7600c872d gencode/docs/configuration_pubber.html
26d2fe3ecc9f95dff52cdd9eae3be621886ef264305f31f64aa8f254e7ffbf99 gencode/docs/configuration_pubber.html
96186777da06f95eae1d16d73555445d23608a9301636ea1ccd17922b3fe4019 gencode/docs/event.html
587e048c161273b927de67b899204bf0e183db64e59ae513f833e5eff406b1ab gencode/docs/event_discovery.html
0f99534574718e07e655e33e76e06b56e6a96a7a42ae1457dc97dabc581d848f gencode/docs/event_mapping.html
Expand Down Expand Up @@ -99,7 +99,7 @@ fc3a9415c04d8a06954dbdbfdff5d68ab113cce3948532c19df555778ffb04fa gencode/java/u
ca2e7566106818ca7e5190c8041eb86f0c9b3251b0bda8c3ea7ce11a0c891a0a gencode/java/udmi/schema/Position.java
3df66bb1a37a9e0b2b6cf392f8c64d404a73c83e5e13c02bb4844f09b9a04b70 gencode/java/udmi/schema/Properties.java
d5e11dc354995681b894bcb62e4e21da7f0be68aaa3643a3dc5aa13610741f29 gencode/java/udmi/schema/PubberConfiguration.java
3583ac57d4e5e7e0fc01081bf08cae368c4b90cdb4b337c4a72bc3e69c26046e gencode/java/udmi/schema/PubberOptions.java
3575b20afc5e1b38f0ac34799968270b301c3320915bd74b607e02d45c9e6eb4 gencode/java/udmi/schema/PubberOptions.java
703ed0cecb60f284b52e76dc4d612eb798ba3e8781cc40698a46611b36e6b0c9 gencode/java/udmi/schema/SchemaValidationState.java
6da1708f597a0c64ce30dcbe739095fc7ebc091d63b98af88c73f70706af31ca gencode/java/udmi/schema/SequenceValidationState.java
9da49b22341a65580d085fd9d00eaadcaefcf7b813988ef844c617aa4b8a9a4f gencode/java/udmi/schema/SetupUdmiConfig.java
Expand Down Expand Up @@ -182,7 +182,7 @@ b48ae013d203eb31cc388a084c0cc6f93d4d5534336d4da2ecbccd84a085ea2b gencode/python
5c50847e136a033ea511209238bb570499b43fbee6189dae06603132dcb9f01f gencode/python/udmi/schema/model_testing_target.py
7c9a755ae06c44fc2b8117d7918b6401ce08a7218b86033fb3320eda7286e581 gencode/python/udmi/schema/monitoring.py
3a3873c7db8d5fa13b43629031d36417a4ec4838d612a7b8c2fce7c22fdee009 gencode/python/udmi/schema/monitoring_metric.py
f32079e2cef51f6bcd8aeee3febf2af6aa177714ce7cdfe7164be6d776a866a8 gencode/python/udmi/schema/options_pubber.py
47feb547b1630546bfa7ed5a8de1c708f0f769b42fe1aac35f4b1cdacda865eb gencode/python/udmi/schema/options_pubber.py
6c5f3dd1c5ca9d821e3c48298af118fc7eafd97af9265dfd34b2ed8642efca77 gencode/python/udmi/schema/persistent_device.py
a58f8c98e837a5b56126ca0f410e02f1e9cfcd80a8cb429e0ef522defab1f690 gencode/python/udmi/schema/properties.py
e604cf0280fe772de5f4e5ecf10dc6c564b6177eeff9cd9fb8b385af8fe10a95 gencode/python/udmi/schema/state.py
Expand Down
20 changes: 12 additions & 8 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ jobs:
strategy:
fail-fast: false
matrix:
shard: [0, 1, 2, 3, 4, 5, 6, 7]
shard: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
if: vars.TARGET_PROJECT != ''
env:
TARGET_PROJECT: ${{ vars.TARGET_PROJECT }}
UDMI_ALT_REGISTRY: ZZ-REDIRECT-NA
UDMI_REGISTRY_SUFFIX: _${{ matrix.shard }}
MATRIX_SHARD_COUNT: 8
MATRIX_SHARD_COUNT: 10
MATRIX_SHARD_INDEX: ${{ matrix.shard }}
steps:
- uses: actions/checkout@v3
Expand All @@ -149,23 +149,25 @@ jobs:
run: bin/test_sequencer clean nocheck $TARGET_PROJECT
- name: sequence tests alpha
run: bin/test_sequencer alpha nocheck $TARGET_PROJECT
- name: sequence test timing
- name: sequence test post-process
if: ${{ always() }}
run: egrep ' test .* after .*s ' out/sequencer.log.combined
run: egrep ' test .* after .*s ' out/sequencer.log > out/timing_sequencer.out
- name: itemized sequencer tests
run: bin/test_itemized $TARGET_PROJECT
- name: itemized test timing
if: ${{ always() }}
run: egrep ' test .* after .*s ' out/sequencer.log-*
- name: output files
if: ${{ always() }}
run: more out/*.out* | cat
- name: pubber logs
if: ${{ always() }}
run: more out/pubber.log* pubber/out/*.json | cat
- name: itemized test post-process
if: ${{ always() }}
run: egrep ' test .* after .*s ' out/sequencer.log-* > out/timing_itemized.out
- name: support bundle
if: ${{ always() }}
run: bin/support ${{ github.repository_owner }}_${{ github.job }}_
run: |
ls -lrt out*/ sites/udmi_site_model/out*/
bin/support ${{ github.repository_owner }}_${{ github.job }}_
- uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
Expand Down Expand Up @@ -277,3 +279,5 @@ jobs:
find out* -name 'schema*.out*' -size +0 | xargs more | cat
- name: Sequencer validation
run: bin/test_sequcheck
- name: Itemized validation
run: bin/test_itemcheck
11 changes: 9 additions & 2 deletions bin/support_process
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@ elif [[ ! -d $archive ]]; then
fi

ls -l $archive_dir/
echo Extracting test archives...
ls $archive_dir/*sequencer*.tgz | xargs -n 1 tar -xzf

find $sites_in -name out-seq -print -exec rsync -ah {}/ $sites_out/ \;
echo Consolidating device tests...
devices=$(ls -d $sites_in/out-seq/devices)
for devices_dir in $devices; do
rsync -ah $devices_dir/ $sites_out/devices/
done

src_count=$(find $sites_in/out-seq -name sequence.md | wc -l)
dst_count=$(find $sites_out -name sequence.md | wc -l)
Expand All @@ -52,7 +57,9 @@ fi
echo Restored $dst_count test output files to $sites_out

cat out_*/sequencer.out.combined | sort -k 4 > out/sequencer.out
cat out_*/schema.out.combined | sort -k 4 | uniq > out/schema.out
cat out_*/schema.out.combined | fgrep RESULT | sort -k 4 | uniq > out/schema.out
cat out_*/test_itemized.out | sort -k 4 > out/test_itemized.out
cat out_*/schema_itemized.out | sort | uniq > out/schema_itemized.out

echo Restored combined schema.out files.

Expand Down
15 changes: 15 additions & 0 deletions bin/test_itemcheck
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash -e

ROOT_DIR=$(dirname $0)/..
cd $ROOT_DIR

RESULTS_OUT=out/test_itemized.out
GOLDEN_FILE=etc/test_itemized.out
SCHEMA_OUT=out/schema_itemized.out
GOLDEN_SCHEMAS=etc/schema_itemized.out

echo Comparing diff $RESULTS_OUT $GOLDEN_FILE
diff -bu $RESULTS_OUT $GOLDEN_FILE

echo Comparing diff $SCHEMA_OUT $GOLDEN_SCHEMAS
diff -bu $SCHEMA_OUT $GOLDEN_SCHEMAS
56 changes: 28 additions & 28 deletions bin/test_itemized
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ DEVICE_ID=AHU-1
seq_opts=-v
serial_no=sequencer-$RANDOM

PUBBER_LOG=out/pubber.log
SEQUENCER_LOG=out/sequencer.log
SEQUENCER_OUT=out/sequencer.out
INPUT_FILE=etc/test_itemized.in
RESULTS_OUT=out/test_itemized.out
GOLDEN_FILE=etc/test_itemized.out
SCHEMA_OUT=out/schema_itemized.out
SCHEMA_ITEMIZED=out/schema_itemized.out
GOLDEN_SCHEMAS=etc/schema_itemized.out
AUGMENT_OPTS=out/augment_opts.txt

rm -rf out/*_itemized.out
mkdir -p out
echo > $AUGMENT_OPTS

Expand All @@ -38,17 +36,24 @@ echo "export MATRIX_SHARD_INDEX=$MATRIX_SHARD_INDEX"
pubber/bin/build
validator/bin/build

test_index=-1
test_index=0
while read -u 7 action test_name pubber_opts; do
rm -f $RESULTS_OUT $SEQUENCER_OUT $PUBBER_LOG $SCHEMA_OUT $SEQUENCER_LOG
mkdir -p out
test_marker=$(printf %02d $test_index)
((test_index++)) || true

PUBBER_LOG=out/pubber.log-$test_marker
SEQUENCER_LOG=out/sequencer.log
SEQUENCER_OUT=out/sequencer.out
SCHEMA_OUT=out/schema.out

if [[ $action == TEST && -n $TARGET_TEST && $TARGET_TEST != $test_name ]]; then
continue
fi

if [[ $action == WITH ]]; then
echo $test_name $pubber_opts > $AUGMENT_OPTS
DEVICE_ID=$test_name
echo $pubber_opts > $AUGMENT_OPTS
echo Executing itemized tests as $DEVICE_ID with $pubber_opts
continue
elif [[ -z $action || $action =~ ^# ]]; then
continue
Expand All @@ -57,19 +62,17 @@ while read -u 7 action test_name pubber_opts; do
false
fi

((test_index++)) || true
test_marker=$(printf %02d $test_index)
if [[ -z $MATRIX_SHARD_COUNT || $((test_index % MATRIX_SHARD_COUNT)) == $MATRIX_SHARD_INDEX ]]; then
echo Executing shard test index $test_index
echo Executing $test_name shard test index $test_marker
else
echo Skipping non-shard test index $test_index
echo Skipping $test_name non-shard test index $test_marker
continue
fi

echo itemized test $test_name $pubber_opts [$(< $AUGMENT_OPTS)]

# Clean out the persistant data store to ensure a clean state each time.
rm -rf sites/udmi_site_model/out/devices/AHU-1/persistent_data.json
rm -rf sites/udmi_site_model/out/devices/AHU-1/persistent_data.json $SITE_PATH/out

echo bin/reset_config $SITE_PATH $PROJECT_ID $DEVICE_ID
bin/reset_config $SITE_PATH $PROJECT_ID $DEVICE_ID
Expand Down Expand Up @@ -102,29 +105,26 @@ while read -u 7 action test_name pubber_opts; do
kill $(ps ax | fgrep pubber | fgrep java | awk '{print $1}') || true

result=$(grep -E -m 1 "RESULT [a-z]+ [a-z.]+ $test_name " $SEQUENCER_OUT)
echo $test_marker ${result/* NOTICE RESULT/RESULT} >> $RESULTS_OUT
echo ${result/* NOTICE RESULT/RESULT} >> $RESULTS_OUT

mv $PUBBER_LOG $PUBBER_LOG-$test_marker
mv $SEQUENCER_OUT $SEQUENCER_OUT-$test_marker
mv $SEQUENCER_LOG $SEQUENCER_LOG-$test_marker

echo =========== $test_name >> $SCHEMA_OUT
cat out/schema.out >> $SCHEMA_OUT
mv out/schema.out $SCHEMA_OUT-$test_marker
rm -rf $SITE_PATH/out-$test_marker
mv $SITE_PATH/out $SITE_PATH/out-$test_marker

sleep 2
if [[ -s $SCHEMA_OUT ]]; then
cat $SCHEMA_OUT | sed -e "s/^/$test_name /" >> $SCHEMA_ITEMIZED
else
echo $test_name >> $SCHEMA_ITEMIZED
fi

done 7< $INPUT_FILE

if [[ -z $TARGET_TEST && -z $MATRIX_SHARD_COUNT ]]; then
echo Comparing diff $RESULTS_OUT $GOLDEN_FILE
diff -bu $RESULTS_OUT $GOLDEN_FILE

echo Comparing diff $SCHEMA_OUT $GOLDEN_SCHEMAS
uniq < $SCHEMA_OUT | sponge $SCHEMA_OUT
diff -bu $SCHEMA_OUT $GOLDEN_SCHEMAS
bin/test_itemcheck
else
echo Archiving $SITE_PATH/out to $SITE_PATH/out-itm
rm -rf $SITE_PATH/out-itm/
mv $SITE_PATH/out/ $SITE_PATH/out-itm/
echo Skipping item checks
fi

echo Done with itemized test run.
13 changes: 10 additions & 3 deletions bin/test_sequcheck
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
suffix=$1
shift || true

UDMI_ROOT=$(dirname $0)/..
cd $UDMI_ROOT

source $UDMI_ROOT/etc/shell_common.sh

if [[ -z $suffix ]]; then
bin/sequencer_cache -t
fi
Expand All @@ -24,9 +29,11 @@ diff -u out/generated.tmp docs/specs/sequences/generated.md || (
false
)

SAMPLE_TEST_ROW="| discovery.scan | single_scan | alpha | pass | Sequence complete |"
echo Checking for expected entry in generated results.md
fgrep "$SAMPLE_TEST_ROW" sites/udmi_site_model/out/devices/AHU-1/results.md
SAMPLE_TEST_ROW="| system | system_min_loglevel | alpha | pass | Sequence complete |"
target=sites/udmi_site_model/out/devices/AHU-1/results.md
echo Checking for expected entry in $target:
echo "$SAMPLE_TEST_ROW"
fgrep "$SAMPLE_TEST_ROW" $target || fail expected line not found

echo Checking for duplication in out/sequencer.out and etc/sequencer_planning.txt
bin/test_sequencer_plan
Expand Down
37 changes: 17 additions & 20 deletions bin/test_sequencer
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ echo "export MATRIX_SHARD_INDEX=$MATRIX_SHARD_INDEX"

site_path=sites/udmi_site_model
device_id=AHU-1
output_file=$site_path/out/sequencer_$device_id.json
device_out_base=$site_path/out/devices/$device_id
test_out_base=$device_out_base/tests
site_out=$site_path/out
output_file=$site_out/sequencer_$device_id.json
device_out_base=$site_out/devices/$device_id
tests_out_base=$device_out_base/tests

if [[ -n $clean_cache ]]; then
echo Cleaning out/ $test_out_base/
rm -rf out/ $test_out_base/
rm -rf out/ $site_path/out-seq $site_out
fi

mkdir -p $test_out_base out/
mkdir -p out/ $tests_out_base/

serial_no=sequencer-$RANDOM
echo Using pubber with serial $serial_no
Expand All @@ -84,7 +84,7 @@ bin/clone_model # Clone, and check that version is correct.
bin/reset_config $site_path $project_id $device_id

# Clean out the persistant data store to ensure a clean state each time.
rm -rf $site_path/out/devices/${device_id}/persistent_data.json
rm -rf $site_out/devices/${device_id}/persistent_data.json

pubber/bin/build

Expand Down Expand Up @@ -128,13 +128,14 @@ else
fi

echo Combining partial-run output files...
ls -l out/schema.out out/sequencer.log

cat out/schema.out >> out/schema.out.combined
cat out/sequencer.log >> out/sequencer.log.combined
cat out/sequencer.out >> out/sequencer.out.combined
echo Combined to:
ls -l out/schema.out.combined out/sequencer.log.combined || true
ls -l out
files=$(cd out; ls -1 *.out *.log)
echo Merging $files
for file in $files; do
cat out/$file >> out/$file.combined
cp out/$file.combined out/$file
done
ls -l out

if [[ -n $out_check ]]; then
if [[ -n $clean_cache ]]; then
Expand All @@ -144,12 +145,8 @@ if [[ -n $out_check ]]; then

bin/test_sequcheck $suffix
else
if [[ -n $clean_cache ]]; then
echo Cleaning sequencer out archive...
rm -rf $site_path/out-seq
fi

echo Archiving $site_path/out to $site_path/out-seq
echo Preparing stuff for shard reconcilliation
mkdir -p $site_path/out-seq
rsync -ah $site_path/out/ $site_path/out-seq/
rm -rf $site_path/out
fi
Expand Down
4 changes: 2 additions & 2 deletions common/src/main/java/com/google/udmi/util/Common.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.google.udmi.util;

import static com.google.udmi.util.GeneralUtils.stackTraceString;
import static java.util.Optional.ofNullable;

import com.google.common.base.Function;
import com.google.common.base.Joiner;
Expand Down Expand Up @@ -38,7 +37,8 @@ public abstract class Common {
public static final String SUBFOLDER_PROPERTY_KEY = "subFolder";
public static final String PROJECT_ID_PROPERTY_KEY = "projectId";
public static final String REGISTRY_ID_PROPERTY_KEY = "deviceRegistryId";
public static final String DEVICE_ID_PROPERTY_KEY = "deviceId";
public static final String DEVICE_ID_KEY = "deviceId";
public static final String GATEWAY_ID_KEY = "gatewayId";
public static final String MESSAGE_SOURCE_PROPERTY_KEY = "source";
public static final String NO_SITE = "--";
public static final String GCP_REFLECT_KEY_PKCS8 = "reflector/rsa_private.pkcs8";
Expand Down
Loading

0 comments on commit 2fb77e8

Please sign in to comment.