Merge lp:~mbruzek/charms/precise/rabbitmq-server/add-tests into lp:charms/rabbitmq-server

Proposed by Matt Bruzek
Status: Merged
Merged at revision: 74
Proposed branch: lp:~mbruzek/charms/precise/rabbitmq-server/add-tests
Merge into: lp:charms/rabbitmq-server
Diff against target: 657 lines (+605/-1)
9 files modified
Makefile (+5/-1)
tests/00_setup.sh (+16/-0)
tests/10_basic_deploy_test.py (+101/-0)
tests/20_deploy_relations_test.py (+214/-0)
tests/30_configuration_test.py (+142/-0)
tests/amqp_tester.py (+65/-0)
tests/rabbit-server-cacert.pem (+17/-0)
tests/rabbit-server-cert.pem (+18/-0)
tests/rabbit-server-privkey.pem (+27/-0)
To merge this branch: bzr merge lp:~mbruzek/charms/precise/rabbitmq-server/add-tests
Reviewer Review Type Date Requested Status
Review Queue (community) automated testing Needs Fixing
José Antonio Rey (community) charmers Approve
Ryan Beisner (community) Approve
Review via email: mp+246025@code.launchpad.net

Description of the change

Adding tests for the rabbitmq-server charm.

To post a comment you must log in.
Revision history for this message
Ryan Beisner (1chb1n) wrote :

Thank you for the amulet test coverage work on rmq, much appreciated!

If we can get this added to Makefile, that will make OSCI's engine happy:

test:
    @echo Starting amulet tests...
    @juju test -v -p AMULET_HTTP_PROXY --timeout 900

I just sent your branch with ^ that mod through to confirm:
  juju-test.conductor.00_setup.sh RESULT : ✔
  juju-test.conductor.10_basic_deploy_test.py RESULT : ✔
  juju-test.conductor.20_deploy_relations_test.py RESULT : ✔
  juju-test.conductor.30_configuration_test.py RESULT : ✔
  juju-test INFO : Results: 4 passed, 0 failed, 0 errored

I think most of the openstack charms use the 'test' target name. But actually, you can name the make target anything as OSCI just looks for '@juju test' in a target and runs that target.

76. By Matt Bruzek

Adding Makefile changes

Revision history for this message
Matt Bruzek (mbruzek) wrote :

Thanks for the review. I added the functional_test target to the Makefile so these tests work on both testing systems. Charmers please review these changes for inclusion to the precise charm.

Revision history for this message
Ryan Beisner (1chb1n) wrote :

Re-confirmed with rev76. Precise charm amulet tests succeed. Clear from the OSCI perspective. Thanks again!

review: Approve
Revision history for this message
José Antonio Rey (jose) wrote :

Hey Matt!

Thank you for taking the time to write this tests. I have ran them on EC2, and turns out they successfully pass!

I will be pushing these on the next few minutes. Thanks again!

review: Approve (charmers)
Revision history for this message
Review Queue (review-queue) wrote :

This items has failed automated testing! Results available here http://reports.vapour.ws/charm-tests/charm-bundle-test-10905-results

