Skip to content

Commit 5c850cd

Browse files
committed
feat(mosq): Add target tests with localhost broker-client
1 parent de4531e commit 5c850cd

File tree

2 files changed

+64
-3
lines changed

2 files changed

+64
-3
lines changed

.github/workflows/mosq__build.yml

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ on:
99

1010
jobs:
1111
build_mosq:
12-
if: contains(github.event.pull_request.labels.*.name, 'Comp::mosq') || github.event_name == 'push'
13-
name: Build
12+
if: contains(github.event.pull_request.labels.*.name, 'mosquitto') || github.event_name == 'push'
13+
name: Mosquitto build
1414
strategy:
1515
matrix:
1616
idf_ver: ["latest", "release-v5.3"]
1717
runs-on: ubuntu-22.04
1818
container: espressif/idf:${{ matrix.idf_ver }}
19+
env:
20+
TEST_DIR: components/mosquitto/examples/broker
21+
TARGET_TEST_DIR: build_esp32_default
1922
steps:
2023
- name: Checkout esp-protocols
2124
uses: actions/checkout@v4
@@ -28,4 +31,44 @@ jobs:
2831
run: |
2932
. ${IDF_PATH}/export.sh
3033
pip install idf-component-manager idf-build-apps --upgrade
31-
python ci/build_apps.py components/mosquitto/examples/ -c
34+
python ci/build_apps.py ${TEST_DIR}
35+
cd ${TEST_DIR}
36+
${GITHUB_WORKSPACE}/ci/clean_build_artifacts.sh `pwd`/${TARGET_TEST_DIR}
37+
zip -qur artifacts.zip ${TARGET_TEST_DIR}
38+
- uses: actions/upload-artifact@v4
39+
with:
40+
name: mosq_target_esp32_${{ matrix.idf_ver }}
41+
path: ${{ env.TEST_DIR }}/artifacts.zip
42+
if-no-files-found: error
43+
44+
test_mosq:
45+
# Skip running on forks since it won't have access to secrets
46+
if: |
47+
github.repository == 'espressif/esp-protocols' &&
48+
( contains(github.event.pull_request.labels.*.name, 'mosquitto') || github.event_name == 'push' )
49+
name: Mosquitto target test
50+
needs: build_mosq
51+
strategy:
52+
matrix:
53+
idf_ver: ["latest", "release-v5.3"]
54+
runs-on:
55+
- self-hosted
56+
- ESP32-ETHERNET-KIT
57+
env:
58+
TEST_DIR: components/mosquitto/examples/broker
59+
TARGET_TEST_DIR: build_esp32_default
60+
steps:
61+
- uses: actions/checkout@v4
62+
- uses: actions/download-artifact@v4
63+
with:
64+
name: mosq_target_esp32_${{ matrix.idf_ver }}
65+
path: ${{ env.TEST_DIR }}/ci/
66+
- name: Run Test
67+
working-directory: ${{ env.TEST_DIR }}
68+
run: |
69+
unzip ci/artifacts.zip -d ci
70+
for dir in `ls -d ci/build_*`; do
71+
rm -rf build sdkconfig.defaults
72+
mv $dir build
73+
python -m pytest --log-cli-level DEBUG --junit-xml=./results_esp32_${{ matrix.idf_ver }}_${dir#"ci/build_"}.xml --target=esp32
74+
done
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
2+
# SPDX-License-Identifier: Unlicense OR CC0-1.0
3+
4+
def test_mosq_local(dut):
5+
"""
6+
steps:
7+
1. Start mosquitto broker
8+
2. Start mqtt client
9+
3. Checks that the client connected to broker
10+
4. checks that the client received published data
11+
"""
12+
# We expect the client to connect from IPv4 localhost address
13+
dut.expect('New client connected from 127.0.0.1')
14+
# We expect the client to get "connected" event and receive the published data
15+
dut.expect('MQTT_EVENT_CONNECTED')
16+
dut.expect('MQTT_EVENT_DATA')
17+
dut.expect('TOPIC=/topic/qos0')
18+
dut.expect('DATA=data')

0 commit comments

Comments
 (0)