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

« back to all changes in this revision

Viewing changes to tests/20_deploy_relations_test.py

  • 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:
8
8
import time
9
9
 
10
10
# The number of seconds to wait for the environment to setup.
11
 
seconds = 900
 
11
seconds = 2700
12
12
# The number of units to scale rabbitmq-server to.
13
13
scale = 2
14
14
# The port that amqp traffic is sent on.
45
45
    error_message = 'Error, python version 2 is required for this test.'
46
46
    amulet.raise_status(amulet.FAIL, msg=error_message)
47
47
 
48
 
d = amulet.Deployment(series='trusty')
 
48
series = 'trusty'
 
49
d = amulet.Deployment(series=series)
49
50
# Add rabbitmq-server to the deployment.
50
51
d.add('rabbitmq-server', units=scale)
51
 
# Add the ceph charm to the deployment.
52
 
d.add('ceph')
53
 
# Add cinder to the deployment to test the AMQP relation.
54
 
d.add('cinder')
55
 
# Add hacluster to the deployment to test the ha relation.
56
 
d.add('hacluster')
 
52
 
 
53
# TODO(billy-olsen) - Rework this following set of code to be more in-line
 
54
# with how the other openstack services are done. For now, we want to test
 
55
# the current branch with the appropriate branches of related charms in
 
56
# order to test /next with /next branches and /trunk with /trunk branches.
 
57
stable = False
 
58
 
 
59
 
 
60
def determine_charm_branches(services):
 
61
    if stable:
 
62
        for svc in services:
 
63
            temp = 'lp:charms/{}'
 
64
            svc['location'] = temp.format(svc['name'])
 
65
    else:
 
66
        for svc in services:
 
67
            temp = 'lp:~openstack-charmers/charms/{}/{}/next'
 
68
            svc['location'] = temp.format(series, svc['name'])
 
69
 
 
70
    return services
 
71
 
 
72
 
 
73
def add_services(services):
 
74
    """
 
75
    Adds services to the deployment. The input is a list of dicts with
 
76
    the key of 'name' name for the service name. The branch location
 
77
    will be determined automatically.
 
78
    """
 
79
    services = determine_charm_branches(services)
 
80
 
 
81
    for svc in services:
 
82
        d.add(svc['name'], charm=svc['location'])
 
83
 
 
84
 
 
85
services_to_add = [
 
86
    {'name': 'ceph'},
 
87
    {'name': 'cinder'},
 
88
    {'name': 'hacluster'},
 
89
]
 
90
 
 
91
# Add the services to the deployment
 
92
add_services(services_to_add)
 
93
 
57
94
# The ceph charm requires configuration to deploy successfully.
58
95
d.configure('ceph', ceph_configuration)
59
96
# Configure the cinder charm.
104
141
# Iterate over every rabbitmq-unit to get the different relations.
105
142
for rabbit_unit in rabbit_units:
106
143
    ###########################################################################
107
 
    ## Test Relations
 
144
    # Test Relations
108
145
    ###########################################################################
109
146
    # Verify the ceph relation was created for the rabbit unit.
110
147
    rabbit_relation = rabbit_unit.relation('ceph', 'ceph:client')
132
169
        print(key, value)
133
170
 
134
171
    ###########################################################################
135
 
    ## Test AMQP
 
172
    # Test AMQP
136
173
    ###########################################################################
137
174
 
138
175
    # The AMQP python library is only available for python2 at this time.
167
204
    counter += 1
168
205
 
169
206
    ###########################################################################
170
 
    ## Verify that the rabbitmq cluster status is correct.
 
207
    # Verify that the rabbitmq cluster status is correct.
171
208
    ###########################################################################
172
209
    # Create the command that checks if the rabbitmq-server service is running.
173
210
    command = 'rabbitmqctl cluster_status'
183
220
        print('The rabbitmq-server cluster status is OK.')
184
221
 
185
222
###############################################################################
186
 
## Test the AMQP messages can be sent from and read from another.
 
223
# Test the AMQP messages can be sent from and read from another.
187
224
###############################################################################
188
225
# Get the public address for rabbitmq-server instance 0.
189
226
send_address = rabbit_units[0].info['public-address']