-
Notifications
You must be signed in to change notification settings - Fork 49
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
Enable CI tests for discovery node #1047
Changes from all commits
656c48d
52762e4
1d23741
55e9654
fbfa59c
88b7a18
9fb9141
310396c
319710e
c218f76
7c04592
381ae15
6b9d711
b9e4e24
aab4a0c
5c7e92c
03dfac1
6b50c66
719f051
1682dd6
437316a
ce0717f
c1306fa
3f0447c
c77bc18
a56d55f
2a15fcb
0db17ed
56b5986
d5da1ca
d494afe
b84eb07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ on: | |
push: | ||
tags: | ||
- '**' | ||
branches: | ||
- '**' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
@@ -141,20 +143,60 @@ jobs: | |
run: docker logs sequencer | ||
|
||
discovery: | ||
name: Simple discovery test | ||
name: Simple discovery sequencer test | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
needs: images | ||
env: | ||
IMAGE_NAME: ${{ github.repository }} | ||
REF_NAME: ${{ github.ref_name }} | ||
DEVICE_ID: ${{'AHU-1'}} | ||
steps: | ||
- name: Execute discovery node | ||
- name: Setup Environment | ||
run: | | ||
sudo apt-get install moreutils | ||
git clone https://github.com/faucetsdn/udmi_site_model.git | ||
ln -s udmi_site_model/ site_model | ||
(cd site_model; git log -n 1) | ||
jq ".device_id = \"$DEVICE_ID\"" site_model/cloud_iot_config.json | sponge site_model/cloud_iot_config.json | ||
jq . site_model/cloud_iot_config.json | ||
docker network create udminet --subnet 192.168.99.0/24 | ||
- name: Start UDMIS container | ||
run: | | ||
export IMAGE_TAG=ghcr.io/$IMAGE_NAME:udmis-$REF_NAME | ||
docker run $IMAGE_TAG cat bin/actualize > /tmp/actualize.sh | ||
cat /tmp/actualize.sh && bash /tmp/actualize.sh | ||
- name: Generate keys | ||
run: | | ||
docker run --net udminet --name keygen -v $(realpath site_model):/root/site_model \ | ||
ghcr.io/$IMAGE_NAME:validator-$REF_NAME bin/keygen CERT site_model/devices/$DEVICE_ID | ||
- 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: Start discoverynode | ||
run: | | ||
export IMAGE_TAG=ghcr.io/$IMAGE_NAME:misc-$REF_NAME | ||
# This currently fails (no config), but just check that it actually runs. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove comment |
||
docker run $IMAGE_TAG discoverynode/bin/run | fgrep "Loading config" | ||
|
||
docker run -d \ | ||
--net udminet \ | ||
-v $(realpath site_model):/var/site_model \ | ||
--name discoverynode \ | ||
$IMAGE_TAG \ | ||
bin/run /var/site_model //mqtt/udmis AHU-1 vendor.range=0x65,28179023,20231,,,,,,,,,,,,,,,, | ||
- 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 \ | ||
scan_single_future | ||
- name: Sequencer results | ||
run: | | ||
cat site_model/out/devices/$DEVICE_ID/results.md | ||
[[ $(cat site_model/out/devices/$DEVICE_ID/results.md | grep -Ec ".*discovery.* pass") == 1 ]] | ||
- name: Discoverynode logs | ||
if: ${{ !cancelled() }} | ||
run: docker logs discoverynode | ||
|
||
udmif: | ||
name: UDMIF unit tests | ||
runs-on: ubuntu-latest | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
FROM debian:12-slim | ||
|
||
WORKDIR /root | ||
COPY discoverynode/ /root/discoverynode/ | ||
WORKDIR /root/discoverynode | ||
|
||
RUN apt-get update && \ | ||
apt-get install --no-install-suggests --no-install-recommends --yes python3-venv gcc libpython3-dev sudo && \ | ||
apt-get install --no-install-suggests --no-install-recommends --yes python3-venv gcc libpython3-dev sudo jq moreutils && \ | ||
python3 -m venv venv && \ | ||
venv/bin/pip install --upgrade pip setuptools wheel | ||
|
||
ADD discoverynode/src/requirements.txt /tmp/ | ||
RUN venv/bin/pip install --disable-pip-version-check -r /tmp/requirements.txt | ||
ADD discoverynode/ discoverynode/ | ||
RUN venv/bin/pip install --disable-pip-version-check -r src/requirements.txt |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash -e | ||
set -x | ||
ROOT_DIR=$(realpath $(dirname $0)/..) | ||
|
||
TMP_DIR=$(mktemp -d) | ||
OUT_DIR=$ROOT_DIR/dist | ||
OUT_FILE=$OUT_DIR/discoverynode | ||
|
||
echo Building binary to | ||
cat >$TMP_DIR/build.sh <<-EOF | ||
set -x | ||
mkdir /build | ||
cp -r /src /build | ||
cd /build/src | ||
pip3 install -r requirements.txt | ||
pyinstaller --onefile --hidden-import udmi main.py | ||
mv dist/main /tmp/main | ||
EOF | ||
|
||
docker pull ghcr.io/noursaidi/discoverybuilder:latest | ||
docker run --rm --volume $ROOT_DIR/src:/src --volume $TMP_DIR:/tmp ghcr.io/noursaidi/discoverybuilder:latest /bin/bash /tmp/build.sh | ||
mkdir -p $OUT_DIR | ||
mv $TMP_DIR/main $OUT_FILE | ||
chmod 7755 $OUT_FILE |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,8 @@ ROOT_DIR=$(realpath $(dirname $0)/..) | |
BASE_CONFIG=$(realpath $ROOT_DIR/etc/base_config.json) | ||
TMP_CONFIG="/tmp/discoverynode_config.json" | ||
|
||
if [[ $# -ne 3 ]]; then | ||
error Usage: $0 SITE_MODEL TARGET DEVICE_ID | ||
if (( $# -le 4 )); then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this be -le 2 since the [OPTIONS] bit is optional? Or -lt 3? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's three required options:
|
||
error Usage: $0 SITE_MODEL TARGET DEVICE_ID [OPTIONS] | ||
fi | ||
|
||
site_model=$1 | ||
|
@@ -65,12 +65,8 @@ EOF | |
) | ||
|
||
elif [[ $provider == mqtt ]]; then | ||
if [[ $project != localhost ]]; then | ||
error only localhost supported | ||
fi | ||
|
||
substitutions=$(cat <<EOF | ||
.mqtt.host|="localhost" | | ||
.mqtt.host|="$project" | | ||
.mqtt.port|=8883 | | ||
.mqtt.region|="$region" | | ||
.mqtt.project_id|="$project" | | ||
|
@@ -88,6 +84,12 @@ else | |
exit | ||
fi | ||
|
||
shift 3 | ||
|
||
cat $TMP_CONFIG | jq -r "$substitutions" | sponge $TMP_CONFIG | ||
|
||
for option in "$@"; do | ||
cat $TMP_CONFIG | jq -r ".${option/=/|=\"}\"" | sponge $TMP_CONFIG | ||
done | ||
|
||
$ROOT_DIR/venv/bin/python3 $ROOT_DIR/src/main.py --config_file=$TMP_CONFIG |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM ubuntu:16.04 | ||
|
||
WORKDIR /tmp | ||
|
||
RUN apt update && apt -y install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget | ||
RUN wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz | ||
RUN wget https://www.python.org/ftp/python/3.12.8/Python-3.12.8.tgz | ||
|
||
RUN apt -y remove openssl | ||
RUN tar -zxf openssl-1.1.1g.tar.gz | ||
RUN tar -xzvf Python-3.12.8.tgz | ||
|
||
WORKDIR /tmp/openssl-1.1.1g | ||
RUN ./config | ||
RUN make | ||
RUN make install | ||
RUN cp -r libssl.so.1.1 /usr/lib && cp -r libcrypto.so.1.1 /usr/lib | ||
|
||
WORKDIR /tmp/Python-3.12.8 | ||
RUN ./configure --enable-optimizations --with-openssl=/usr/local --with-ensurepip=install CFLAGS="-I/usr/include" LDFLAGS="-Wl,-rpath /usr/local/lib" --enable-shared --prefix=/usr/local | ||
RUN make | ||
RUN make install | ||
|
||
RUN python3 -m pip install pyinstaller | ||
|
||
WORKDIR /root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No ${{