Skip to content

Commit 2413572

Browse files
committed
Allow running tests in parallel (don't reuse addresses)
1 parent 5e38e7f commit 2413572

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+128
-128
lines changed

Diff for: tests/lib/clients/01-asyncio.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
import paho.mqtt.client as mqtt
55

6+
from tests.paho_test import get_test_server_port
7+
68
client_id = 'asyncio-test'
79

810

@@ -78,7 +80,7 @@ def on_disconnect(client, userdata, rc):
7880

7981
_aioh = AsyncioHelper(loop, client)
8082

81-
client.connect('localhost', 1888, 60)
83+
client.connect('localhost', get_test_server_port(), 60)
8284
client.socket().setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 2048)
8385

8486
await disconnected

Diff for: tests/lib/clients/01-decorators.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import loop_until_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
44

55
mqttc = mqtt.Client("decorators-test", clean_session=True)
66
payload = b""
@@ -38,5 +38,5 @@ def on_disconnect(mqttc, obj, rc):
3838
pass # TODO: should probably test that this gets called
3939

4040

41-
mqttc.connect("localhost", 1888)
41+
mqttc.connect("localhost", get_test_server_port())
4242
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/01-keepalive-pingreq.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import loop_until_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
44

55

66
def on_connect(mqttc, obj, flags, rc):
@@ -10,5 +10,5 @@ def on_connect(mqttc, obj, flags, rc):
1010
mqttc = mqtt.Client("01-keepalive-pingreq")
1111
mqttc.on_connect = on_connect
1212

13-
mqttc.connect("localhost", 1888, keepalive=4)
13+
mqttc.connect("localhost", get_test_server_port(), keepalive=4)
1414
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/01-no-clean-session.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import loop_until_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
44

55
mqttc = mqtt.Client("01-no-clean-session", clean_session=False)
66

7-
mqttc.connect("localhost", 1888)
7+
mqttc.connect("localhost", get_test_server_port())
88
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/01-reconnect-on-failure.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import wait_for_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, wait_for_keyboard_interrupt
44

55

66
def on_connect(mqttc, obj, flags, rc):
@@ -11,6 +11,6 @@ def on_connect(mqttc, obj, flags, rc):
1111
mqttc.on_connect = on_connect
1212

1313
with wait_for_keyboard_interrupt():
14-
mqttc.connect("localhost", 1888)
14+
mqttc.connect("localhost", get_test_server_port())
1515
mqttc.loop_forever()
1616
exit(42) # this is expected by the test case

Diff for: tests/lib/clients/01-unpwd-empty-password-set.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import loop_until_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
44

55
mqttc = mqtt.Client("01-unpwd-set")
66

77
mqttc.username_pw_set("uname", "")
8-
mqttc.connect("localhost", 1888)
8+
mqttc.connect("localhost", get_test_server_port())
99
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/01-unpwd-empty-set.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import loop_until_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
44

55
mqttc = mqtt.Client("01-unpwd-set")
66

77
mqttc.username_pw_set("", "")
8-
mqttc.connect("localhost", 1888)
8+
mqttc.connect("localhost", get_test_server_port())
99
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/01-unpwd-set.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import loop_until_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
44

55
mqttc = mqtt.Client("01-unpwd-set")
66

77
mqttc.username_pw_set("uname", ";'[08gn=#")
8-
mqttc.connect("localhost", 1888)
8+
mqttc.connect("localhost", get_test_server_port())
99
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/01-unpwd-unicode-set.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11

22
import paho.mqtt.client as mqtt
33

4-
from tests.paho_test import loop_until_keyboard_interrupt
4+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
55

66
mqttc = mqtt.Client("01-unpwd-unicode-set")
77

88
username = "\u00fas\u00e9rn\u00e1m\u00e9-h\u00e9ll\u00f3"
99
password = "h\u00e9ll\u00f3"
1010
mqttc.username_pw_set(username, password)
11-
mqttc.connect("localhost", 1888)
11+
mqttc.connect("localhost", get_test_server_port())
1212
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/01-will-set.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import loop_until_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
44

55
mqttc = mqtt.Client("01-will-set")
66

77
mqttc.will_set("topic/on/unexpected/disconnect", "will message", 1, True)
8-
mqttc.connect("localhost", 1888)
8+
mqttc.connect("localhost", get_test_server_port())
99
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/01-will-unpwd-set.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import loop_until_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
44

55
mqttc = mqtt.Client("01-will-unpwd-set")
66

77
mqttc.username_pw_set("oibvvwqw", "#'^2hg9a&nm38*us")
88
mqttc.will_set("will-topic", "will message", 2, False)
9-
mqttc.connect("localhost", 1888)
9+
mqttc.connect("localhost", get_test_server_port())
1010
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/01-zero-length-clientid.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import loop_until_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
44

55

66
def on_connect(mqttc, obj, flags, rc):
@@ -16,5 +16,5 @@ def on_disconnect(mqttc, obj, rc):
1616
mqttc.on_connect = on_connect
1717
mqttc.on_disconnect = on_disconnect
1818

19-
mqttc.connect("localhost", 1888)
19+
mqttc.connect("localhost", get_test_server_port())
2020
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/02-subscribe-qos0.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import loop_until_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
44

55

66
def on_connect(mqttc, obj, flags, rc):
@@ -16,5 +16,5 @@ def on_subscribe(mqttc, obj, mid, granted_qos):
1616
mqttc.on_connect = on_connect
1717
mqttc.on_subscribe = on_subscribe
1818

19-
mqttc.connect("localhost", 1888)
19+
mqttc.connect("localhost", get_test_server_port())
2020
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/02-subscribe-qos1.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import loop_until_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
44

55

66
def on_connect(mqttc, obj, flags, rc):
@@ -16,5 +16,5 @@ def on_subscribe(mqttc, obj, mid, granted_qos):
1616
mqttc.on_connect = on_connect
1717
mqttc.on_subscribe = on_subscribe
1818

19-
mqttc.connect("localhost", 1888)
19+
mqttc.connect("localhost", get_test_server_port())
2020
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/02-subscribe-qos2.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import loop_until_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
44

55

66
def on_connect(mqttc, obj, flags, rc):
@@ -16,5 +16,5 @@ def on_subscribe(mqttc, obj, mid, granted_qos):
1616
mqttc.on_connect = on_connect
1717
mqttc.on_subscribe = on_subscribe
1818

19-
mqttc.connect("localhost", 1888)
19+
mqttc.connect("localhost", get_test_server_port())
2020
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/02-unsubscribe.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import loop_until_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
44

55

66
def on_connect(mqttc, obj, flags, rc):
@@ -16,5 +16,5 @@ def on_unsubscribe(mqttc, obj, mid):
1616
mqttc.on_connect = on_connect
1717
mqttc.on_unsubscribe = on_unsubscribe
1818

19-
mqttc.connect("localhost", 1888)
19+
mqttc.connect("localhost", get_test_server_port())
2020
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/03-publish-b2c-qos1.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import loop_until_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
44

55
expected_payload = b"message"
66

@@ -21,5 +21,5 @@ def on_connect(mqttc, obj, flags, rc):
2121
mqttc.on_connect = on_connect
2222
mqttc.on_message = on_message
2323

24-
mqttc.connect("localhost", 1888)
24+
mqttc.connect("localhost", get_test_server_port())
2525
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/03-publish-b2c-qos2.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import wait_for_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, wait_for_keyboard_interrupt
44

55
expected_payload = b"message"
66

@@ -21,7 +21,7 @@ def on_connect(mqttc, obj, flags, rc):
2121
mqttc.on_connect = on_connect
2222
mqttc.on_message = on_message
2323

24-
mqttc.connect("localhost", 1888)
24+
mqttc.connect("localhost", get_test_server_port())
2525

2626
with wait_for_keyboard_interrupt():
2727
while True:

Diff for: tests/lib/clients/03-publish-c2b-qos1-disconnect.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import loop_until_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
44

55
sent_mid = -1
66

@@ -29,5 +29,5 @@ def on_publish(mqttc, obj, mid):
2929
mqttc.on_disconnect = on_disconnect
3030
mqttc.on_publish = on_publish
3131

32-
mqttc.connect("localhost", 1888)
32+
mqttc.connect("localhost", get_test_server_port())
3333
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/03-publish-c2b-qos2-disconnect.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import loop_until_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
44

55
first_connection = 1
66

@@ -27,5 +27,5 @@ def on_publish(mqttc, obj, mid):
2727
mqttc.on_disconnect = on_disconnect
2828
mqttc.on_publish = on_publish
2929

30-
mqttc.connect("localhost", 1888)
30+
mqttc.connect("localhost", get_test_server_port())
3131
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/03-publish-helper-qos0-v5.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import paho.mqtt.client
22
import paho.mqtt.publish
33

4-
from tests.paho_test import wait_for_keyboard_interrupt
4+
from tests.paho_test import get_test_server_port, wait_for_keyboard_interrupt
55

66
with wait_for_keyboard_interrupt():
77
paho.mqtt.publish.single(
88
"pub/qos0/test",
99
"message",
1010
qos=0,
1111
hostname="localhost",
12-
port=1888,
12+
port=get_test_server_port(),
1313
client_id="publish-helper-qos0-test",
1414
protocol=paho.mqtt.client.MQTTv5,
1515
)

Diff for: tests/lib/clients/03-publish-helper-qos0.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import paho.mqtt.publish
22

3-
from tests.paho_test import wait_for_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, wait_for_keyboard_interrupt
44

55
with wait_for_keyboard_interrupt():
66
paho.mqtt.publish.single(
77
"pub/qos0/test",
88
"message",
99
qos=0,
1010
hostname="localhost",
11-
port=1888,
11+
port=get_test_server_port(),
1212
client_id="publish-helper-qos0-test",
1313
)
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import paho.mqtt.publish
22

3-
from tests.paho_test import wait_for_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, wait_for_keyboard_interrupt
44

55
with wait_for_keyboard_interrupt():
66
paho.mqtt.publish.single(
77
"pub/qos1/test",
88
"message",
99
qos=1,
1010
hostname="localhost",
11-
port=1888,
11+
port=get_test_server_port(),
1212
client_id="publish-helper-qos1-disconnect-test",
1313
)

Diff for: tests/lib/clients/03-publish-qos0-no-payload.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import loop_until_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
44

55
sent_mid = -1
66

@@ -20,5 +20,5 @@ def on_publish(mqttc, obj, mid):
2020
mqttc.on_connect = on_connect
2121
mqttc.on_publish = on_publish
2222

23-
mqttc.connect("localhost", 1888)
23+
mqttc.connect("localhost", get_test_server_port())
2424
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/03-publish-qos0.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import loop_until_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
44

55
sent_mid = -1
66

@@ -22,5 +22,5 @@ def on_publish(mqttc, obj, mid):
2222
mqttc.on_connect = on_connect
2323
mqttc.on_publish = on_publish
2424

25-
mqttc.connect("localhost", 1888)
25+
mqttc.connect("localhost", get_test_server_port())
2626
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/04-retain-qos0.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import paho.mqtt.client as mqtt
22

3-
from tests.paho_test import loop_until_keyboard_interrupt
3+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
44

55

66
def on_connect(mqttc, obj, flags, rc):
@@ -11,5 +11,5 @@ def on_connect(mqttc, obj, flags, rc):
1111
mqttc = mqtt.Client("retain-qos0-test", clean_session=True)
1212
mqttc.on_connect = on_connect
1313

14-
mqttc.connect("localhost", 1888)
14+
mqttc.connect("localhost", get_test_server_port())
1515
loop_until_keyboard_interrupt(mqttc)

Diff for: tests/lib/clients/08-ssl-connect-cert-auth-pw.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import paho.mqtt.client as mqtt
44

5-
from tests.paho_test import loop_until_keyboard_interrupt
5+
from tests.paho_test import get_test_server_port, loop_until_keyboard_interrupt
66

77

88
def on_connect(mqttc, obj, flags, rc):
@@ -19,5 +19,5 @@ def on_connect(mqttc, obj, flags, rc):
1919
)
2020
mqttc.on_connect = on_connect
2121

22-
mqttc.connect("localhost", 1888)
22+
mqttc.connect("localhost", get_test_server_port())
2323
loop_until_keyboard_interrupt(mqttc)

0 commit comments

Comments
 (0)