Skip to content

Commit

Permalink
Promote set of sequencer tests (#786)
Browse files Browse the repository at this point in the history
  • Loading branch information
noursaidi authored Dec 19, 2023
1 parent 769bae3 commit 30318f4
Show file tree
Hide file tree
Showing 321 changed files with 24,199 additions and 23,287 deletions.
3 changes: 2 additions & 1 deletion .wordlist.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
acked
addr
AHU
anagement
api
Expand Down Expand Up @@ -81,6 +82,7 @@ kube
kubectl
Kubernetes
localhost
localnet
logentry
loglevel
macos
Expand Down Expand Up @@ -163,4 +165,3 @@ validator
writeback
Writeback
yaml
localnet
30 changes: 18 additions & 12 deletions bin/sequencer_cache
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ if [[ -n $validate_archive ]]; then
| xargs -I% diff -u \
$TEST_ROOT/tests/%/sequence.md \
$ARCHIVE_ROOT/%/sequence.md
echo Verification successful
echo Verification successful
fi

if [[ -n $import_cache ]]; then
Expand All @@ -141,17 +141,23 @@ if [[ -n $import_cache ]]; then
TMP_DIR=/tmp/import_cache
rm -rf $TMP_DIR && mkdir -p $TMP_DIR

SEQUENCER_OUT=$(zipinfo -1 $github_artifact | grep sequencer)
unzip -p $github_artifact $SEQUENCER_OUT | tar -zxC $TMP_DIR
while read -r zipfile ; do
mkdir -p $TMP_DIR/$zipfile
unzip -p $github_artifact $zipfile | tar -zxC $TMP_DIR/$zipfile
# there is one site model which is udmi_site_model-{prefix}
unzip_path="$TMP_DIR/$zipfile"
site_model_dir=$(ls -1 $unzip_path/sites| head -n 1)
import_dir="$unzip_path/sites/$site_model_dir/out-seq/devices/AHU-1/tests"
for directory in $import_dir/* ; do
test_name=$(basename "$directory")
if ! diff "$directory/sequence.md" "$CACHE_ROOT/$test_name/sequence.md" >/dev/null 2>&1; then
echo Updating $test_name from $zipfile
rm -rf "$CACHE_ROOT/$test_name/"
cp -r "$directory" "$CACHE_ROOT/$test_name"
fi
done
done < <(zipinfo -1 $github_artifact | grep sequencer)
exit
IMPORT_DIR="$TMP_DIR/$TEST_ROOT/tests"

for directory in $IMPORT_DIR/* ; do
test_name=$(basename "$directory")
if ! diff "$IMPORT_DIR/$test_name/sequence.md" "$CACHE_ROOT/$test_name/sequence.md" >/dev/null 2>&1; then
echo Updating $test_name
rm -rf "$CACHE_ROOT/$test_name/"
cp -r "$IMPORT_DIR/$test_name" "$CACHE_ROOT/$test_name"
fi
done
echo Completed update
fi
4 changes: 2 additions & 2 deletions bin/stream_device_messages
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ print(f'Subscribing to messages from'

while True:
try:
future.result(timeout=5)
except (futures.CancelledError, KeyboardInterrupt, futures.TimeoutError):
future.result()
except (futures.CancelledError, KeyboardInterrupt):
future.cancel()
future.result()
break
Expand Down
2 changes: 1 addition & 1 deletion bin/test_sequcheck
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ mv out/generated.tmp $UDMI_ROOT/docs/specs/sequences/generated.md
echo Comparing diff out/generated.out docs/specs/sequences/generated.md
diff -u out/generated.out $UDMI_ROOT/docs/specs/sequences/generated.md || failures+="gencode_seq "

SAMPLE_TEST_ROW="| system | system_min_loglevel | alpha | pass | Sequence complete |"
SAMPLE_TEST_ROW="| writeback | writeback_failure | 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"
Expand Down
21 changes: 13 additions & 8 deletions bin/test_sequencer_report
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env python3
""" Unit testing for sequence report generator """
import unittest
from importlib import util, machinery
"""Unit testing for sequence report generator"""
from dataclasses import dataclass
from importlib import machinery, util
import unittest

spec = util.spec_from_loader(
"sequence_report",
"sequence_report",
machinery.SourceFileLoader("sequence_report", "bin/sequencer_report"),
)
seq = util.module_from_spec(spec)
Expand Down Expand Up @@ -78,21 +78,22 @@ check enumeration of nothing at all
1. Wait for matching enumeration generation
"""

EMPTY_SEQUENCE="""
EMPTY_SEQUENCE = """
## multi_enumeration (ALPHA)
check enumeration of multiple categories
"""


@dataclass
class SampleTestResult:
result: str = "fail"
name: str = "extra_config"


class TestSequencerReport(unittest.TestCase):
""" Unit tests for sequence report generation """
"""Unit tests for sequence report generation"""

def test_sequence_get_steps(self):
steps = seq.Sequence.get_steps(SAMPLE_SEQUENCE)
Expand Down Expand Up @@ -143,9 +144,13 @@ class TestSequencerReport(unittest.TestCase):
["1. Step 1"],
["1. Multistep 2", " * line a", " * line b"],
["1. Step 3"],
["1. Step 4"]
["1. Step 4"],
]
act = [
["1. Step 1"],
["1. Multistep 2", " * line a", " * line b"],
["1. Step 3"],
]
act = [["1. Step 1"], ["1. Multistep 2", " * line a", " * line b"], ["1. Step 3"]]

formatted = seq.Sequence.format(ref, act, SampleTestResult())
print(formatted)
Expand Down
159 changes: 0 additions & 159 deletions bin/test_sequencer_report.py

This file was deleted.

Loading

0 comments on commit 30318f4

Please sign in to comment.