Fix remaining amulet issues, lint, and http proxy settings for the
20-different-repositories test.
This commit is contained in:
parent
1cdae617e2
commit
893f14f3ca
3
Makefile
3
Makefile
|
@ -16,7 +16,8 @@ clean:
|
|||
.venv/bin/pip install -I -r test-requirements.txt
|
||||
|
||||
lint: .venv
|
||||
@.venv/bin/flake8 --exclude hooks/charmhelpers hooks unit_tests
|
||||
@.venv/bin/flake8 --exclude hooks/charmhelpers,tests/charmhelpers hooks \
|
||||
unit_tests tests
|
||||
@charm proof
|
||||
|
||||
bin/charm_helpers_sync.py:
|
||||
|
|
|
@ -43,7 +43,7 @@ except:
|
|||
print('The rabbitmq-server has been successfully deployed.')
|
||||
|
||||
###############################################################################
|
||||
## Verify that the rabbit service is running on the deployed server.
|
||||
# Verify that the rabbit service is running on the deployed server.
|
||||
###############################################################################
|
||||
rabbitmq_sentry = d.sentry.unit['rabbitmq-server/0']
|
||||
# Get the public address for rabbitmq-server instance.
|
||||
|
@ -62,7 +62,7 @@ else:
|
|||
print('The rabbitmq-server is running on %s' % server_address)
|
||||
|
||||
###############################################################################
|
||||
## Test the ssl certificate.
|
||||
# Test the ssl certificate.
|
||||
###############################################################################
|
||||
# Get the port for ssl_port instance.
|
||||
server_port = rabbitmq_configuration['ssl_port']
|
||||
|
|
|
@ -1,7 +1,25 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import amulet
|
||||
import os
|
||||
import pika
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
# The juju environment should be bootstrapped at this point, but depending
|
||||
# on the test environment an http proxy may be necessary. Check to see if
|
||||
# one is configured via the environment variable and set it if it is.
|
||||
# The settings of these proxy variables should only survive the current
|
||||
# lifetime of the bootstrapped environment and will be torn down for the
|
||||
# next test.
|
||||
if os.environ['AMULET_HTTP_PROXY']:
|
||||
proxy_setting = 'http-proxy={}'.format(os.environ['AMULET_HTTP_PROXY'])
|
||||
subprocess.call(['juju', 'set-env', proxy_setting])
|
||||
|
||||
if os.environ['AMULET_HTTPS_PROXY']:
|
||||
proxy_setting = 'https-proxy={}'.format(os.environ['AMULET_HTTPS_PROXY'])
|
||||
subprocess.call(['juju', 'set-env', proxy_setting])
|
||||
|
||||
|
||||
d = amulet.Deployment(series='trusty')
|
||||
|
||||
|
@ -37,7 +55,8 @@ pqQ5UJlqbB5FGLnwJ0773WzgRdxIwSIxkFhL/Mq4agf4an8151kqcZCISQQYEQIA
|
|||
CQUCRo5D+wIbDAAKCRD3uM6mBW6OVhLmAKCYY152B/10n7aUNKejs92NsNAnPACf
|
||||
ZwbDOKBXGfkCPuRx5j/AGneASNU=
|
||||
=Ry+c
|
||||
-----END PGP PUBLIC KEY BLOCK-----"""
|
||||
-----END PGP PUBLIC KEY BLOCK-----""",
|
||||
"management_plugin": True,
|
||||
})
|
||||
d.expose('rabbitmq-server')
|
||||
|
||||
|
@ -58,6 +77,14 @@ except:
|
|||
server = d.sentry.unit['rabbitmq-server/0']
|
||||
host = server.info['public-address']
|
||||
|
||||
# TODO(wolsen) It looks like in rabbitmq version 3.3.0 the guest count was
|
||||
# disabled by default and therefore we need to do the following bit of code
|
||||
# in order to allow guest access for the test to succeed.
|
||||
server.run('echo "[{rabbit, [{loopback_users, []}]}]." > '
|
||||
'/etc/rabbitmq/rabbitmq.config')
|
||||
server.run('service rabbitmq-server restart')
|
||||
|
||||
|
||||
try:
|
||||
connection = pika.BlockingConnection(pika.ConnectionParameters(host=host))
|
||||
except Exception as e:
|
||||
|
|
|
@ -141,7 +141,7 @@ for n in range(scale):
|
|||
# Iterate over every rabbitmq-unit to get the different relations.
|
||||
for rabbit_unit in rabbit_units:
|
||||
###########################################################################
|
||||
## Test Relations
|
||||
# Test Relations
|
||||
###########################################################################
|
||||
# Verify the ceph relation was created for the rabbit unit.
|
||||
rabbit_relation = rabbit_unit.relation('ceph', 'ceph:client')
|
||||
|
@ -169,7 +169,7 @@ for rabbit_unit in rabbit_units:
|
|||
print(key, value)
|
||||
|
||||
###########################################################################
|
||||
## Test AMQP
|
||||
# Test AMQP
|
||||
###########################################################################
|
||||
|
||||
# The AMQP python library is only available for python2 at this time.
|
||||
|
@ -204,7 +204,7 @@ for rabbit_unit in rabbit_units:
|
|||
counter += 1
|
||||
|
||||
###########################################################################
|
||||
## Verify that the rabbitmq cluster status is correct.
|
||||
# Verify that the rabbitmq cluster status is correct.
|
||||
###########################################################################
|
||||
# Create the command that checks if the rabbitmq-server service is running.
|
||||
command = 'rabbitmqctl cluster_status'
|
||||
|
@ -220,7 +220,7 @@ for rabbit_unit in rabbit_units:
|
|||
print('The rabbitmq-server cluster status is OK.')
|
||||
|
||||
###############################################################################
|
||||
## Test the AMQP messages can be sent from and read from another.
|
||||
# Test the AMQP messages can be sent from and read from another.
|
||||
###############################################################################
|
||||
# Get the public address for rabbitmq-server instance 0.
|
||||
send_address = rabbit_units[0].info['public-address']
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
import amulet
|
||||
import pika
|
||||
import time
|
||||
import datetime
|
||||
|
||||
d = amulet.Deployment(series='trusty')
|
||||
|
||||
|
@ -29,12 +28,9 @@ host = server.info['public-address']
|
|||
|
||||
|
||||
# Connects without ssl
|
||||
print("Running tests with SSL disabled...")
|
||||
try:
|
||||
print("Attempting to connect to {}...".format(host))
|
||||
connection = pika.BlockingConnection(pika.ConnectionParameters(host=host,
|
||||
ssl=False))
|
||||
print("Successfully connected.")
|
||||
except Exception as e:
|
||||
amulet.raise_status(
|
||||
amulet.FAIL,
|
||||
|
@ -43,11 +39,9 @@ except Exception as e:
|
|||
|
||||
# Doesn't connect with ssl
|
||||
try:
|
||||
print("Attempting to connect securely...")
|
||||
connection = pika.BlockingConnection(pika.ConnectionParameters(host=host,
|
||||
ssl=True))
|
||||
except Exception as e:
|
||||
print("Successfully did NOT connect.")
|
||||
pass
|
||||
else:
|
||||
amulet.raise_status(
|
||||
|
@ -55,26 +49,21 @@ else:
|
|||
'SSL enabled when it shouldn\'t.'
|
||||
)
|
||||
|
||||
print("Setting ssl=on...")
|
||||
d.configure('rabbitmq-server', {
|
||||
'ssl': 'on'
|
||||
})
|
||||
|
||||
# Requires rabbit to come back up, let's give it a few seconds
|
||||
time.sleep(10)
|
||||
|
||||
# There's a race for changing the configuration of a deployment.
|
||||
# The configure from the juju client side happens fairly quickly, and the
|
||||
# sentry.wait() can fire before the config-changed hooks do, which causes
|
||||
# the wait to end...
|
||||
time.sleep(10)
|
||||
d.sentry.wait()
|
||||
|
||||
# Connects without ssl
|
||||
try:
|
||||
print("Attempting to connect insecurely with ssl=on...")
|
||||
connection = pika.BlockingConnection(pika.ConnectionParameters(host=host,
|
||||
ssl=False))
|
||||
print("Successfully connected.")
|
||||
except Exception as e:
|
||||
amulet.raise_status(
|
||||
amulet.FAIL,
|
||||
|
@ -83,34 +72,32 @@ except Exception as e:
|
|||
|
||||
# Connects with ssl
|
||||
try:
|
||||
print("Attempting to connect securely with ssl=on...")
|
||||
connection = pika.BlockingConnection(pika.ConnectionParameters(host=host,
|
||||
port=5671,
|
||||
ssl=True))
|
||||
print("Successfully connected.")
|
||||
except Exception as e:
|
||||
st = str(datetime.datetime.now())
|
||||
amulet.raise_status(
|
||||
amulet.FAIL,
|
||||
"{} Secure connection fails with ssl=on: {}".format(st, str(e))
|
||||
"Secure connection fails with ssl=on"
|
||||
)
|
||||
|
||||
print("Setting ssl=only...")
|
||||
d.configure('rabbitmq-server', {
|
||||
'ssl': 'only'
|
||||
})
|
||||
|
||||
# There's a race for changing the configuration of a deployment.
|
||||
# The configure from the juju client side happens fairly quickly, and the
|
||||
# sentry.wait() can fire before the config-changed hooks do, which causes
|
||||
# the wait to end...
|
||||
time.sleep(10)
|
||||
d.sentry.wait()
|
||||
|
||||
|
||||
# Doesn't connect without ssl
|
||||
try:
|
||||
print("Attmpting to connect insecurely with ssl=only...")
|
||||
connection = pika.BlockingConnection(pika.ConnectionParameters(host=host,
|
||||
ssl=False))
|
||||
except Exception as e:
|
||||
print("Successfully did NOT connect")
|
||||
pass
|
||||
else:
|
||||
amulet.raise_status(
|
||||
|
@ -121,6 +108,7 @@ else:
|
|||
# Connects with ssl
|
||||
try:
|
||||
connection = pika.BlockingConnection(pika.ConnectionParameters(host=host,
|
||||
port=5671,
|
||||
ssl=True))
|
||||
except Exception as e:
|
||||
amulet.raise_status(
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
import amulet
|
||||
import os
|
||||
import requests
|
||||
import socket
|
||||
import ssl
|
||||
from deploy_common import CA
|
||||
|
@ -40,7 +39,7 @@ try:
|
|||
# Execute the deployer with the current mapping.
|
||||
d.setup(timeout=seconds)
|
||||
# Wait for the relation to finish the transations.
|
||||
#d.sentry.wait(seconds)
|
||||
d.sentry.wait(seconds)
|
||||
except amulet.helpers.TimeoutError:
|
||||
message = 'The environment did not setup in %d seconds.' % seconds
|
||||
# The SKIP status enables skip or fail the test based on configuration.
|
||||
|
@ -50,7 +49,7 @@ except:
|
|||
|
||||
rabbit_unit = d.sentry.unit['rabbitmq-server/0']
|
||||
###############################################################################
|
||||
## Verify that the rabbit service is running on the deployed server.
|
||||
# Verify that the rabbit service is running on the deployed server.
|
||||
###############################################################################
|
||||
# Create the command that checks if the rabbitmq-server service is running.
|
||||
command = 'rabbitmqctl status'
|
||||
|
@ -66,7 +65,7 @@ else:
|
|||
print('The rabbitmq-server is running.')
|
||||
|
||||
###############################################################################
|
||||
## Verify the configuration values.
|
||||
# Verify the configuration values.
|
||||
###############################################################################
|
||||
# Get the contents of the private key from the rabbitmq-server
|
||||
contents = rabbit_unit.file_contents('/etc/rabbitmq/rabbit-server-privkey.pem')
|
||||
|
@ -90,25 +89,7 @@ else:
|
|||
rabbit_host = rabbit_unit.info['public-address']
|
||||
|
||||
###############################################################################
|
||||
## Verify the management plugin is running and responding on correct port.
|
||||
## According to this: http://www.rabbitmq.com/access-control.html
|
||||
## The guest account can only log in from local host.
|
||||
## Since this test runs on a different system there is no way to test
|
||||
## the management plugin.
|
||||
###############################################################################
|
||||
# Create a url for the rabbitmq server's managment plugin (uses 55672).
|
||||
#management_url = 'http://{0}:55672'.format(rabbit_host)
|
||||
#print(management_url)
|
||||
# Get the management url with the authentication for guest.
|
||||
#r = requests.get(management_url, auth=('guest', 'guest'))
|
||||
# Raise an exception if response is not 200 OK.
|
||||
#r.raise_for_status()
|
||||
#print(str(r))
|
||||
#print('Successfully authenticated to the management console at %s' %
|
||||
# management_url)
|
||||
|
||||
###############################################################################
|
||||
## Verify that SSL is set up on the non-default port.
|
||||
# Verify that SSL is set up on the non-default port.
|
||||
###############################################################################
|
||||
# Get the port for ssl_port instance.
|
||||
ssl_port = rabbit_configuration['ssl_port']
|
||||
|
|
|
@ -50,5 +50,3 @@ class CA(object):
|
|||
Returns the certificate authority certificate path.
|
||||
"""
|
||||
return os.path.join(self.CA_PATH, 'cacert.pem')
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue