Skip to content

Commit b465d69

Browse files
authored
Fix: mqtt test (#1033)
1 parent 7c13b05 commit b465d69

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

smoketest/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM greenbone/vulnerability-tests AS nasl
1+
FROM registry.community.greenbone.net/community/vulnerability-tests AS nasl
22
# use latest version
33
RUN mv `ls -d /var/lib/openvas/* | sort -r | head -n 1`/vt-data/nasl /nasl
44

@@ -7,7 +7,7 @@ COPY --chmod=7777 smoketest /usr/local/src
77
WORKDIR /usr/local/src
88
RUN make build-cmds
99

10-
FROM greenbone/openvas-scanner:unstable
10+
FROM registry.community.greenbone.net/community/openvas-scanner:edge
1111

1212
RUN apt-get update && apt-get install --no-install-recommends --no-install-suggests -y \
1313
mosquitto \

tests/messaging/test_mqtt.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44
# SPDX-License-Identifier: AGPL-3.0-or-later
55

6+
import time
67
from datetime import datetime
78
from uuid import UUID
89

@@ -87,12 +88,15 @@ def test_connect(self):
8788
daemon = MQTTDaemon(client)
8889

8990
def test_run(self):
90-
client = mock.MagicMock()
91-
91+
client = mock.MagicMock(side_effect=1)
9292
daemon = MQTTDaemon(client)
93+
t_ini = time.time()
9394

9495
daemon.run()
96+
# In some systems the spawn of the thread can take longer than expected.
97+
# Therefore, we wait until the thread is spawned or times out.
98+
while len(client.mock_calls) == 0 and time.time() - t_ini < 10:
99+
time.sleep(1)
95100

96101
client.connect.assert_called_with()
97-
98102
client.loop_start.assert_called_with()

0 commit comments

Comments
 (0)