Skip to content
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

Adding docker-based integration test #940

Merged
merged 84 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
ea1a415
Basic testing infrastructure
grafnu Jul 22, 2024
83f8298
Some basic testing stuff
grafnu Jul 22, 2024
84cb0de
Working deviceID test
grafnu Jul 23, 2024
5a24c0a
Adding device allowable tests
grafnu Jul 23, 2024
0842ec2
Add comments
grafnu Jul 23, 2024
abfd7a1
Fix pointname checks
grafnu Jul 23, 2024
101662e
Adding expected files
grafnu Jul 23, 2024
fedd460
Better refactoring
grafnu Jul 23, 2024
ae9d0d5
Fixing hard failures
grafnu Jul 23, 2024
f726838
Corner case handling
grafnu Jul 23, 2024
2a16158
Add unit test cleanup
grafnu Jul 23, 2024
791bd1b
Minor variable rename
grafnu Jul 23, 2024
ce78d53
Cleanup extra files
grafnu Jul 23, 2024
a256d78
Minor cleanup of etcd dir
grafnu Jul 23, 2024
5d36f0d
Adjusting regex
grafnu Jul 24, 2024
fc91630
Cleanup validator docker image
grafnu Jul 24, 2024
d84b7ee
Remove swarm
grafnu Jul 24, 2024
4f2244c
Merge remote-tracking branch 'faucet/master' into udmil
grafnu Jul 24, 2024
8de53eb
Merge branch 'master' into udmil
grafnu Jul 24, 2024
52e32ee
Adding workflow
grafnu Jul 24, 2024
cda9eb4
Remove pretest
grafnu Jul 24, 2024
85ade0a
Add missing jobs:
grafnu Jul 24, 2024
222b1ba
Fix workflow name
grafnu Jul 24, 2024
78ce6c0
Fix regex unit tests
grafnu Jul 24, 2024
f54051e
Build on tag push only
grafnu Jul 26, 2024
690d3a0
Ignore tag push
grafnu Jul 26, 2024
15dd83e
Don't push tags
grafnu Jul 26, 2024
ed32c5a
empty commit
grafnu Jul 26, 2024
54f204b
Fixing push logic
grafnu Jul 26, 2024
6704d07
Updating container build
grafnu Jul 26, 2024
3894f1a
Updating integration tag
grafnu Jul 26, 2024
56a24be
Updating integration tag
grafnu Jul 26, 2024
b564fe4
Updating integration tag
grafnu Jul 26, 2024
f621431
Updating integration tag
grafnu Jul 26, 2024
b49857b
Updating integration tag
grafnu Jul 26, 2024
56826e2
Updating integration tag
grafnu Jul 26, 2024
2bf7d9e
List built images
grafnu Jul 26, 2024
059e604
Updating integration tag
grafnu Jul 26, 2024
3d44bbd
Use more standard revhash
grafnu Jul 26, 2024
9e4fb97
Updating integration tag
grafnu Jul 26, 2024
581ddd9
Updating integration tag
grafnu Jul 26, 2024
9fd422a
Updating integration tag
grafnu Jul 26, 2024
0cc9559
Updating integration tag
grafnu Jul 26, 2024
a143042
Updating integration tag
grafnu Jul 26, 2024
1a14380
Updating integration tag
grafnu Jul 26, 2024
3638988
Improving startup process
grafnu Jul 26, 2024
022f0c6
Updating integration tag
grafnu Jul 26, 2024
2eb1933
Fixing test
grafnu Jul 26, 2024
668cddb
Updating integration tag
grafnu Jul 26, 2024
ee2541e
Debug
grafnu Jul 26, 2024
7a12ac4
Updating integration tag
grafnu Jul 26, 2024
c921e5f
Updating integration tag
grafnu Jul 26, 2024
519cc24
Updating integration tag
grafnu Jul 26, 2024
d75cd7c
Updating integration tag
grafnu Jul 26, 2024
0bfb2b6
Updating integration tag
grafnu Jul 26, 2024
e7eb3f7
Updating integration tag
grafnu Jul 26, 2024
92b59a3
Updating integration tag
grafnu Jul 26, 2024
25e9afe
Updating integration tag
grafnu Jul 26, 2024
e89082a
Updating integration tag
grafnu Jul 29, 2024
79c7971
Updating integration tag
grafnu Jul 29, 2024
2f0996e
Updating integration tag
grafnu Jul 29, 2024
8e9fdbf
Updating integration tag
grafnu Jul 29, 2024
e64fc40
Merge branch 'master' into udmil
grafnu Jul 29, 2024
d75121f
Merge remote-tracking branch 'faucet/master' into udmil
grafnu Jul 29, 2024
90ae8dd
Updating integration tag
grafnu Jul 29, 2024
221b75a
Updating integration tag
grafnu Jul 29, 2024
3532ff0
Updating integration tag
grafnu Jul 29, 2024
6028af3
Updating integration tag
grafnu Jul 29, 2024
4d43a50
Trying to fix start_local for previous use cases
grafnu Jul 29, 2024
ae35e51
Updating integration tag
grafnu Jul 29, 2024
2bb051c
Revert start_local call format
grafnu Jul 29, 2024
bbccceb
Updating integration tag
grafnu Jul 29, 2024
fe94642
Updating integration tag
grafnu Jul 29, 2024
fd17c7e
Updating integration tag
grafnu Jul 29, 2024
c24bf63
Updating integration tag
grafnu Jul 29, 2024
12ccc49
Updating integration tag
grafnu Jul 29, 2024
52e4956
Updating integration tag
grafnu Jul 29, 2024
1648958
Updating integration tag
grafnu Jul 29, 2024
3d727fd
Updating integration tag
grafnu Jul 29, 2024
0ab5a8b
Updating integration tag
grafnu Jul 29, 2024
c92b234
Updating integration tag
grafnu Jul 29, 2024
831b770
Updating integration tag
grafnu Jul 29, 2024
d826733
Updating integration tag
grafnu Jul 29, 2024
2a93c25
Updating integration tag
grafnu Jul 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 153 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
name: UDMI Integration Suite

