Skip to content

Commit

Permalink
CI: Run mqttv5 tests
Browse files Browse the repository at this point in the history
Signed-off-by: Aarni Koskela <[email protected]>
  • Loading branch information
akx committed Dec 24, 2023
1 parent e4ded42 commit a820a60
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: eclipse/paho.mqtt.testing
ref: a4dc694010217b291ee78ee13a6d1db812f9babd
path: paho.mqtt.testing
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
Expand Down
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ Once you have the code, it can be installed from your repository as well:
To perform all test (including MQTT v5 test), you also need to clone paho.mqtt.testing in paho.mqtt.python folder::

git clone https://github.com/eclipse/paho.mqtt.testing.git
cd paho.mqtt.testing
git checkout a4dc694010217b291ee78ee13a6d1db812f9babd

Known limitations
-----------------
Expand Down
29 changes: 17 additions & 12 deletions tests/test_mqttv5.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import threading
import time
import unittest
import unittest.mock

import paho.mqtt
import paho.mqtt.client
Expand Down Expand Up @@ -164,18 +165,22 @@ def setUpClass(cls):
except ImportError as ie:
raise unittest.SkipTest("paho.mqtt.testing not present.") from ie

cls._test_broker = threading.Thread(
target=mqtt.brokers.run,
kwargs={
"config": ["listener 0"],
},
)
cls._test_broker.daemon = True
cls._test_broker.start()
# Wait a bit for TCP server to bind to an address
time.sleep(0.5)
# Hack to find the port used by the test broker...
cls._test_broker_port = mqtt.brokers.listeners.TCPListeners.server.socket.getsockname()[1]
# Hack: we need to patch `signal.signal()` because `mqtt.brokers.run()`
# calls it to set up a signal handler; however, that won't work
# from a thread...
with unittest.mock.patch("signal.signal", unittest.mock.MagicMock()):
cls._test_broker = threading.Thread(
target=mqtt.brokers.run,
kwargs={
"config": ["listener 0"],
},
)
cls._test_broker.daemon = True
cls._test_broker.start()
# Wait a bit for TCP server to bind to an address
time.sleep(0.5)
# Hack to find the port used by the test broker...
cls._test_broker_port = mqtt.brokers.listeners.TCPListeners.server.socket.getsockname()[1]
setData()
cleanup(cls._test_broker_port)

Expand Down

0 comments on commit a820a60

Please sign in to comment.