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

Add mosquitto to CI tests #365

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 33 additions & 2 deletions .github/workflows/fsanitize-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,36 @@ jobs:
WOLFMQTT_NO_EXTERNAL_BROKER_TESTS: 1

steps:
- name: Install dependencies
run: |
# Don't prompt for anything
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
# Install mosquitto
sudo apt-get install -y mosquitto bubblewrap

- name: Setup mosquitto broker
run: |
# Disable default broker daemon
sudo service mosquitto stop
sleep 1

# This is some debug info useful if something goes wrong
- name: Show network status
run: |
sudo ifconfig
sudo route
sudo netstat -tulpan

- uses: actions/checkout@master
with:
repository: wolfssl/wolfssl
path: wolfssl
- name: wolfssl autogen
working-directory: ./wolfssl
working-directory: ./wolfssl
run: ./autogen.sh
- name: wolfssl configure
working-directory: ./wolfssl
working-directory: ./wolfssl
run: ./configure --enable-enckeys
- name: wolfssl make
working-directory: ./wolfssl
Expand All @@ -34,27 +55,37 @@ jobs:
- uses: actions/checkout@master
- name: autogen
run: ./autogen.sh

- name: configure
run: ./configure CC="gcc -fsanitize=address"
- name: make
run: make
- name: make check
run: make check

- name: configure with SN Enabled
run: ./configure --enable-sn CC="gcc -fsanitize=address"
- name: make
run: make
- name: make check
run: make check

- name: configure with Non-Block
run: ./configure --enable-nonblock CFLAGS="-DWOLFMQTT_TEST_NONBLOCK" CC="gcc -fsanitize=address"
- name: make
run: make
- name: make check
run: make check

- name: configure with Non-Block and Multi-threading
run: ./configure --enable-mt --enable-nonblock CFLAGS="-DWOLFMQTT_TEST_NONBLOCK" CC="gcc -fsanitize=address"
- name: make
run: make
- name: make check
run: make check

# capture logs on failure
- name: Show logs on failure
if: failure() || cancelled()
run: |
more test-suite.log
18 changes: 15 additions & 3 deletions .github/workflows/macos-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,55 @@ jobs:
repository: wolfssl/wolfssl
path: wolfssl
- name: brew
run: brew install automake libtool
run: brew install automake libtool md5sha1sum

- name: wolfssl autogen
working-directory: ./wolfssl
working-directory: ./wolfssl
run: ./autogen.sh
- name: wolfssl configure
working-directory: ./wolfssl
working-directory: ./wolfssl
run: ./configure --enable-enckeys
- name: wolfssl make
working-directory: ./wolfssl
run: make
- name: wolfssl make install
working-directory: ./wolfssl
run: make install

- uses: actions/checkout@master
- name: autogen
run: ./autogen.sh

- name: configure
run: ./configure
- name: make
run: make
- name: make check
run: make check

- name: configure with SN Enabled
run: ./configure --enable-sn
- name: make
run: make
- name: make check
run: make check

- name: configure with Non-Block
run: ./configure --enable-nonblock CFLAGS="-DWOLFMQTT_TEST_NONBLOCK"
- name: make
run: make
- name: make check
run: make check

- name: configure with Non-Block and Multi-threading
run: ./configure --enable-mt --enable-nonblock CFLAGS="-DWOLFMQTT_TEST_NONBLOCK"
- name: make
run: make
- name: make check
run: make check

# capture logs on failure
- name: Show logs on failure
if: failure() || cancelled()
run: |
cat test-suite.log
79 changes: 44 additions & 35 deletions .github/workflows/ubuntu-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@ jobs:
timeout-minutes: 5

steps:
- name: Install dependencies
run: |
# Don't prompt for anything
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
# Install mosquitto
sudo apt-get install -y mosquitto bubblewrap

- name: Setup mosquitto broker
run: |
# Disable default broker daemon
sudo service mosquitto stop
sleep 1

# This is some debug info useful if something goes wrong
- name: Show network status
run: |
sudo ifconfig
sudo route
sudo netstat -tulpan

- uses: actions/checkout@master
with:
repository: wolfssl/wolfssl
Expand All @@ -29,63 +50,51 @@ jobs:
- name: wolfssl make install
working-directory: ./wolfssl
run: sudo make install

- uses: actions/checkout@master
- name: autogen
- name: wolfmqtt autogen
run: ./autogen.sh
- name: configure

- name: wolfmqtt configure
run: ./configure
- name: make
- name: wolfmqtt make
run: make
- name: make check
id: make-check
- name: wolfmqtt make check
run: make check
- name: Show logs on failure
if: ${{ failure() && steps.make-check.outcome == 'failure' }}
run: |
more test-suite.log

env:
WOLFMQTT_NO_EXTERNAL_BROKER_TESTS: 1
- name: configure with SN Enabled

- name: wolfmqtt configure with SN Enabled
run: ./configure --enable-sn
- name: make
- name: wolfmqtt make
run: make
- name: make check
id: make-check-sn
- name: wolfmqtt make check
run: make check
- name: Show logs on failure
if: ${{ failure() && steps.make-check-sn.outcome == 'failure' }}
run: |
more test-suite.log
- name: configure with Non-Block

- name: wolfmqtt configure with Non-Block
run: ./configure --enable-nonblock CFLAGS="-DWOLFMQTT_TEST_NONBLOCK"
- name: make
- name: wolfmqtt make
run: make
- name: make check
id: make-check-nonblock
- name: wolfmqtt make check
run: make check
- name: Show logs on failure
if: ${{ failure() && steps.make-check-nonblock.outcome == 'failure' }}
run: |
more test-suite.log
- name: configure with Non-Block and Multi-threading

- name: wolfmqtt configure with Non-Block and Multi-threading
run: ./configure --enable-mt --enable-nonblock CFLAGS="-DWOLFMQTT_TEST_NONBLOCK"
- name: make
- name: wolfmqtt make
run: make
- name: make check
id: make-check-nonblock-mt
- name: wolfmqtt make check
run: make check
- name: Show logs on failure
if: ${{ failure() && steps.make-check-nonblock-mt.outcome == 'failure' }}
run: |
more test-suite.log

- name: configure with Multi-threading and WOLFMQTT_DYN_PROP
run: ./configure --enable-mt CFLAGS="-DWOLFMQTT_DYN_PROP"
- name: make
run: make
- name: make check
id: make-check-mt-dynprop
run: make check

# capture logs on failure
- name: Show logs on failure
if: ${{ failure() && steps.make-check-mt-dynprop.outcome == 'failure' }}
if: failure() || cancelled()
run: |
more test-suite.log
5 changes: 4 additions & 1 deletion .github/workflows/zephyr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: Zephyr tests
env:
WOLFMQTT_NO_EXTERNAL_BROKER_TESTS: 1

on:
push:
Expand All @@ -17,6 +19,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:

- name: Install dependencies
run: |
# Don't prompt for anything
Expand Down Expand Up @@ -86,7 +89,7 @@ jobs:
sudo service mosquitto stop
mosquitto -c scripts/broker_test/mosquitto.conf &> broker.log &
sleep 1 # let the broker set everything up
mosquitto_sub -t sensors &> sub.log &
mosquitto_sub -p 11883 -t sensors &> sub.log &

# This is some debug info useful if something goes wrong
- name: Show network status
Expand Down
4 changes: 2 additions & 2 deletions scripts/broker_test/mosquitto.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# =================================================================

# Port to use for the default listener.
listener 1883
listener 11883
allow_anonymous true

# -----------------------------------------------------------------
Expand All @@ -19,7 +19,7 @@ allow_anonymous true
#
# See also the mosquitto-tls man page.

listener 8883
listener 18883
allow_anonymous true

