33import string
44
55from tests .helpers import fake_backend
6- from tests .helpers .util import wait_for , run_agent , run_container
6+ from tests .helpers .util import wait_for , run_agent , run_container , container_ip
77from tests .helpers .assertions import *
88
9- def wait_for_rabbit_to_start (cont ):
10- # 3D38 is 15672 in hex, the port we need to be listening
11- assert wait_for (p (container_cmd_exit_0 , cont , "sh -c 'cat /proc/net/tcp | grep 3D38'" ), 40 ), "rabbitmq didn't start"
12-
13-
149rabbitmq_config = string .Template ("""
1510monitors:
1611 - type: collectd/rabbitmq
@@ -24,9 +19,9 @@ def wait_for_rabbit_to_start(cont):
2419
2520def test_rabbitmq ():
2621 with run_container ("rabbitmq:3.6-management" ) as rabbitmq_cont :
27- host = rabbitmq_cont . attrs [ "NetworkSettings" ][ "IPAddress" ]
22+ host = container_ip ( rabbitmq_cont )
2823 config = rabbitmq_config .substitute (host = host )
29- wait_for_rabbit_to_start ( rabbitmq_cont )
24+ assert wait_for ( p ( tcp_socket_open , host , 15672 ), 60 ), "service didn't start"
3025
3126 with run_agent (config ) as [backend , _ , _ ]:
3227 assert wait_for (p (has_datapoint_with_dim , backend , "plugin" , "rabbitmq" )), "Didn't get rabbitmq datapoints"
@@ -35,9 +30,9 @@ def test_rabbitmq():
3530
3631def test_rabbitmq_broker_name ():
3732 with run_container ("rabbitmq:3.6-management" ) as rabbitmq_cont :
38- host = rabbitmq_cont . attrs [ "NetworkSettings" ][ "IPAddress" ]
33+ host = container_ip ( rabbitmq_cont )
3934 config = rabbitmq_config .substitute (host = host )
40- wait_for_rabbit_to_start ( rabbitmq_cont )
35+ assert wait_for ( p ( tcp_socket_open , host , 15672 ), 60 ), "service didn't start"
4136
4237 with run_agent ("""
4338monitors:
0 commit comments