eclipse / mosquitto

Eclipse Mosquitto - An open source MQTT broker
https://mosquitto.org
Other
8.99k stars 2.39k forks source link

make `make test` work under CentOS8/python3 #1659

Open honglei opened 4 years ago

honglei commented 4 years ago

make test output:

cc -I../../../lib -I../../../src -Wall -Werror -fPIC -shared auth_plugin_msg_params.c -o auth_plugin_msg_params.so
cc -I../../../lib -I../../../src -Wall -Werror -fPIC -shared auth_plugin_extended_multiple.c -o auth_plugin_extended_multiple.so
cc -I../../../lib -I../../../src -Wall -Werror -fPIC -shared auth_plugin_extended_single.c -o auth_plugin_extended_single.so
cc -I../../../lib -I../../../src -Wall -Werror -fPIC -shared auth_plugin_extended_single2.c -o auth_plugin_extended_single2.so
cc -I../../../lib -I../../../src -Wall -Werror 08-tls-psk-pub.c -o 08-tls-psk-pub.test ../../../lib/libmosquitto.so.1
cc -I../../../lib -I../../../src -Wall -Werror 08-tls-psk-bridge.c -o 08-tls-psk-bridge.test ../../../lib/libmosquitto.so.1
make[3]: Leaving directory '/root/libs/mosquitto-1.6.9/test/broker/c'
./01-connect-anon-denied.py
Traceback (most recent call last):
  File "./01-connect-anon-denied.py", line 22, in <module>
    broker = mosq_test.start_broker(filename=os.path.basename(__file__), use_conf=True, port=port)
  File "/root/libs/mosquitto-1.6.9/test/mosq_test.py", line 63, in start_broker
    raise IOError
OSError
make[2]: *** [Makefile:23: 01] Error 1
make[2]: Leaving directory '/root/libs/mosquitto-1.6.9/test/broker'
make[1]: *** [Makefile:10: test] Error 2
make[1]: Leaving directory '/root/libs/mosquitto-1.6.9/test'
make: *** [Makefile:75: test] Error 2
[root@localhost broker]# ../../src/mosquitto -v -c 01-connect-anon-denied.conf
1587476916: mosquitto version 1.6.9 starting
1587476916: Config loaded from 01-connect-anon-denied.conf.
1587476916: Opening ipv4 listen socket on port 1888.
1587476916: Opening ipv6 listen socket on port 1888.
1587476916: Error: Invalid user 'mosquitto'.

So, I add user mosquitto, and rerun it:

make[3]: Leaving directory '/root/libs/mosquitto-1.6.9/test/lib/cpp'
./01-con-discon-success.py c/01-con-discon-success.test
./01-keepalive-pingreq.py c/01-keepalive-pingreq.test
./01-no-clean-session.py c/01-no-clean-session.test
./01-server-keepalive-pingreq.py c/01-server-keepalive-pingreq.test
./01-unpwd-set.py c/01-unpwd-set.test
./01-will-set.py c/01-will-set.test
./01-will-unpwd-set.py c/01-will-unpwd-set.test
./02-subscribe-qos0.py c/02-subscribe-qos0.test
./02-subscribe-qos1.py c/02-subscribe-qos1.test
./02-subscribe-qos1.py c/02-subscribe-qos1-async1.test
./02-subscribe-qos1.py c/02-subscribe-qos1-async2.test
connect_async failed: Connection refused
Traceback (most recent call last):
  File "./02-subscribe-qos1.py", line 47, in <module>
    (conn, address) = sock.accept()
  File "/usr/lib64/python3.6/socket.py", line 205, in accept
    fd, addr = self._accept()
socket.timeout: timed out
make[2]: *** [Makefile:36: c] Error 1
make[2]: Leaving directory '/root/libs/mosquitto-1.6.9/test/lib'
make[1]: *** [Makefile:11: test] Error 2
make[1]: Leaving directory '/root/libs/mosquitto-1.6.9/test'
make: *** [Makefile:75: test] Error 2
[root@localhost mosquitto-1.6.9]# find ./ |grep 02-subscribe-qos1.py
SigmundVik commented 4 years ago

./02-subscribe-qos1.py c/02-subscribe-qos1-async2.test fails on my Ubuntu 18.04 machine in a similar way (but async1.test runs fine):

sigmund@ubuntu1:~/mosquitto/test/lib$ ./02-subscribe-qos1.py ./c/02-subscribe-qos1-async1.test && echo $?
0
sigmund@ubuntu1:~/mosquitto/test/lib$ ./02-subscribe-qos1.py ./c/02-subscribe-qos1-async2.test && echo $?
connect_async failed: Connection refused
Traceback (most recent call last):
  File "./02-subscribe-qos1.py", line 47, in <module>
    (conn, address) = sock.accept()
  File "/usr/lib/python3.6/socket.py", line 205, in accept
    fd, addr = self._accept()
socket.timeout: timed out

If I make this change in test/lib/02-subscribe-qos1.py:

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
->
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)

then both tests pass:

sigmund@ubuntu1:~/mosquitto/test/lib$ ./02-subscribe-qos1.py ./c/02-subscribe-qos1-async1.test && echo $?
0
sigmund@ubuntu1:~/mosquitto/test/lib$ ./02-subscribe-qos1.py ./c/02-subscribe-qos1-async2.test && echo $?
0

I have not not yet figured out the reason for this, but it might be useful information. (The broker listens on the same port using both AF_INET and AF_INET6 sockets, so one fix would be to make the tests do the same. But if would of course be good to understand why that would be required...)

schmidtw commented 3 years ago

I'm seeing the same problem using Fedora 33 and https://github.com/eclipse/mosquitto/commit/5c45bc4e8407d94d29b39152b580d2b4cc8082e9.