software/mosquitto/test: fix flaky test
This test is using two connection one with a client to subscribe to a topic and wait for message and another one with publish.single to publish to the topic. The test was failing from time to time because the publish might have happened after the client was subscribed.
Refactor the test to use loop
on the client to have more control
and be able to wait for the client to be subscribed using the
on_subscribe
callback.
The test is also factorized, instead of having the same test twice for IPv4 and IPv6, we pass the host as parameter.