jasonrbriggs / stomp.py

“stomp.py” is a Python client library for accessing messaging servers (such as ActiveMQ or RabbitMQ) using the STOMP protocol (versions 1.0, 1.1 and 1.2). It can also be run as a standalone, command-line client for testing.
Apache License 2.0
495 stars 166 forks source link

Tests are broken #358

Closed ehossack closed 2 years ago

ehossack commented 3 years ago

Hi, I was inspecting the code and tried to run the tests but I found they did not work.

I noticed that:

  1. the artemis version didn't work so that part of the install failed
  2. one had to have the poetry environment set up (undocumented)
  3. Many of the files refer to the ip 172.17.0.2 which I'm guessing might've been your container's port when you last ran these tests? So basically all the tests failed.
  4. In the dockerfile you take the artemis STOMP acceptor and sub in the port 61615 for the default of 61613 but nowhere else in the project do you expose it (which makes me think that this IP above is the same as your docker container) - I would have expected it to be mapped on line 79 of the dockerfile.
tests/test_cli.py::TestCLI::testrunarg
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- live log call --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
INFO     stomp.py:transport.py:750 attempt reconnection (True, None, 0)
INFO     stomp.py:transport.py:755 Attempting connection to host 172.17.0.2, port 62613
WARNING  stomp.py:transport.py:817 Could not connect to host 172.17.0.2, port 62613
DEBUG    stomp.py:transport.py:826 Sleeping for 0.1 seconds before attempting reconnect
INFO     stomp.py:transport.py:755 Attempting connection to host 172.17.0.2, port 62613
WARNING  stomp.py:transport.py:817 Could not connect to host 172.17.0.2, port 62613
DEBUG    stomp.py:transport.py:826 Sleeping for 0.2 seconds before attempting reconnect
INFO     stomp.py:transport.py:755 Attempting connection to host 172.17.0.2, port 62613
WARNING  stomp.py:transport.py:817 Could not connect to host 172.17.0.2, port 62613
DEBUG    stomp.py:transport.py:826 Sleeping for 0.2 seconds before attempting reconnect
FAILED

Anyway, below is a diff (git apply changes.patch) of me starting to do changes, but realizing that the setup is super broken so it might not be worth my while trying to work on a fix.

diff --git a/Makefile b/Makefile
index 956b0df..d3aab77 100644
--- a/Makefile
+++ b/Makefile
@@ -49,7 +49,7 @@ release: updateversion

 docker/tmp/activemq-artemis-bin.tar.gz:
    mkdir -p docker/tmp
-   wget http://www.apache.org/dist/activemq/activemq-artemis/2.13.0/apache-artemis-2.13.0-bin.tar.gz -O docker/tmp/activemq-artemis-bin.tar.gz
+   wget http://www.apache.org/dist/activemq/activemq-artemis/2.17.0/apache-artemis-2.17.0-bin.tar.gz -O docker/tmp/activemq-artemis-bin.tar.gz

 ssl-setup:
@@ -59,6 +59,8 @@ ssl-setup:
    rm -f tmp/broker*
    rm -f tmp/expiredbroker*

+   mkdir -p tmp
+
    keytool -genkey -alias broker -keyalg RSA -keystore docker/tmp/broker.ks -storepass changeit -storetype pkcs12 -keypass changeit -dname "CN=test, OU=test, O=test, L=test, S=test, C=GB" -ext "san=ip:172.17.0.2"
    keytool -genkey -alias broker2 -keyalg RSA -keystore docker/tmp/broker2.ks -storepass changeit -storetype pkcs12 -keypass changeit -dname "CN=test2, OU=test2, O=test2, L=test2, S=test2, C=GB" -ext "san=ip:172.17.0.2"
    keytool -genkey -alias client -keyalg RSA -keystore tmp/client.ks -storepass changeit -storetype pkcs12 -keypass changeit -dname "CN=testclient, OU=testclient, O=testclient, L=testclient, S=testclient, C=GB"
diff --git a/README.rst b/README.rst
index 297468d..50e9c82 100644
--- a/README.rst
+++ b/README.rst
@@ -71,6 +71,8 @@ stomp.py has been perfunctorily tested on:

 For testing locally, you'll need to install docker. Once installed:

+#. Ensure the poetry environment is set up:
+        poetry install
 #. Create the docker image:
         make docker-image
 #. Run the container:
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 321dc62..54ee14d 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -48,7 +48,7 @@ COPY haproxy.sh /
 # activemq artemis
 COPY tmp/activemq-artemis-bin.tar.gz /
 RUN tar -xvzf activemq-artemis-bin.tar.gz
-RUN apache-artemis-2.13.0/bin/artemis create testbroker --user testuser --password password --allow-anonymous --no-amqp-acceptor --no-hornetq-acceptor --default-port 61619
+RUN apache-artemis-2.17.0/bin/artemis create testbroker --user testuser --password password --allow-anonymous --no-amqp-acceptor --no-hornetq-acceptor --default-port 61619
 RUN sed -i 's/acceptor name="stomp">tcp:\/\/0.0.0.0:61613/acceptor name="stomp">tcp:\/\/0.0.0.0:61615/g' testbroker/etc/broker.xml

 # expose ports
jasonrbriggs commented 2 years ago

Working fine with the latest version (for me at least).

ehossack commented 2 years ago

Did you try a fresh install?

It's been a year since I filed this issue - and I tried again, had the same struggles, and the same outcome.

jasonrbriggs commented 2 years ago

Yes, I tried a completely clean install on another machine. Apart from having to install dependencies (poetry install; poetry install -E cryptography), and setting up the hosts file (which I'll add to the readme), there was nothing special needed to make it work. One test failure due to ipv6, but that's due to the machine I was running it on.

ehossack commented 2 years ago

Probably it was the hosts file why it didn't work for me then if that's required. Wasn't clear :)