~le-charmers/charms/trusty/rabbitmq-server/leadership-election

« back to all changes in this revision

Viewing changes to tests/20-different-repositories

  • Committer: Liam Young
  • Date: 2015-05-11 08:03:57 UTC
  • mfrom: (83.1.14 rabbitmq-server)
  • Revision ID: liam.young@canonical.com-20150511080357-3ftop9kxb6o0e3mq
Merged trunk in + LE charmhelper sync

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python3
2
2
 
3
3
import amulet
 
4
import os
4
5
import pika
5
 
 
6
 
d = amulet.Deployment()
7
 
 
8
 
d.add('rabbitmq-server', charm='cs:trusty/rabbitmq-server')
 
6
import subprocess
 
7
import time
 
8
 
 
9
# The juju environment should be bootstrapped at this point, but depending
 
10
# on the test environment an http proxy may be necessary. Check to see if
 
11
# one is configured via the environment variable and set it if it is.
 
12
# The settings of these proxy variables should only survive the current
 
13
# lifetime of the bootstrapped environment and will be torn down for the
 
14
# next test.
 
15
if os.environ.get('AMULET_HTTP_PROXY', None):
 
16
    proxy_setting = 'http-proxy={}'.format(os.environ['AMULET_HTTP_PROXY'])
 
17
    subprocess.call(['juju', 'set-env', proxy_setting])
 
18
 
 
19
if os.environ.get('AMULET_HTTPS_PROXY', None):
 
20
    proxy_setting = 'https-proxy={}'.format(os.environ['AMULET_HTTPS_PROXY'])
 
21
    subprocess.call(['juju', 'set-env', proxy_setting])
 
22
 
 
23
 
 
24
d = amulet.Deployment(series='trusty')
 
25
 
 
26
d.add('rabbitmq-server')
9
27
d.configure('rabbitmq-server', {
10
28
    "source": "deb http://www.rabbitmq.com/debian/ testing main",
11
29
    "key": """-----BEGIN PGP PUBLIC KEY BLOCK-----
37
55
CQUCRo5D+wIbDAAKCRD3uM6mBW6OVhLmAKCYY152B/10n7aUNKejs92NsNAnPACf
38
56
ZwbDOKBXGfkCPuRx5j/AGneASNU=
39
57
=Ry+c
40
 
-----END PGP PUBLIC KEY BLOCK-----"""
 
58
-----END PGP PUBLIC KEY BLOCK-----""",
 
59
    "management_plugin": True,
41
60
})
42
61
d.expose('rabbitmq-server')
43
62
 
44
63
# Don't forget to expose using d.expose(service)
45
64
 
46
65
try:
47
 
    d.setup(timeout=900)
 
66
    # TODO(billy-olsen), juju test --timeout fails to pass the timeout values
 
67
    # into the environment and the charm isn't the best of places to select
 
68
    # a viable timeout since so muc is attributed to the environment anyways.
 
69
    # Need to fix this the right way, but for now we'll bump the timeout.
 
70
    d.setup(timeout=2700)
48
71
    d.sentry.wait()
49
72
except amulet.helpers.TimeoutError:
50
73
    amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
54
77
server = d.sentry.unit['rabbitmq-server/0']
55
78
host = server.info['public-address']
56
79
 
 
80
# TODO(wolsen) It looks like in rabbitmq version 3.3.0 the guest count was
 
81
# disabled by default and therefore we need to do the following bit of code
 
82
# in order to allow guest access for the test to succeed.
 
83
server.run('echo "[{rabbit, [{loopback_users, []}]}]." > '
 
84
           '/etc/rabbitmq/rabbitmq.config')
 
85
server.run('service rabbitmq-server restart')
 
86
 
 
87
 
57
88
try:
58
89
    connection = pika.BlockingConnection(pika.ConnectionParameters(host=host))
59
90
except Exception as e: