32
42
self._initialize_tests()
34
44
def _add_services(self):
45
self.d.add('mysql', charm='cs:trusty/mysql', units=1,
47
self.d.add('rabbitmq-server', charm='cs:trusty/rabbitmq-server',
48
units=1, series=self.series)
49
self.d.add('cassandra', charm='cassandra', units=1,
50
branch='lp:charms/cassandra', series=self.series)
51
self.d.add('keystone', charm='keystone', units=1, series=self.series,
52
branch='lp:~celebdor/charms/trusty/keystone/trunk')
53
self.d.add('nova-compute', charm='nova-compute', units=1,
54
branch='lp:~celebdor/charms/trusty/nova-compute/trunk',
56
self.d.add('neutron-api', charm='neutron-api', units=1,
57
branch='lp:~celebdor/charms/trusty/neutron-api/trunk',
59
self.d.add('nova-cloud-controller', charm='nova-cloud-controller',
60
branch='lp:~celebdor/charms/trusty/nova-cloud-controller/trunk',
61
units=1, series=self.series)
62
self.d.add('zookeeper', charm='cs:trusty/zookeeper', units=1,
35
64
self.d.add('midonet-api', charm='midonet-api', units=1,
36
65
branch='lp:~celebdor/charms/trusty/midonet-api/trunk',
37
66
series=self.series)
38
self.d.add('zookeeper', charm='cs:trusty/zookeeper', units=1,
40
self.d.add('keystone', charm='cs:trusty/keystone', units=1,
42
self.d.add('mysql', charm='cs:trusty/mysql', units=1,
44
self.d.add('cassandra',
45
charm='cs:precise/cassandra-18',
46
units=1, series='precise')
47
self.d.add('nova-compute', charm='cs:trusty/nova-compute', units=1,
49
67
self.d.add('midonet-agent', charm='midonet-agent', units=1,
50
68
branch='lp:~celebdor/charms/trusty/midonet-agent/trunk',
51
69
series=self.series)
70
self.d.add('neutron-agents-midonet', charm='neutron-agents-midonet',
71
branch='lp:~celebdor/charms/trusty/neutron-agents-midonet/trunk',
53
74
def _add_relations(self):
54
75
self.d.relate('mysql:shared-db', 'keystone:shared-db')
55
self.d.relate('midonet-api:zookeeper', 'zookeeper:zookeeper')
56
self.d.relate('midonet-api:keystone', 'keystone:identity-admin')
57
self.d.relate('nova-compute:shared-db', 'mysql:shared-db')
58
self.d.relate('midonet-agent:zookeeper', 'zookeeper:zookeeper')
59
self.d.relate('midonet-agent:cassandra', 'cassandra:database')
76
self.d.relate('mysql:shared-db', 'nova-cloud-controller:shared-db')
77
self.d.relate('rabbitmq-server:amqp', 'nova-compute:amqp')
78
self.d.relate('rabbitmq-server:amqp', 'nova-cloud-controller:amqp')
79
self.d.relate('rabbitmq-server:amqp', 'neutron-api:amqp')
80
self.d.relate('nova-cloud-controller:identity-service',
81
'keystone:identity-service')
83
self.d.relate('neutron-api:identity-service',
84
'keystone:identity-service')
85
self.d.relate('nova-compute:cloud-compute',
86
'nova-cloud-controller:cloud-compute')
87
self.d.relate('neutron-api:neutron-api',
88
'nova-cloud-controller:neutron-api')
90
self.d.relate('keystone:identity-service', 'midonet-api:keystone')
91
self.d.relate('zookeeper:zookeeper', 'midonet-api:zookeeper')
60
92
self.d.relate('midonet-agent:host', 'midonet-api:host')
93
self.d.relate('neutron-api:midonet', 'midonet-api:midonet-api')
95
self.d.relate('neutron-agents-midonet:neutron_agents',
96
'nova-cloud-controller:quantum-network-service')
98
self.d.relate('neutron-agents-midonet:neutron-plugin-api',
99
'neutron-api:neutron-plugin-api')
61
101
self.d.relate('midonet-agent:neutron-plugin',
62
102
'nova-compute:neutron-plugin')
104
self.d.relate('midonet-agent:host', 'neutron-api:midonet-host')
105
self.d.relate('midonet-agent:cassandra', 'cassandra:database')
106
self.d.relate('midonet-agent:zookeeper', 'zookeeper:zookeeper')
64
108
def _configure_services(self):
65
self.d.configure('keystone', {'openstack-origin': 'cloud:trusty-juno'})
109
self.d.configure('keystone', {
110
'enable-pki': 'false',
111
'openstack-origin': self.os_release})
67
113
self.d.configure('cassandra', {
68
114
'allow-single-node': True,
72
118
'deb http://debian.datastax.com/community 2.0 main',
73
119
'extra_packages': 'openjdk-7-jre-headless dsc20'})
74
self.d.configure('nova-compute', {'openstack-origin':
121
self.d.configure('mysql', {'max-connections': 2000})
123
self.d.configure('nova-compute', {
124
'openstack-origin': self.os_release,
126
'flat-interface': 'eth0',
127
'manage-neutron-plugin-legacy-mode': 'false'})
129
self.d.configure('nova-cloud-controller', {
130
'openstack-origin': self.os_release,
131
'network-manager': 'Neutron',
132
'shared_secret': 'secret'})
134
self.d.configure('neutron-api', {
135
'neutron-plugin': 'midonet',
136
'neutron-security-groups': 'True',
137
'neutron-external-network': 'Public_Network',
138
'l2-population': 'False',
139
'openstack-origin': self.os_release,
140
'midonet-release': self.midonet_release})
142
self.d.configure('midonet-api',
143
{'midonet-release': self.midonet_release})
145
self.d.configure('neutron-agents-midonet',
146
{'shared_secret': 'secret'})
148
self.d.configure('midonet-agent',
149
{'midonet-release': self.midonet_release})
77
151
def _deploy(self):
83
157
msg="Environment wasn't stood up in time")
85
159
def _initialize_tests(self):
86
self.mn_api_sentry = self.d.sentry.unit['midonet-api/0']
87
160
self.zookeeper_sentry = self.d.sentry.unit['zookeeper/0']
88
161
self.keystone_sentry = self.d.sentry.unit['keystone/0']
89
162
self.cassandra_sentry = self.d.sentry.unit['cassandra/0']
90
163
self.nova_compute_sentry = self.d.sentry.unit['nova-compute/0']
91
self.mn_host_sentry = self.d.sentry.unit['midonet-agent/0']
164
self.mn_api_sentry = self.d.sentry.unit['midonet-api/0']
165
self.mn_agent_sentry = self.d.sentry.unit['midonet-agent/0']
166
self.agents_mn_sentry = self.d.sentry.unit['neutron-agents-midonet/0']
93
168
self.keystone_api_relation = self.keystone_sentry.relation(
94
'identity-admin', 'midonet-api:keystone')
169
'identity-service', 'midonet-api:keystone')
95
170
self.zookeeper_api_relation = self.zookeeper_sentry.relation(
96
171
'zookeeper', 'midonet-api:zookeeper')
98
172
self.zk_host_relation = self.zookeeper_sentry.relation(
99
173
'zookeeper', 'midonet-agent:zookeeper')
100
174
self.cs_host_relation = self.cassandra_sentry.relation(
101
175
'database', 'midonet-agent:cassandra')
102
176
self.api_host_relation = self.mn_api_sentry.relation(
103
177
'host', 'midonet-agent:host')
104
self.nova_comp_host_relation = self.nova_compute_sentry.relation(
105
'neutron-plugin', 'midonet-agent:neutron-plugin')
107
179
def run_tests(self):
108
180
for test in dir(self):
109
181
if test.startswith('test_'):
110
182
getattr(self, test)()
112
def test_mn_host(self):
113
# Check the key has been correctly fetched
114
apt_key_out, apt_key_exit = self.mn_host_sentry.run(
184
def test_mn_agent(self):
185
u.log.debug('Checking if the key has been correctly fetched...')
186
apt_key_out, apt_key_exit = self.mn_agent_sentry.run(
115
187
'apt-key list | grep Midokura')
116
188
if 'Midokura' not in apt_key_out:
117
189
message = ("error, Midokura repository key is not installed")
118
190
amulet.raise_status(amulet.FAIL, msg=message)
120
# Check if midolman package has been installed
121
dpkg_midol_out, dpkg_exit = self.mn_host_sentry.run(
192
u.log.debug('Checking if midolman package has been installed...')
193
dpkg_midol_out, dpkg_exit = self.mn_agent_sentry.run(
122
194
'dpkg -l | grep midolman')
123
195
if 'midolman' not in dpkg_midol_out:
124
196
message = ("error, midolman package is not installed")
125
197
amulet.raise_status(amulet.FAIL, msg=message)
127
# Check zookeeper state and connection
199
u.log.debug('Checking zookeeper state...')
128
200
zk_out, zk_exit = self.zookeeper_sentry.run(
129
201
'echo ruok | nc 127.0.0.1 2181')
130
202
if 'imok' not in zk_out:
131
203
message = ("zookeeper in error state: %s" % zk_exit)
132
204
amulet.raise_status(amulet.FAIL, msg=message)
134
zk_out, zk_exit = self.zookeeper_sentry.run(
135
'echo stat | nc 127.0.0.1 2181')
136
mn_host_ip, _ = self.mn_host_sentry.run(
137
'ifconfig | awk\'/inet / { print $2 }\' | sed -e s/addr:// | '
139
if mn_host_ip not in zk_out:
140
message = "error: midonet-agent not connected to zk"
141
amulet.raise_status(amulet.FAIL, msg=message)
143
# Check if cassandra is running in a non-error state
206
u.log.debug('Checking if cassandra is running in a non-error state...')
144
207
cs_out, _ = self.cassandra_sentry.run(
145
208
'nodetool -host 127.0.0.1 status')
146
209
if 'Up' not in cs_out:
147
210
message = ("error: cassandra in error state: %s" % cs_out)
148
211
amulet.raise_status(amulet.FAIL, msg=message)
150
# Check if the bridge has been successfully created
213
u.log.debug('Checking if the host has been successfully added...')
151
214
cli_out, _ = self.mn_api_sentry.run('midonet-cli -e host list')
152
215
if 'host' not in cli_out:
153
216
message = ("error, midonet host not in tunnel-zone")