on:
push:
tags:
- '**'
workflow_dispatch:

concurrency:
group: it-${{ github.repository }}
cancel-in-progress: true

jobs:
images:
name: Build Docker Images
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
timeout-minutes: 5
strategy:
fail-fast: false
matrix:
container: [ "udmis", "validator", "pubber" ]
env:
PUSH_REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
CONTAINER: ${{ matrix.container }}
REF_NAME: ${{ github.ref_name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Log in to the github registry
uses: docker/login-action@v3
with:
registry: ${{ env.PUSH_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Container build and push
run: |
revhash=$(git log -n 1 --pretty=format:"%h")
IMAGE_HASH=g${revhash:0:8}
PUSH_REPO=$PUSH_REGISTRY/${IMAGE_NAME,,}

TAG_BASE=$PUSH_REPO:$CONTAINER
PUSH_TAG=${TAG_BASE}-$IMAGE_HASH
echo PUSH_TAG=$PUSH_TAG >> $GITHUB_ENV

bin/clone_model
$CONTAINER/bin/build check
bin/container $CONTAINER push --no-check $PUSH_TAG

docker tag $CONTAINER:latest $TAG_BASE-latest
docker push $TAG_BASE-latest
docker tag $CONTAINER:latest $TAG_BASE-$REF_NAME
docker push $TAG_BASE-$REF_NAME

echo Pushed built $CONTAINER container as $PUSH_TAG | tee -a $GITHUB_STEP_SUMMARY
- name: Docker images summary
run: |
docker images
echo
docker history $PUSH_TAG
simple:
name: Simple sequence test
runs-on: ubuntu-latest
timeout-minutes: 5
needs: images
env:
IMAGE_NAME: ${{ github.repository }}
REF_NAME: ${{ github.ref_name }}
steps:
- name: Setup Environment
run: |
git clone https://github.com/faucetsdn/udmi_site_model.git
ln -s udmi_site_model/ site_model
docker network create udminet --subnet 192.168.99.0/24
- name: Start UDMIS container
run: |
cat udmi_site_model/cloud_iot_config.json
docker run -d --net udminet --name udmis -p 8883:8883 \
-v $(realpath site_model):/root/site_model \
-v $PWD/var/tmp:/tmp \
-v $PWD/var/etcd:/root/udmi/var/etcd \
-v $PWD/var/mosquitto:/etc/mosquitto \
ghcr.io/$IMAGE_NAME:udmis-$REF_NAME udmi/bin/start_local block site_model/cloud_iot_config.json
for count in `seq 0 30`; do
echo Waiting for UDMIS startup $((30 - count))
[[ ! -f var/tmp/pod_ready.txt ]] || break
(docker ps | fgrep -q udmis) || break
sleep 1
done
ls -l var/tmp/pod_ready.txt 2>&1
- name: Registrar run
run: |
docker run --net udminet --name registrar -v $(realpath site_model):/root/site_model \
ghcr.io/$IMAGE_NAME:validator-$REF_NAME bin/registrar site_model/cloud_iot_config.json
- name: Pubber background run
run: |
echo docker run -d --net udminet --name pubber -v $(realpath site_model):/root/site_model \
ghcr.io/$IMAGE_NAME:pubber-$REF_NAME bin/pubber site_model/cloud_iot_config.json
docker run -d --net udminet --name pubber -v $(realpath site_model):/root/site_model \
ghcr.io/$IMAGE_NAME:pubber-$REF_NAME bin/pubber site_model/cloud_iot_config.json
for count in `seq 0 30`; do
(docker ps | fgrep -q pubber) || break
(docker logs pubber 2>&1 | fgrep -q -v "Connection complete") || break
echo Waiting for pubber startup $((30 - count))...
sleep 1
done
docker logs pubber 2>&1 | fgrep "Connection complete"
- name: Sequencer run
run: |
docker run --net udminet --name sequencer -v $(realpath site_model):/root/site_model \
ghcr.io/$IMAGE_NAME:validator-$REF_NAME bin/sequencer site_model/cloud_iot_config.json \
broken_config extra_config device_config_acked
- name: Sequencer results
run: |
cat site_model/out/devices/AHU-1/results.md
[[ $(cat site_model/out/devices/AHU-1/results.md | fgrep 'stable | pass' | wc -l) == 3 ]]
- name: UDMIS logs
if: ${{ !cancelled() }}
run: docker logs udmis
- name: Registrar logs
if: ${{ !cancelled() }}
run: docker logs registrar
- name: Pubber logs
if: ${{ !cancelled() }}
run: docker logs pubber
- name: Sequencer logs
if: ${{ !cancelled() }}
run: docker logs sequencer

udmif:
name: UDMIF unit tests
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.9.0
- name: Install Angular CLI
run: npm install -g @angular/cli
- name: web tests
run: echo Disabled udmif/web/runTests due to dependency integration problems
- name: api tests
run: echo Disabled udmif/api/runTests due to dependency integration problems
83 changes: 4 additions & 79 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: UDMI test suite
name: UDMI Test Suite

on:
push:
branches:
- '**'
workflow_dispatch:
pull_request:
schedule:
Expand Down Expand Up @@ -61,85 +63,9 @@ jobs:
config_path: .spellcheck.yml
task_name: Markdown

udmif:
name: UDMIF unit tests
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.9.0
- name: Install Angular CLI
run: npm install -g @angular/cli
- name: web tests
run: echo Disabled udmif/web/runTests due to dependency integration problems
- name: api tests
run: echo Disabled udmif/api/runTests due to dependency integration problems

pretest:
name: Pre-test Setup
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
timeout-minutes: 5
if: vars.TARGET_PROJECT != ''
env:
PUSH_REGISTRY: ghcr.io
TARGET_PROJECT: ${{ vars.TARGET_PROJECT }}
UDMI_ALT_REGISTRY: ZZ-REDIRECT-NA
UDMI_UPDATE_UDMIS: ${{ vars.UDMI_UPDATE_UDMIS }}
IMAGE_NAME: ${{ github.repository }}
GITHUB_REF: ${{ github.ref }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: sanity check
run: |
[[ -n $UDMI_ALT_REGISTRY ]]
[[ -n $TARGET_PROJECT ]]
- name: Log in to the github registry
if: ${{ github.event_name == 'push' }}
uses: docker/login-action@v3
with:
registry: ${{ env.PUSH_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup udmis container build
if: ${{ github.event_name == 'push' }}
run: |
revhash=$(git log -n 1 --pretty=format:"%h" udmis)
IMAGE_TAG=U${revhash:0:9}
PUSH_REPO=$PUSH_REGISTRY/${IMAGE_NAME,,}
PUSH_TAG=$PUSH_REPO:udmis-$IMAGE_TAG
echo PUSH_TAG=$PUSH_TAG >> $GITHUB_ENV
bin/container udmis prep --no-check $PUSH_TAG
echo Pushing built container as $PUSH_TAG | tee -a $GITHUB_STEP_SUMMARY
- name: Build and push docker image
if: ${{ github.event_name == 'push' }}
uses: docker/build-push-action@v5
with:
file: udmis/Dockerfile.udmis
context: udmis
push: true
tags: ${{ env.PUSH_TAG }}
- name: Update udmis deployment
if: ${{ env.UDMI_UPDATE_UDMIS != '' }}
run: |
bin/clone_model
bin/update_udmis sites/udmi_site_model/ $TARGET_PROJECT $PUSH_TAG

sequencer:
name: Sequencer Tests
runs-on: ubuntu-latest
needs: pretest
timeout-minutes: 20
strategy:
fail-fast: false
Expand Down Expand Up @@ -203,7 +129,6 @@ jobs:
baseline:
name: Baseline Tests
runs-on: ubuntu-latest
needs: pretest
timeout-minutes: 15
if: vars.TARGET_PROJECT != ''
env:
Expand Down Expand Up @@ -297,7 +222,7 @@ jobs:
redirect:
name: Endpoint Redirection
runs-on: ubuntu-latest
needs: [ pretest, baseline ]
needs: baseline
timeout-minutes: 15
if: vars.TARGET_PROJECT != ''
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
\#*

/udmi-support_*/
/site_model
udmi_site_model/
gcp_reflect_key.pkcs8
workspace.xml
Expand Down
4 changes: 3 additions & 1 deletion bin/container
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ fi

if [[ -n $push ]]; then
docker push $udmi_ref
hash=$(docker images --digests ${udmi_ref%:*} | fgrep $udmi_tag | awk '{print $3}')
docker images
docker images --digests ${udmi_ref%:*} || true
hash=$(docker images --digests ${udmi_ref%:*} | fgrep $udmi_tag | awk '{print $3}') || true
ihash=$udmi_ref@$hash
for file in $TEMPLATES; do
out_file=tmp/$file
Expand Down
25 changes: 19 additions & 6 deletions bin/pubber
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ trap cleanup EXIT

config_file=$(realpath $1)
serial_no=NA
cloud_region=us-central1
project_id=--
shift

Expand All @@ -42,12 +43,20 @@ elif [[ $(jq -r .device_id $config_file) == null ]]; then
fail Neither deviceId nor device_id defined in config file.
else
echo Constructing pubber configuration from site config.
cat $config_file
project_id=$(jq -r .project_id $config_file)
device_id=$(jq -r .device_id $config_file)
registry_id=$(jq -r .registry_id $config_file)
serial_no=$(jq -r .serial_no $config_file)
site_model=$(jq -r .site_model $config_file)
iot_provider=$(jq -r .iot_provider $config_file)
[[ $site_model != null ]] || site_model=$(dirname $config_file)
[[ $site_model = /* ]] || site_model=$(dirname $config_file)/$site_model
jq -r .device_endpoint $config_file > $ENDPOINT_TMP
device_endpoint=$(jq -r .device_endpoint $config_file)
[[ $device_endpoint == null ]] || (
echo Extracting configuration to $ENDPOINT_TMP
echo $device_endpoint > $ENDPOINT_TMP
)
fi

if [[ -n ${UDMI_REGISTRY_SUFFIX:-} ]]; then
Expand Down Expand Up @@ -102,15 +111,16 @@ elif [[ $project_id =~ @ ]]; then
iot_provider=jwt
broker_hostname=${project_id#*@}
project_target=${project_id%@*}
else
iot_provider=gcp
elif [[ -z $iot_provider ]]; then
false no iot_provider provided.
fi

[[ ${registry_id:-null} == null ]] && fail registry_id not defined
registry_actual=${udmi_prefix}${registry_id}${registry_suffix}
if [[ ! -f $ENDPOINT_TMP ]]; then
[[ ${registry_id:-null} == null ]] && fail registry_id not defined
registry_actual=${udmi_prefix}${registry_id}${registry_suffix}
client_id=\"projects/$project_target/locations/$cloud_region/registries/$registry_actual/devices/$device_id\"
fi

topic_prefix=null
auth_provider=null
transport=null
Expand All @@ -124,7 +134,7 @@ elif [[ $iot_provider == mqtt ]]; then
gateway_id=$(jq -r .gateway.gateway_id $site_model/devices/$device_id/metadata.json) || true
echo Attached to gateway $gateway_id
target_id=$device_id
[[ $gateway_id == null ]] || target_id=$gateway_id
[[ -z $gateway_id || $gateway_id == null ]] || target_id=$gateway_id
echo Target is $target_id
client_id=\"/r/$registry_actual/d/$target_id\"
key_file=$site_model/devices/$target_id/*_private.pkcs8
Expand All @@ -139,6 +149,7 @@ elif [[ -z $broker_hostname ]]; then
fi

if [[ ! -f $ENDPOINT_TMP ]]; then
echo Constructing new $ENDPOINT_TMP
cat <<EOF > $ENDPOINT_TMP
{
"protocol": "mqtt",
Expand Down Expand Up @@ -179,6 +190,8 @@ if [[ -f ${site_model:-}/reflector/ca.crt && -n ${project_target:-} ]]; then
ls -l ${site_model}/devices/${target_id}/*.crt
fi

cat $tmp_config

# Run in the background to force new process group and get PID
$UDMI_ROOT/pubber/bin/run $tmp_config &
PUB_PID=$!
Expand Down
3 changes: 2 additions & 1 deletion bin/sequencer
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ elif [[ -f $site_path ]]; then
device_id=`jq -r .device_id $site_path`
[[ $device_id == null ]] && fail Parameter device_id not defined in config file.
serial_no=`jq -r .serial_no $site_path`
[[ $serial_no == null ]] && serial_no=$DEFAULT_SERIAL
[[ $serial_no != null ]] || serial_no=$DEFAULT_SERIAL
iot_provider=`jq .iot_provider $site_path`
endpoint=`jq .reflector_endpoint $site_path`
alt_registry=`jq .alt_registry $site_path`
registry_suffix=`jq .registry_suffix $site_path`
Expand Down
4 changes: 2 additions & 2 deletions bin/setup_base
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if [[ -n $(which apt-get) ]]; then
else
update_cmd="apk add"
# Some extra packages are necessary for alpine based docker builds.
extra_packages="linux-headers g++ gcc"
extra_packages="${NO_CACHE_DIR:+--no-cache} linux-headers g++ gcc"
fi

sudo $update_cmd $extra_packages moreutils expect python3-dev mosquitto mosquitto-clients
Expand All @@ -18,6 +18,6 @@ python3 --version
python3 -m venv venv

venv_pip3=$($(dirname $0)/which_venv_pip3)
${venv_pip3} install -r etc/requirements.txt
${venv_pip3} install ${NO_CACHE_DIR:+--no-cache-dir} -r etc/requirements.txt

java -version
Loading