# At least one of cafile or capath must be defined. They both
Expand Down
30 changes: 18 additions & 12 deletions scripts/client.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ broker_pid=$no_pid
do_cleanup() {
if [ $broker_pid != $no_pid ]
then
kill -6 $broker_pid
kill -9 $broker_pid
echo "Killed broker PID $broker_pid"
broker_pid=$no_pid
fi

if [ $1 -ne 0 ]
then
exit 1
Expand All @@ -29,49 +31,53 @@ then
if [ "${AM_BWRAPPED-}" != "yes" ]; then
bwrap_path="$(command -v bwrap)"
if [ -n "$bwrap_path" ]; then
echo "Client test using bwrap"
export AM_BWRAPPED=yes
exec "$bwrap_path" --unshare-net --dev-bind / / "$0" "$@"
fi
fi
# Run mosquitto broker
mosquitto -c scripts/broker_test/mosquitto.conf &
broker_pid=$!
echo "Broker PID is $broker_pid"
def_args="${def_args} -h localhost"
mutual_auth_args="${mutual_auth_args} -c certs/client-cert.pem -K certs/client-key.pem"
ecc_mutual_auth_args="${mutual_auth_args} -c certs/client-ecc-cert.pem -K certs/ecc-client-key.pem"
tls_port_args="-p 18883"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it still required to use different port numbers even after your script stops the mosquito daemon sudo service mosquitto stop?

port_args="-p 11883"
mutual_auth_args="-c certs/client-cert.pem -K certs/client-key.pem"
ecc_mutual_auth_args="-c certs/client-ecc-cert.pem -K certs/ecc-client-key.pem"
fi

# Run with and without TLS and QoS 0-2

./examples/mqttclient/mqttclient $def_args -q 0 $1
./examples/mqttclient/mqttclient $def_args $port_args -q 0 $1
RESULT=$?
[ $RESULT -ne 0 ] && echo -e "\n\nMQTT Client failed! TLS=Off, QoS=0" && do_cleanup "-1"

./examples/mqttclient/mqttclient $def_args -q 1 $1
./examples/mqttclient/mqttclient $def_args $port_args -q 1 $1
RESULT=$?
[ $RESULT -ne 0 ] && echo -e "\n\nMQTT Client failed! TLS=Off, QoS=1" && do_cleanup "-1"

./examples/mqttclient/mqttclient $def_args -q 2 $1
./examples/mqttclient/mqttclient $def_args $port_args -q 2 $1
RESULT=$?
[ $RESULT -ne 0 ] && echo -e "\n\nMQTT Client failed! TLS=Off, QoS=2" && do_cleanup "-1"

./examples/mqttclient/mqttclient $def_args -t -q 0 $1
./examples/mqttclient/mqttclient $def_args $tls_port_args -t -q 0 $1
RESULT=$?
[ $RESULT -ne 0 ] && echo -e "\n\nMQTT Client failed! TLS=On, QoS=0" && do_cleanup "-1"

./examples/mqttclient/mqttclient $def_args -t -q 1 $1
./examples/mqttclient/mqttclient $def_args $tls_port_args -t -q 1 $1
RESULT=$?
[ $RESULT -ne 0 ] && echo -e "\n\nMQTT Client failed! TLS=On, QoS=1" && do_cleanup "-1"

./examples/mqttclient/mqttclient $def_args -t -q 2 $1
./examples/mqttclient/mqttclient $def_args $tls_port_args -t -q 2 $1
RESULT=$?
[ $RESULT -ne 0 ] && echo -e "\n\nMQTT Client failed! TLS=On, QoS=2" && do_cleanup "-1"

./examples/mqttclient/mqttclient $def_args $mutual_auth_args -t -q 0 $1
./examples/mqttclient/mqttclient $def_args $mutual_auth_args $tls_port_args -t -q 0 $1
RESULT=$?
[ $RESULT -ne 0 ] && echo -e "\n\nMQTT Client failed! TLS=On, QoS=0, RSA mutual auth" && do_cleanup "-1"

./examples/mqttclient/mqttclient $def_args $ecc_mutual_auth_args -t -q 0 $1
./examples/mqttclient/mqttclient $def_args $ecc_mutual_auth_args $tls_port_args -t -q 0 $1
RESULT=$?
[ $RESULT -ne 0 ] && echo -e "\n\nMQTT Client failed! TLS=On, QoS=0, ECC mutual auth" && do_cleanup "-1"

Expand Down