review: Needs Fixing (automated testing)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile'
--- Makefile 2014-10-08 15:57:57 +0000
+++ Makefile 2015-01-12 15:19:55 +0000
@@ -20,7 +20,11 @@
20 bzr push lp:charms/rabbitmq-server20 bzr push lp:charms/rabbitmq-server
21 bzr push lp:charms/trusty/rabbitmq-server21 bzr push lp:charms/trusty/rabbitmq-server
2222
23functional_test:
24 @echo Starting functional tests...
25 @juju test -v -p AMULET_HTTP_PROXY --timeout 900
26
23unit_test:27unit_test:
24 @echo Starting tests...28 @echo Starting unit tests...
25 CHARM_DIR=$(CHARM_DIR) $(TEST_PREFIX) nosetests unit_tests29 CHARM_DIR=$(CHARM_DIR) $(TEST_PREFIX) nosetests unit_tests
2630
2731
=== added directory 'tests'
=== added file 'tests/00_setup.sh'
--- tests/00_setup.sh 1970-01-01 00:00:00 +0000
+++ tests/00_setup.sh 2015-01-12 15:19:55 +0000
@@ -0,0 +1,16 @@
1#!/bin/sh
2
3# Install Juju Amulet and any other applications that are needed for the tests.
4
5set -x
6
7# Check if amulet is installed before adding repository and updating apt-get.
8dpkg -s amulet
9if [ $? -ne 0 ]; then
10 sudo add-apt-repository -y ppa:juju/stable
11 sudo apt-get update
12 sudo apt-get install -y amulet
13fi
14
15# Install any additional python packages, or software here.
16sudo apt-get install -y python python-pika python3-requests
017
=== added file 'tests/10_basic_deploy_test.py'
--- tests/10_basic_deploy_test.py 1970-01-01 00:00:00 +0000
+++ tests/10_basic_deploy_test.py 2015-01-12 15:19:55 +0000
@@ -0,0 +1,101 @@
1#!/usr/bin/python3
2
3# This Amulet test performs a basic deploy and checks if rabbitmq is running.
4
5import amulet
6import os
7import socket
8import ssl
9
10# The number of seconds to wait for the environment to setup.
11seconds = 900
12# Get the directory in this way to load the files from the tests directory.
13path = os.path.abspath(os.path.dirname(__file__))
14
15key_path = os.path.join(path, 'rabbit-server-privkey.pem')
16# Read the private key file.
17with open(key_path) as f:
18 privateKey = f.read()
19# Read the certificate file.
20cert_path = os.path.join(path, 'rabbit-server-cert.pem')
21with open(cert_path) as f:
22 certificate = f.read()
23
24# Create a dictionary for the rabbitmq configuration.
25rabbitmq_configuration = {
26 'ssl_enabled': True,
27 'ssl_key': privateKey,
28 'ssl_cert': certificate,
29 'ssl_port': 5671
30}
31
32d = amulet.Deployment()
33# Add the rabbitmq-server charm to the deployment.
34d.add('rabbitmq-server')
35# Configure options on the rabbitmq-server.
36d.configure('rabbitmq-server', rabbitmq_configuration)
37# Expose the server so we can connect.
38d.expose('rabbitmq-server')
39
40try:
41 # Execute the deployer with the current mapping.
42 d.setup(timeout=seconds)
43except amulet.helpers.TimeoutError:
44 message = 'The environment did not setup in %d seconds.' % seconds
45 # The SKIP status enables skip or fail the test based on configuration.
46 amulet.raise_status(amulet.SKIP, msg=message)
47except:
48 raise
49print('The rabbitmq-server has been successfully deployed.')
50
51###############################################################################
52## Verify that the rabbit service is running on the deployed server.
53###############################################################################
54rabbitmq_sentry = d.sentry.unit['rabbitmq-server/0']
55# Get the public address for rabbitmq-server instance.
56server_address = rabbitmq_sentry.info['public-address']
57# Create the command that checks if the rabbitmq-server service is running.
58command = 'rabbitmqctl status'
59print(command)
60# Execute the command on the deployed service.
61output, code = rabbitmq_sentry.run(command)
62print(output)
63# Check the return code for the success and failure of this test.
64if (code != 0):
65 message = 'The ' + command + ' did not return the expected code of 0.'
66 amulet.raise_status(amulet.FAIL, msg=message)
67else:
68 print('The rabbitmq-server is running on %s' % server_address)
69
70###############################################################################
71## Test the ssl certificate.
72###############################################################################
73# Get the port for ssl_port instance.
74server_port = rabbitmq_configuration['ssl_port']
75
76# Get the path to the certificate authority file.
77ca_cert_path = os.path.join(path, 'rabbit-server-cacert.pem')
78
79print('Testing ssl connection to rabbitmq-server.')
80try:
81 # Create a normal socket.
82 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
83 # Require a certificate from the server, since a self-signed certificate
84 # was used, the ca_certs must be the server certificate file itself.
85 ssl_sock = ssl.wrap_socket(s, ca_certs=ca_cert_path,
86 cert_reqs=ssl.CERT_REQUIRED)
87 # Connect to the rabbitmq server using ssl.
88 ssl_sock.connect((server_address, server_port))
89 # Get the certificate.
90 certificate = ssl_sock.getpeercert()
91 # SSL socket connected and got the certificate, this passes the ssl test!
92 print('Connected to the rabbitmq-server {0}:{1} using ssl!'.format(
93 server_address, server_port))
94except Exception as e:
95 message = 'Failed to create an ssl connection to {0}:{1}\n{2}'.format(
96 server_address, server_port, str(e))
97 amulet.raise_status(amulet.FAIL, msg=message)
98finally:
99 ssl_sock.close()
100
101print('The rabbitmq-server passed the basic deploy test!')
0102
=== added file 'tests/20_deploy_relations_test.py'
--- tests/20_deploy_relations_test.py 1970-01-01 00:00:00 +0000
+++ tests/20_deploy_relations_test.py 2015-01-12 15:19:55 +0000
@@ -0,0 +1,214 @@
1#!/usr/bin/python3
2
3# This Amulet test deploys rabbitmq-server, and the related charms.
4
5import amulet
6import os
7import subprocess
8import time
9
10# The number of seconds to wait for the environment to setup.
11seconds = 900
12# The number of units to scale rabbitmq-server to.
13scale = 2
14# The port that amqp traffic is sent on.
15amqp_port = '5672'
16# The directory to use as a block devie for the ceph
17devices = '/srv/osd1'
18# The default version of ceph does not support directories as devices.
19havana = 'cloud:precise-updates/havana'
20# Create a dictionary of configuration values for ceph.
21ceph_configuration = {
22 'fsid': 'ecbb8960-0e21-11e2-b495-83a88f44db01',
23 'monitor-secret': 'AQBomftSyK1LORAAhg71ukxBxN9ml90stexqEw==',
24 'osd-devices': devices,
25 'source': havana
26}
27# Create a dictionary of configuration values for cinder.
28cinder_configuration = {
29 'block-device': 'None'
30}
31# Create a dictionary of the rabbit configuration values.
32rabbit_configuration = {
33 'vip': '192.168.77.11',
34 'vip_cidr': 19,
35 'vip_iface': 'eth0',
36 'ha-bindiface': 'eth0',
37 'ha-mcastport': 5406,
38 'rbd-size': '2G',
39 'rbd-name': 'testrabbit1'
40}
41
42# The AMQP package is only available for python version 2.x.
43python2 = '/usr/bin/python'
44if not os.path.isfile(python2):
45 error_message = 'Error, python version 2 is required for this test.'
46 amulet.raise_status(amulet.FAIL, msg=error_message)
47
48d = amulet.Deployment()
49# Add rabbitmq-server to the deployment.
50d.add('rabbitmq-server', units=scale)
51# Add the ceph charm to the deployment.
52d.add('ceph')
53# Add cinder to the deployment to test the AMQP relation.
54d.add('cinder')
55# Add hacluster to the deployment to test the ha relation.
56d.add('hacluster')
57# The ceph charm requires configuration to deploy successfully.
58d.configure('ceph', ceph_configuration)
59# Configure the cinder charm.
60d.configure('cinder', cinder_configuration)
61# Configure the rabbit charm.
62d.configure('rabbitmq-server', rabbit_configuration)
63# Add relation from rabbitmq-server to ceph testing the ceph relation.
64d.relate('rabbitmq-server:ceph', 'ceph:client')
65# Add relation from rabbitmq-server to cinder testing the amqp relation.
66d.relate('rabbitmq-server:amqp', 'cinder:amqp')
67# Add relation from rabibtmq-server to hacluster testing the ha relation.
68d.relate('rabbitmq-server:ha', 'hacluster:ha')
69# Expose the rabbitmq-server.
70d.expose('rabbitmq-server')
71
72try:
73 # Execute the deployer with the current mapping.
74 d.setup(timeout=seconds)
75 # Wait for the relation to finish the transations.
76 d.sentry.wait(seconds)
77except amulet.helpers.TimeoutError:
78 message = 'The environment did not setup in %d seconds.' % seconds
79 # The SKIP status enables skip or fail the test based on configuration.
80 amulet.raise_status(amulet.FAIL, msg=message)
81except:
82 raise
83print('The environment successfully deployed.')
84
85# Create a counter to make the messages unique.
86counter = 1
87# Get the directory in this way to load the files from the tests directory.
88path = os.path.abspath(os.path.dirname(__file__))
89# Create a path to the python test file to call.
90amqp_tester = os.path.join(path, 'amqp_tester.py')
91if not os.path.isfile(amqp_tester):
92 error_message = 'Unable to locate python test file %s' % amqp_tester
93 amulet.raise_status(amulet.FAIL, msg=error_message)
94
95# Verify the ceph unit was created.
96ceph_unit = d.sentry.unit['ceph/0']
97# Verify the cinder unit was created.
98cinder_unit = d.sentry.unit['cinder/0']
99rabbit_units = []
100for n in range(scale):
101 # Get each rabbitmq unit that was deployed.
102 rabbit_units.append(d.sentry.unit['rabbitmq-server/%d' % n])
103
104# Iterate over every rabbitmq-unit to get the different relations.
105for rabbit_unit in rabbit_units:
106 ###########################################################################
107 ## Test Relations
108 ###########################################################################
109 # Verify the ceph relation was created for the rabbit unit.
110 rabbit_relation = rabbit_unit.relation('ceph', 'ceph:client')
111 print('rabbit relation to ceph:')
112 for key, value in rabbit_relation.items():
113 print(key, value)
114 # Verify the amqp relation was created for the rabbit unit.
115 rabbit_relation = rabbit_unit.relation('amqp', 'cinder:amqp')
116 print('rabbit relation to amqp:')
117 for key, value in rabbit_relation.items():
118 print(key, value)
119
120 # The hacluster charm is a subordinate, since the relation-sentry is also
121 # a subordinate charm no sentry is created for the hacluster relation.
122
123 # Verify the rabbit relation was created with the ceph unit.
124 ceph_relation = ceph_unit.relation('client', 'rabbitmq-server:ceph')
125 print('ceph relation to rabbitmq-server:')
126 for key, value in ceph_relation.items():
127 print(key, value)
128 # Verify the rabbit relation was created with the cinder unit.
129 cinder_relation = cinder_unit.relation('amqp', 'rabbitmq-server:amqp')
130 print('cinder relation to rabbitmq-server:')
131 for key, value in cinder_relation.items():
132 print(key, value)
133
134 ###########################################################################
135 ## Test AMQP
136 ###########################################################################
137
138 # The AMQP python library is only available for python2 at this time.
139 # Call out a command to run the python2 code to test the AMQP protocol.
140
141 # Get the public address for rabbitmq-server instance.
142 server_address = rabbit_unit.info['public-address']
143 # Create a time stamp to help make the AMQP message unique.
144 time_stamp = time.strftime('%F %r')
145 # Create the message to send on the AMPQ protocol.
146 amqp_message = "Message #{0} to send using the AMPQ protocol {1}".format(
147 counter, time_stamp)
148 # Create the command with arguments that sends the message.
149 send_command = [python2, amqp_tester, server_address, amqp_port,
150 amqp_message]
151 print(send_command)
152 # Call the python command to send the AMQP message to the server.
153 output = subprocess.check_output(send_command)
154 # Create the command with arguments to receive messages.
155 receive_command = [python2, amqp_tester, server_address, amqp_port]
156 print(receive_command)
157 # Call the python command to receive the AMQP message from the same server.
158 output = subprocess.check_output(receive_command)
159 # The output is a byte string so convert the message to a byte string.
160 if output.find(amqp_message.encode()) == -1:
161 print('The AMQP test to {0}:{1} failed.'.format(server_address,
162 amqp_port))
163 amulet.raise_status(amulet.FAIL, msg=output)
164 else:
165 print('The AMQP test to {0}:{1} completed successfully.'.format(
166 server_address, amqp_port))
167 counter += 1
168
169 ###########################################################################
170 ## Verify that the rabbitmq cluster status is correct.
171 ###########################################################################
172 # Create the command that checks if the rabbitmq-server service is running.
173 command = 'rabbitmqctl cluster_status'
174 print(command)
175 # Execute the command on the deployed service.
176 output, code = rabbit_unit.run(command)
177 print(output)
178 # Check the return code for the success and failure of this test.
179 if (code != 0):
180 message = 'The ' + command + ' did not return the expected code of 0.'
181 amulet.raise_status(amulet.FAIL, msg=message)
182 else:
183 print('The rabbitmq-server cluster status is OK.')
184
185###############################################################################
186## Test the AMQP messages can be sent from and read from another.
187###############################################################################
188# Get the public address for rabbitmq-server instance 0.
189send_address = rabbit_units[0].info['public-address']
190# Create a message to send from instance 0 and read it from instance 1.
191amqp_message = "Message #{0} sent from {1} using the AMQP protocol.".format(
192 counter, send_address)
193counter += 1
194# Create the command that sends the message to instance 0.
195send_command = [python2, amqp_tester, send_address, amqp_port, amqp_message]
196print(send_command)
197output = subprocess.check_output(send_command)
198# Get the public address for rabbitmq-server instance 1.
199receive_address = rabbit_units[1].info['public-address']
200# Create the command that receives the message from instance 1.
201recieve_command = [python2, amqp_tester, receive_address, amqp_port]
202print(recieve_command)
203output = subprocess.check_output(receive_command)
204# The output is a byte string so convert the message to a byte string.
205if output.find(amqp_message.encode()) == -1:
206 print(output)
207 message = 'Server {0} did not receive the AMQP message "{1}"'.format(
208 receive_address, amqp_message)
209 amulet.raise_status(amulet.FAIL, msg=message)
210else:
211 print('Server {0} received the AMQP message sent from {1}'.format(
212 receive_address, send_address))
213
214print('The rabbitmq-server charm passed this relations test.')
0215
=== added file 'tests/30_configuration_test.py'
--- tests/30_configuration_test.py 1970-01-01 00:00:00 +0000
+++ tests/30_configuration_test.py 2015-01-12 15:19:55 +0000
@@ -0,0 +1,142 @@
1#!/usr/bin/python3
2
3# This Amulet test exercises the configuration options for rabbitmq-server.
4
5import amulet
6import os
7import requests
8import socket
9import ssl
10
11# The number of seconds to wait for the environment to setup.
12seconds = 900
13# Get the directory in this way to load the files from the tests directory.
14path = os.path.abspath(os.path.dirname(__file__))
15key_path = os.path.join(path, 'rabbit-server-privkey.pem')
16# Read the private key file.
17with open(key_path) as f:
18 privateKey = f.read()
19cert_path = os.path.join(path, 'rabbit-server-cert.pem')
20# Read the certificate file.
21with open(cert_path) as f:
22 certificate = f.read()
23
24# Create a dictionary of all the configuration values.
25rabbit_configuration = {
26 'management_plugin': True,
27 'ssl_enabled': True,
28 'ssl_port': 5999,
29 'ssl_key': privateKey,
30 'ssl_cert': certificate
31}
32
33d = amulet.Deployment()
34# Add the rabbitmq-server charm to the deployment.
35d.add('rabbitmq-server')
36# Configure all the options on rabbitmq-server.
37d.configure('rabbitmq-server', rabbit_configuration)
38# Expose the rabbitmq-server.
39d.expose('rabbitmq-server')
40
41try:
42 # Execute the deployer with the current mapping.
43 d.setup(timeout=seconds)
44 # Wait for the relation to finish the transations.
45 #d.sentry.wait(seconds)
46except amulet.helpers.TimeoutError:
47 message = 'The environment did not setup in %d seconds.' % seconds
48 # The SKIP status enables skip or fail the test based on configuration.
49 amulet.raise_status(amulet.SKIP, msg=message)
50except:
51 raise
52
53rabbit_unit = d.sentry.unit['rabbitmq-server/0']
54###############################################################################
55## Verify that the rabbit service is running on the deployed server.
56###############################################################################
57# Create the command that checks if the rabbitmq-server service is running.
58command = 'rabbitmqctl status'
59print(command)
60# Execute the command on the deployed service.
61output, code = rabbit_unit.run(command)
62print(output)
63# Check the return code for the success and failure of this test.
64if (code != 0):
65 message = 'The ' + command + ' did not return the expected code of 0.'
66 amulet.raise_status(amulet.FAIL, msg=message)
67else:
68 print('The rabbitmq-server is running.')
69
70###############################################################################
71## Verify the configuration values.
72###############################################################################
73# Get the contents of the private key from the rabbitmq-server
74contents = rabbit_unit.file_contents('/etc/rabbitmq/rabbit-server-privkey.pem')
75# Verify the private key was saved on the rabbitmq server correctly.
76if contents != privateKey:
77 message = 'The private keys did not match!'
78 amulet.raise_status(amulet.FAIL, msg=message)
79else:
80 print('The private keys was configured properly on the rabbitmq server.')
81
82# Get the contents of the certificate from the rabbitmq-server.
83contents = rabbit_unit.file_contents('/etc/rabbitmq/rabbit-server-cert.pem')
84# Verify the certificate was saved on the rabbitmq server correctly.
85if contents != certificate:
86 message = 'The certificates did not match!'
87 amulet.raise_status(amulet.FAIL, msg=message)
88else:
89 print('The certificate was configured properly on the rabbitmq server.')
90
91# Get the public address for rabbitmq-server instance.
92rabbit_host = rabbit_unit.info['public-address']
93
94###############################################################################
95## Verify the management plugin is running and responding on correct port.
96## According to this: http://www.rabbitmq.com/access-control.html
97## The guest account can only log in from local host.
98## Since this test runs on a different system there is no way to test
99## the management plugin.
100###############################################################################
101# Create a url for the rabbitmq server's managment plugin (uses 55672).
102#management_url = 'http://{0}:55672'.format(rabbit_host)
103#print(management_url)
104# Get the management url with the authentication for guest.
105#r = requests.get(management_url, auth=('guest', 'guest'))
106# Raise an exception if response is not 200 OK.
107#r.raise_for_status()
108#print(str(r))
109#print('Successfully authenticated to the management console at %s' %
110# management_url)
111
112###############################################################################
113## Verify that SSL is set up on the non-default port.
114###############################################################################
115# Get the port for ssl_port instance.
116ssl_port = rabbit_configuration['ssl_port']
117
118# Get the path to the certificate authority file.
119ca_cert_path = os.path.join(path, 'rabbit-server-cacert.pem')
120
121try:
122 # Create a normal socket.
123 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
124 # Require a certificate from the server, since a self-signed certificate
125 # was used, the ca_certs must be the server certificate file itself.
126 ssl_sock = ssl.wrap_socket(s, ca_certs=ca_cert_path,
127 cert_reqs=ssl.CERT_REQUIRED)
128 # Connect to the rabbitmq server using ssl.
129 ssl_sock.connect((rabbit_host, ssl_port))
130 # Get the certificate.
131 certificate = ssl_sock.getpeercert()
132 # SSL scoket connected and got the certificate, this passes the ssl test!
133 print('Connected to the rabbitmq-server {0}:{1} using ssl!'.format(
134 rabbit_host, ssl_port))
135except Exception as e:
136 message = 'Failed to create an ssl connection to {0}:{1}\n{2}'.format(
137 rabbit_host, ssl_port, str(e))
138 amulet.raise_status(amulet.FAIL, msg=message)
139finally:
140 ssl_sock.close()
141
142print('The rabbitmq-server passed the configuration tests.')
0143
=== added file 'tests/amqp_tester.py'
--- tests/amqp_tester.py 1970-01-01 00:00:00 +0000
+++ tests/amqp_tester.py 2015-01-12 15:19:55 +0000
@@ -0,0 +1,65 @@
1#!/usr/bin/python
2
3# This class uses Python to make AMQP calls to send and receive messages.
4# To send an AMQP message call this module with a host, port, and message.
5# To receive an AMQP message call this module with a host and port only.
6
7import logging
8import pika
9import sys
10
11
12def send(host, port, message, queue='test'):
13 """ Send an AMQP message to a host and port."""
14 connection = None
15 try:
16 parameters = pika.ConnectionParameters(host, port)
17 connection = pika.BlockingConnection(parameters)
18
19 channel = connection.channel()
20 channel.queue_declare(queue)
21 channel.basic_publish(exchange='', routing_key=queue, body=message)
22 print('Message published to {0}:{1}'.format(host, port))
23 except Exception as e:
24 print('Unable to send message to {0}:{1}'.format(host, port))
25 print(e)
26 finally:
27 if connection:
28 connection.close()
29
30
31def callback(ch, method, properties, body):
32 """ Handle the callback when the channel receives a message. """
33 print(body)
34
35
36def receive(host, port, queue='test'):
37 """ Connects to host and port, and consumes AMQP messages. """
38 connection = None
39 try:
40 parameters = pika.ConnectionParameters(host, port)
41 connection = pika.BlockingConnection(parameters)
42 channel = connection.channel()
43 channel.queue_declare(queue)
44 channel.basic_consume(callback, queue, no_ack=True)
45 except Exception as e:
46 print('Unable to receive message from {0}:{1}'.format(host, port))
47 print(e)
48 finally:
49 if connection:
50 connection.close()
51
52# Needed to disable pika complaining about logging levels not set.
53logging.basicConfig(level=logging.ERROR)
54
55if len(sys.argv) == 3:
56 host = sys.argv[1]
57 port = int(sys.argv[2])
58 receive(host, port)
59elif len(sys.argv) > 3:
60 host = sys.argv[1]
61 port = int(sys.argv[2])
62 message = ' '.join(sys.argv[3:])
63 send(host, port, message)
64else:
65 print('Not enough arguments, host and port are required.')
066
=== added file 'tests/rabbit-server-cacert.pem'
--- tests/rabbit-server-cacert.pem 1970-01-01 00:00:00 +0000
+++ tests/rabbit-server-cacert.pem 2015-01-12 15:19:55 +0000
@@ -0,0 +1,17 @@
1-----BEGIN CERTIFICATE-----
2MIICxjCCAa6gAwIBAgIJAIOIZyP0JpvLMA0GCSqGSIb3DQEBBQUAMBMxETAPBgNV
3BAMTCE15VGVzdENBMB4XDTE0MDIyMzIwMDgxOFoXDTE1MDIyMzIwMDgxOFowEzER
4MA8GA1UEAxMITXlUZXN0Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
5AQDceXBJOhn9d68M9UiOViWz00Znds1xk9i+GbZFEsqLPkoReS9g/SeXvR5ZFZlU
65gzAcg8z8b+n26wgZLFQJ4wQAIVELIu0S6e4sUPKfKl/fo9NmRVv/sPkfZWUZ5sc
7d9DEk8MiNYjjXT+Ff4TV7DFxdDOJLIDrc09JWzIKrmfOXP5wLFCsIllGbellfNvY
8FxiHHm3Iz5t3t077+uUXeMD5p1Qd2qQdbJ2p8Dwkg2AyTPNG8RA71tEMIT7FX0nB
9sTX5M217ocdEZJI67x+3Z8Ll21m6blcnJI3V3Zk5kvccvYRlDuyGh7tiWcv4YKmv
10xuP64L9174nQ3HXnwipfjBkBAgMBAAGjHTAbMAwGA1UdEwQFMAMBAf8wCwYDVR0P
11BAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQAaQWYVUuPKRtAFd6kyugL/UpVhIa/o
12zfm/2b23UviPA1TIYzzf4m1eDV7kxJynOeP1RRPp166el+sVx7+vqhBsqcm4b5e+
13epShI3jff0gtODxo5rUVrROS3T6xjHA7AVm60/xmGIIybhDonXzA5YJ8YVBpHUdZ
14Yc2neOwdDT8k/H95cPXBU3pf3vTVpndjN827fBuyO7KwKDAiKHwtwmSedc1uZtLN
15sfwkonXF+gNAHXlk28VeygGQ1jHdloIrNG0zYc4ZX4zqPHd7HDeyYItBBHjrznow
16nf1X6fNjP4YnG5EkUN8hRXf3ct+L8iq8puMNhjb8ssW+bsFRBIufVFaC
17-----END CERTIFICATE-----
018
=== added file 'tests/rabbit-server-cert.pem'
--- tests/rabbit-server-cert.pem 1970-01-01 00:00:00 +0000
+++ tests/rabbit-server-cert.pem 2015-01-12 15:19:55 +0000
@@ -0,0 +1,18 @@
1-----BEGIN CERTIFICATE-----
2MIIC5TCCAc2gAwIBAgIBATANBgkqhkiG9w0BAQUFADATMREwDwYDVQQDEwhNeVRl
3c3RDQTAeFw0xNDAyMjMyMDA5MjFaFw0xNTAyMjMyMDA5MjFaMCgxFTATBgNVBAMM
4DHJlYWxtcy1zbGljZTEPMA0GA1UECgwGc2VydmVyMIIBIjANBgkqhkiG9w0BAQEF
5AAOCAQ8AMIIBCgKCAQEApc6WxtgQZL+PcDHL1S/kLqFyGPaKiJQrOPGYq9djM5pr
6VGPHUZ3F26VWtlBtPB8PgQFT10Sjr+ec7hC9aqT+THyNq2U8qCizGq4l4e44tfEI
7LPuE9IluF/dZuVWFR2nbVYp3FeAjuRQ68AwzpcZOXVup3xsXx7dJrGL4KUx/7NUb
85+6TzboM1nXX7o/DYCE5BvXncM7U3cLg16SV58T6Rs+JYATAFdzveN6X88AgvQpB
9rDSD42tSQmQzYu9mO2RwtP48jLvYLHv34dZo2h6G5zNWe/PkUjXxKEGJXHkeXy83
10vx4UV62Vo8pMLeSSqL4wUV3KMRHJ+MBskP42lmruwQIDAQABoy8wLTAJBgNVHRME
11AjAAMAsGA1UdDwQEAwIFIDATBgNVHSUEDDAKBggrBgEFBQcDATANBgkqhkiG9w0B
12AQUFAAOCAQEArEFhWRHb1Nn1ACDNXbRueiMSdqwWtiAEU4yAFB+1maKyAG1VAQC2
13IegIJ7INbzfwDp6CzNpI3CCyelNO2rcBGwOlXre6XA5K7TxKM6WLJDdodPUt30dY
143+/DF/XwH5S/C4oGbeRVWxzCBAFbStMlJqpXFIQkAYYCOfvWKoZzSslxGe7Zj+hQ
15NYqJbc8BDe0UTyM8KoL9OWucEbdQMQgn0FxwAPqSLXgDkpSo6XHKL15MUbES1u5/
16iT9gRJU1eN+bIWfrJA3dqh4JxXntTLDZ28pBdFtOV4WEF2O4fmxGiSktCi34tjK6
17DsIScb+0mUeKS9b2cyQzLSUCwj8LgJW3rQ==
18-----END CERTIFICATE-----
019
=== added file 'tests/rabbit-server-privkey.pem'
--- tests/rabbit-server-privkey.pem 1970-01-01 00:00:00 +0000
+++ tests/rabbit-server-privkey.pem 2015-01-12 15:19:55 +0000
@@ -0,0 +1,27 @@
1-----BEGIN RSA PRIVATE KEY-----
2MIIEpAIBAAKCAQEApc6WxtgQZL+PcDHL1S/kLqFyGPaKiJQrOPGYq9djM5prVGPH
3UZ3F26VWtlBtPB8PgQFT10Sjr+ec7hC9aqT+THyNq2U8qCizGq4l4e44tfEILPuE
49IluF/dZuVWFR2nbVYp3FeAjuRQ68AwzpcZOXVup3xsXx7dJrGL4KUx/7NUb5+6T
5zboM1nXX7o/DYCE5BvXncM7U3cLg16SV58T6Rs+JYATAFdzveN6X88AgvQpBrDSD
642tSQmQzYu9mO2RwtP48jLvYLHv34dZo2h6G5zNWe/PkUjXxKEGJXHkeXy83vx4U
7V62Vo8pMLeSSqL4wUV3KMRHJ+MBskP42lmruwQIDAQABAoIBAE6jo/ldQrE19acF
8xyIum6/OHJpgXCYY+EMCuyFNf5xa8erNhBxekxfw3CaOELECHk1WPtiLkoL8e/6h
9a+UnqgDG1j5jPpiW7ROLYyY74SPR1MnY5R9CCzhMtX5kZFkRiNiSWpbCfs7qHGX7
10s4c9fa9jqTbK18V+Ve/v5LlZsha13OQRISQLqZlCM6vKRtHZorQHZVM1KIV4bzdP
1175/YTrhUA8GKGA+4Le5vZ1PQY8ubTAXPHeeqILvClsmkZ6k0RC/zesB3DUXzMvjA
12ycbarcpZ+muxyp0Icuv9B7pj3iT/dL4udc+BM82Qg3KvLLiteE9aeOPsW3aJxAHa
13YYLLCQECgYEA2EUF4QVgJE1U6RHFsRO6xP1KBJO0mVMMlEpgywPV3oN7D5gOVrCK
14A/iNkyt2ggaX2o2+QHMe+WjINdMLhY6TdhRiYrUQhLteNSrp0w/HDYyY2Cz1IhH3
15Y/0qHm9rGZhetOWoJ5Ejn/9vnL/ZfsGfSNzwS1VjCUHyXShebS9NHRECgYEAxERZ
165HX3zctB2lzzS8KTNAWijUc+hc8c0LV/GcCC8LMsUPNb/V+wQNiSInJa994YI5+9
171BkJkw4Lnexvx8GQPaAkX6DzZsWSmwaNSkLICd75f2ga4dqeohWOAIvS3xb4fanr
18szCLZfd4L8MEb6lVI2wzpM5yADK42y/w03t0drECgYBvDAn3v93c5gRKZIDA6uOE
190JXYAcvCypzz67kFpSOEzLg8ipQaOS202kQ/pBqGq0H/y7Y7u6DU6dObp5EL8+iN
20weu+yUABF4BJBo7ne/t2XpIAthzscJM5uT2OQSGaE93VPvL31hOXzP4PW4cfCeZy
218FdGJ0Lh9wWuhdLud1I+MQKBgQC7CwzEPmy38mJC8VxoMfnJlSkyDNiX+ybR/HYx
22m5buP0MXrqVXVe8KDZtPOr5ZBI7qvFzTmjzWqYcGrQJmU6DcKhcgD6qHofiyx061
23m+k6BwatlhAweAHAJFydRqPjOef9Eofu0G+48FvY4LkElVLvHDoncRuR9sTXFtwj
24H7+BMQKBgQDNWXHeXi4bYm17KsBHpK+DMT6O9cF1BqYpgbqLyro554ZjYLYpt0li
25iiekhVM55NpWlbsOfje0lhD8mr0ZYzW+SmWd/XMj03ZF9EeOBHx8SvWemsrz69Es
26wAjiQtQoZlvczaLOHLV89p9EaK3OA1trqjAkqq9GFdLBVmG/zVzSaQ==
27-----END RSA PRIVATE KEY-----

Subscribers

People subscribed via source and target branches