Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java: two test cases in MqttPahoClientTest result in an infinite loop #32

Closed
rendner opened this issue Sep 2, 2018 · 1 comment
Closed

Comments

@rendner
Copy link

rendner commented Sep 2, 2018

Problem

Test case mqttClientTestWithDisabledMessageSizeCheckWithTlsAndDefaultJksStore and mqttClientTestWithDisabledMessageSizeCheckWithTlsAndP12Store create an infinite loop.

If these tests are running without an additional mosquitto process with ssl enabled (listener on port 8883 + cert, cat and key file), each of these tests will result in an infinite loop. The following error is reported multiple times:

io.joynr.messaging.mqtt.paho.client.MqttPahoClient: MQTT Connect failed. Error code 32103
Unable to connect to server (32103) - java.net.ConnectException: Connection refused (Connection refused)

The mosquitto process, which is started by the test class, listens only on port 1883.

All users which follow this example Building joynr Java and common components will run into this problem. The problem described here is part of this problem: Building joynr Java failed

Steps to reproduce

Before running the commands, replace FULL_PATH_TO_JOYNR_SOURCES and FULL_PATH_TO_MAVEN_DIRECTORY with the right values.
The docker container can be "killed" with ctrl+c.

  • Run the following command for test case mqttClientTestWithDisabledMessageSizeCheckWithTlsAndDefaultJksStore:
docker run -it --rm --sig-proxy -e DEV_UID="$(id -u)"  \
    -v <FULL_PATH_TO_JOYNR_SOURCES>:/data/src \
    -v <FULL_PATH_TO_MAVEN_DIRECTORY>:/home/joynr/.m2 \
    joynr-java \
    "mvn clean test -f /data/src/java/messaging/mqtt/joynr-mqtt-client/pom.xml -P no-license-and-notice,no-java-formatter,no-checkstyle -DskipTests=false -Dtest=MqttPahoClientTest#mqttClientTestWithDisabledMessageSizeCheckWithTlsAndDefaultJksStore"
  • Run the following command for test case mqttClientTestWithDisabledMessageSizeCheckWithTlsAndP12Store:
docker run -it --rm --sig-proxy -e DEV_UID="$(id -u)"  \
    -v <FULL_PATH_TO_JOYNR_SOURCES>:/data/src \
    -v <FULL_PATH_TO_MAVEN_DIRECTORY>:/home/joynr/.m2 \
    joynr-java \
    "mvn clean test -f /data/src/java/messaging/mqtt/joynr-mqtt-client/pom.xml -P no-license-and-notice,no-java-formatter,no-checkstyle -DskipTests=false -Dtest=MqttPahoClientTest#mqttClientTestWithDisabledMessageSizeCheckWithTlsAndP12Store"

Solution

Run mosquitto process with ssl enabled (listener on port 8883 + required files).

In my environment I copied the mosquitto.conf from /docker/joynr-base to java/messaging/mqtt/joynr-mqtt-client/src/test/resources. And modified the startBroker method of the test class to load the configuration file mosquitto.conf:

//ProcessBuilder processBuilder = new ProcessBuilder(path + "mosquitto", "-p", Integer.toString(mqttBrokerPort));
	ProcessBuilder processBuilder = new ProcessBuilder(path + "mosquitto", "-c", getResourcePath("mosquitto.conf"));
@rendner rendner changed the title Java: MqttPahoClientTest::mqttClientTestWithDisabledMessageSizeCheckWithTlsAndDefaultJksStore Java: MqttPahoClientTest::mqttClientTestWithDisabledMessageSizeCheckWithTlsAndDefaultJksStore can result in an endless loop Sep 2, 2018
@rendner rendner changed the title Java: MqttPahoClientTest::mqttClientTestWithDisabledMessageSizeCheckWithTlsAndDefaultJksStore can result in an endless loop Java: two test cases in MqttPahoClientTest result in an infinite loop Sep 8, 2018
@rendner
Copy link
Author

rendner commented Oct 5, 2018

I can confirm that this problem is now solved with these changes. The mentioned tests run fine if the required resources are available --> #30. If not the test now only fails with a NullPointerException and doesn't cause an infinite loop.

@rendner rendner closed this as completed Oct 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant