~celebdor/charms/trusty/neutron-agents-midonet/trunk

« back to all changes in this revision

Viewing changes to tests/basic_deployment.py

  • Committer: Antoni Segura Puimedon
  • Date: 2016-02-12 00:39:19 UTC
  • Revision ID: toni@midokura.com-20160212003919-kpj0ure01no229fh
amulet: remove old tests and add check for nova-api-metadata

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
SETUP_TIMEOUT = 9600
32
32
 
33
33
 
34
 
class MidonetBasicDeployment():
 
34
class ApiMinimumDeployment():
35
35
    def __init__(self, ubuntu_series, openstack_origin=None,
36
36
                 midonet_origin=None):
37
37
        self.os_release = openstack_origin
43
43
        self.d = amulet.Deployment(series=self.series)
44
44
        self.d.charm_name = 'neutron-agents-midonet'
45
45
 
 
46
        # Sentries
 
47
        self.zookeeper_sentry = None
 
48
        self.keystone_sentry = None
 
49
        self.cassandra_sentry = None
 
50
        self.nova_compute_sentry = None
 
51
        self.mn_api_sentry = None
 
52
        self.agents_mn_sentry = None
 
53
        self.keystone_api_relation = None
 
54
        self.zookeeper_api_relation = None
 
55
 
46
56
        self._add_services()
47
57
        self._add_relations()
48
58
        self._configure_services()
52
62
    def _add_services(self):
53
63
        self.d.add('mysql', charm='cs:trusty/mysql', units=1,
54
64
                   series=self.series)
