charm-rabbitmq-server/tests/deprecated/20-different-repositories

95 lines
3.8 KiB
Python

#!/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.get('AMULET_HTTP_PROXY', None):
proxy_setting = 'http-proxy={}'.format(os.environ['AMULET_HTTP_PROXY'])
subprocess.call(['juju', 'set-env', proxy_setting])
if os.environ.get('AMULET_HTTPS_PROXY', None):
proxy_setting = 'https-proxy={}'.format(os.environ['AMULET_HTTPS_PROXY'])
subprocess.call(['juju', 'set-env', proxy_setting])
d = amulet.Deployment(series='trusty')
d.add('rabbitmq-server')
d.configure('rabbitmq-server', {
"source": "deb http://www.rabbitmq.com/debian/ testing main",
"key": """-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.6 (GNU/Linux)
mQGiBEaOQ/IRBACs/n609zN+OzlK9qDkFWwYKfPG+BlgqBj5MSy0XE2K8cE3bWSV
2WftTe/TGEfW0hknXt1PyBla0cnO9Up1xCn142vo8bvUug8WjrxLQBBiAf11FAOR
dt9roGe4IWw/Lakgb88re09ZYKmOL9H7MEpvMqtjdWjFSq4zeeGa8rGEswCgnQLb
ZD/MNlUNQwQVCs+vVRdgpzcD+QELSc2EeYl4tef0NiUaZQt+mjFTs3DjQNDTjXao
ETVAqECx4kavcshx5tSE5JbbQPIMiUgh0h9J3z3uZsBVnx6P82aW/QTw+jLhsQry
/i3Z/+pS66mk6EWhAAYF/SPVqM/06BZh0ZvUmeG9WGGJXD9CUN1Wfi2mt42L2zhT
xg3uBACoIs5/GORi0H2i+blLiFSxTroXw+TdxiP+mfjdPho0oXJQTljXBgG70VfX
XW9sWsYtekqXBsmwMcbCZTjZGul/8jAUlUoYfthRw9KpP9N8Q7wB8Flx9jEv0M0H
tV1KTrLuXNZvEAB1sECMa7RRrV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
"management_plugin": True,
})
d.expose('rabbitmq-server')
# Don't forget to expose using d.expose(service)
try:
# TODO(billy-olsen), juju test --timeout fails to pass the timeout values
# into the environment and the charm isn't the best of places to select
# a viable timeout since so muc is attributed to the environment anyways.
# Need to fix this the right way, but for now we'll bump the timeout.
d.setup(timeout=2700)
d.sentry.wait()
except amulet.helpers.TimeoutError:
amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
except:
raise
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:
amulet.raise_status(
amulet.FAIL,
str(e)
)