55
 
        self.d.add('rabbitmq-server', charm='cs:trusty/rabbitmq-server',
 
65
        self.d.add('keystone', charm='keystone', units=1, series=self.series,
 
66
                    branch='cs:trusty/keystone')
 
67
        self.d.add('cassandra', charm='cs:trusty/cassandra',
56
68
                   units=1, series=self.series)
57
 
        self.d.add('cassandra', charm='cassandra', units=1,
58
 
                   branch='cs:trusty/cassandra', series=self.series)
59
 
        self.d.add('keystone', charm='keystone', units=1, series=self.series,
60
 
                branch='cs:trusty/keystone')
61
 
        self.d.add('compute', charm='nova-compute', units=1,
62
 
                   branch='cs:trusty/nova-compute', series=self.series,
63
 
                   constraints={'mem': '8G'})
64
 
        self.d.add('neutron', charm='neutron-api', units=1,
65
 
                   branch='lp:~celebdor/charms/trusty/neutron-api/liberty',
66
 
                   series=self.series)
67
 
        self.d.add('nova', charm='nova-cloud-controller',
68
 
               units=1, series=self.series)
69
 
        self.d.add('glance', charm='glance',
70
 
               branch='cs:trusty/glance',
71
 
               units=1, series=self.series)
72
 
        self.d.add('cinder', charm='cinder',
73
 
               branch='cs:trusty/glance',
74
 
               units=1, series=self.series)
75
69
        self.d.add('zookeeper', charm='cs:trusty/zookeeper', units=1,
76
70
                   series=self.series)
77
 
        self.d.add('midonet-api', charm='midonet-api', units=1,
 
71
        self.d.add('rabbitmq', charm='cs:trusty/rabbitmq-server', units=1,
 
72
                   series=self.series)
 
73
        self.d.add('nova', charm='cs:trusty/nova-cloud-controller', units=1,
 
74
                   series=self.series)
 
75
        self.d.add(
 
76
            'neutron', charm='neutron-api', units=1,
 
77
            branch='lp:~openstack-charmers/charms/trusty/neutron-api/next',
 
78
            series=self.series)
 
79
        self.d.add('midonet-api', charm='midonet-api',
78
80
                   branch='lp:~celebdor/charms/trusty/midonet-api/trunk',
79
81
                   series=self.series)
80
 
        self.d.add('midonet-agent', charm='midonet-agent', units=1,
 
82
        self.d.add('midonet-agent', charm='midonet-agent',
81
83
                   branch='lp:~celebdor/charms/trusty/midonet-agent/trunk',
82
84
                   series=self.series)
83
 
        self.d.add('neutron-agents-midonet', constraints={'mem': '4G'})
 
85
        self.d.add('neutron-agents-midonet')
84
86
 
85
87
    def _add_relations(self):
86
88
        # Keystone
89
91
        # Nova
90
92
        self.d.relate('mysql:shared-db', 'nova:shared-db')
91
93
        self.d.relate('keystone:identity-service', 'nova:identity-service')
92
 
        self.d.relate('rabbitmq-server:amqp', 'nova:amqp')
 
94
        self.d.relate('rabbitmq:amqp', 'nova:amqp')
93
95
        self.d.relate('neutron-agents-midonet:neutron_agents',
94
96
                      'nova:quantum-network-service')
95
97
        self.d.relate('neutron:neutron-api', 'nova:neutron-api')
96
 
        self.d.relate('compute:cloud-compute', 'nova:cloud-compute')
97
 
        self.d.relate('glance:image-service', 'nova:image-service')
98
 
        self.d.relate('cinder:cinder-volume-service',
99
 
                      'nova:cinder-volume-service')
100
 
 
101
 
        # Cinder
102
 
        self.d.relate('keystone:identity-service', 'cinder:identity-service')
103
 
        self.d.relate('mysql:shared-db', 'cinder:shared-db')
104
 
        self.d.relate('rabbitmq-server:amqp', 'cinder:amqp')
105
 
        self.d.relate('glance:image-service', 'cinder:image-service')
106
 
 
107
 
        # Glance
108
 
        self.d.relate('keystone:identity-service', 'glance:identity-service')
109
 
        self.d.relate('mysql:shared-db', 'glance:shared-db')
110
 
        self.d.relate('rabbitmq-server:amqp', 'glance:amqp')
111
98
 
112
99
        # Neutron
113
100
        self.d.relate('mysql:shared-db', 'neutron:shared-db')
114
101
        self.d.relate('keystone:identity-service', 'neutron:identity-service')
115
 
        self.d.relate('rabbitmq-server:amqp', 'neutron:amqp')
 
102
        self.d.relate('rabbitmq:amqp', 'neutron:amqp')
116
103
        self.d.relate('neutron-agents-midonet:neutron-plugin-api',
117
104
                      'neutron:neutron-plugin-api')
 
105
        self.d.relate('midonet-api:midonet-api', 'neutron:midonet')
118
106
 
119
107
        # MidoNet
120
108
        self.d.relate('keystone:identity-service', 'midonet-api:keystone')
121
109
        self.d.relate('zookeeper:zookeeper', 'midonet-api:zookeeper')
122
110
        self.d.relate('midonet-agent:host', 'midonet-api:host')
123
 
        self.d.relate('neutron:midonet', 'midonet-api:midonet-api')
124
 
        self.d.relate('rabbitmq-server:amqp', 'neutron-gents-midonet:amqp')
 
111
        self.d.relate('rabbitmq:amqp', 'neutron-agents-midonet:amqp')
125
112
        self.d.relate('midonet-agent:host', 'neutron-agents-midonet:agent')
 
113
        self.d.relate('midonet-api:midonet-api',
 
114
                      'neutron-agents-midonet:midonet')
126
115
        self.d.relate('cassandra:database', 'midonet-agent:cassandra')
127
116
        self.d.relate('zookeeper:zookeeper', 'midonet-agent:zookeeper')
128
 
        self.d.relate('midonet-api:midonet-api',
129
 
                      'neutron-agents-midonet:midonet')
130
 
 
131
 
        # Compute
132
 
        self.d.relate('rabbitmq-server:amqp', 'compute:amqp')
133
 
        self.d.relate('midonet-agent:neutron-plugin', 'compute:neutron-plugin')
134
 
        self.d.relate('glance:image-service', 'compute:image-service')
135
117
 
136
118
    def _configure_services(self):
137
 
        repo_config = {'midonet-origin': self.midonet_origin,
138
 
                      'openstack-origin': self.os_release}
139
 
        if self.mem:
140
 
            repo_config.update(self.mem_credentials)
141
 
 
142
119
        self.d.configure('keystone', {
143
 
                         'admin-user': 'admin',
144
 
                         'admin-password': 'openstack',
145
 
                         'admin-token': 'osttesting',
146
 
                         'enable-pki': 'false',
147
 
                         'openstack-origin': self.os_release})
148
 
 
149
 
        self.d.configure('mysql', {
150
 
                         'max-connections': 500})
 
120
            'admin-user': 'admin',
 
121
            'admin-password': 'openstack',
 
122
            'admin-token': 'osttesting',
 
123
            'enable-pki': 'false',
 
124
            'openstack-origin': self.os_release})
 
125
 
 
126
        self.d.configure('nova', {
 
127
            'network-manager': 'Neutron',
 
128
            'openstack-origin': self.os_release})
 
129
 
 
130
        neutron_conf = {
 
131
            'l2-population': 'false',
 
132
            'neutron-security-groups': 'true',
 
133
            'neutron-plugin': 'midonet',
 
134
            'neutron-external-network': 'Public_Network',
 
135
            'midonet-origin': self.midonet_origin,
 
136
            'openstack-origin': self.os_release}
 
137
        if self.mem:
 
138
            neutron_conf.update(self.mem_credentials)
 
139
 
 
140
        self.d.configure('neutron', neutron_conf)
151
141
 
152
142
        self.d.configure('cassandra', {
153
143
            'authenticator': 'AllowAllAuthenticator',
157
147
            'deb http://debian.datastax.com/community 2.0 main',
158
148
            'extra_packages': 'dsc20'})
159
149
 
160
 
        self.d.configure('compute', {
161
 
                         'openstack-origin': self.os_release,
162
 
                         'virt-type': 'qemu',
163
 
                         'flat-interface': 'eth0',
164
 
                         'manage-neutron-plugin-legacy-mode': 'false'})
165
 
 
166
 
        self.d.configure('nova', {
167
 
                         'openstack-origin': self.os_release,
168
 
                         'network-manager': 'Neutron',
169
 
                         'shared-secret': 'secret'})
170
 
 
171
 
        self.d.configure('neutron', {
172
 
                         'neutron-plugin': 'midonet',
173
 
                         'neutron-security-groups': 'True',
174
 
                         'neutron-external-network': 'Public_Network',
175
 
                         'l2-population': 'False',
176
 
                         'openstack-origin': self.os_release,
177
 
                         'midonet-origin': self.midonet_origin})
178
 
 
179
 
 
180
 
        self.d.configure('midonet-api', repo_config)
181
 
 
182
 
        neutron_agts_midonet_config = {'shared-secret': 'secret'}
183
 
        neutron_agts_midonet_config.update(repo_config)
184
 
        self.d.configure('neutron-agents-midonet', neutron_agts_midonet_config)
185
 
 
186
 
        self.d.configure('midonet-agent', repo_config)
 
150
        self.d.configure('mysql', {'max-connections': 500})
 
151
 
 
152
        api_config = {'midonet-origin': self.midonet_origin,
 
153
                      'openstack-origin': self.os_release}
 
154
        if self.mem:
 
155
            api_config.update(self.mem_credentials)
 
156
        self.d.configure('midonet-api', api_config)
 
157
        self.d.configure('midonet-agent', api_config)
 
158
        self.d.configure('neutron-agents-midonet', api_config)
 
159
 
187
160
 
188
161
    def _deploy(self):
189
162
        try:
196
169
    def _initialize_tests(self):
197
170
        self.zookeeper_sentry = self.d.sentry.unit['zookeeper/0']
198
171
        self.keystone_sentry = self.d.sentry.unit['keystone/0']
199
 
        self.cassandra_sentry = self.d.sentry.unit['cassandra/0']
200
 
        self.nova_compute_sentry = self.d.sentry.unit['compute/0']
201
172
        self.mn_api_sentry = self.d.sentry.unit['midonet-api/0']
202
173
        self.mn_agent_sentry = self.d.sentry.unit['midonet-agent/0']
203
174
        self.agents_mn_sentry = self.d.sentry.unit['neutron-agents-midonet/0']
206
177
            'identity-service', 'midonet-api:keystone')
207
178
        self.zookeeper_api_relation = self.zookeeper_sentry.relation(
208
179
            'zookeeper', 'midonet-api:zookeeper')
209
 
        self.zk_host_relation = self.zookeeper_sentry.relation(
210
 
            'zookeeper', 'midonet-agent:zookeeper')
211
 
        self.cs_host_relation = self.cassandra_sentry.relation(
212
 
            'database', 'midonet-agent:cassandra')
213
 
        self.api_host_relation = self.mn_api_sentry.relation(
214
 
            'host', 'midonet-agent:host')
215
180
 
216
181
    def run_tests(self):
217
182
        for test in dir(self):
249
214
            amulet.raise_status(amulet.FAIL,
250
215
                                msg="neutron-metadata-agent not running: %s" %
251
216
                                meta_agent_out)
 
217
        u.log.debug('Checking nova-api-metadata...')
 
218
        meta_agent_out, _ = self.agents_mn_sentry.run(
 
219
            'service nova-api-metadata status')
 
220
        if 'running' not in meta_agent_out:
 
221
            amulet.raise_status(amulet.FAIL,
 
222
                                msg="nova-api-metadata not running: %s" %
 
223
                                meta_agent_out)