blob: b7273ecbe71a5851c259e6feb99d314ec4aeba7b [file] [log] [blame]
Dennis Dmitriev6f59add2016-10-18 13:45:27 +03001# Copyright 2016 Mirantis, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14import copy
15
16import pytest
17
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030018from tcp_tests import settings
19from tcp_tests.helpers import ext
Dennis Dmitriev474e3f72016-10-21 16:46:09 +030020from tcp_tests import logger
21
22LOG = logger.logger
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030023
24
25@pytest.mark.deploy
26class TestTCPInstaller(object):
27 """Test class for testing TCP deployment"""
28
Dennis Dmitriev474e3f72016-10-21 16:46:09 +030029 salt_cmd = 'salt -l debug ' # For debug output
30 salt_call_cmd = 'salt-call -l debug ' # For debug output
31 #salt_cmd = 'salt --state-verbose=False ' # For reduced output
32 #salt_call_cmd = 'salt-call --state-verbose=False ' # For reduced output
33
34
35 @pytest.mark.steps({
36 '1': {
37 'cmd': salt_cmd + "'cfg01*' state.sls linux",
38 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
39 'retry': {'count': 3, 'delay': 5},
40 },
41 '2': {
42 'cmd': salt_cmd + "'cfg01*' state.sls openssh",
43 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
44 'retry': {'count': 3, 'delay': 5},
45 },
46 '3': {
47 'cmd': "echo ' StrictHostKeyChecking no' >> /root/.ssh/config",
48 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
49 'retry': {'count': 1, 'delay': 1},
50 },
51 '4': {
52 'cmd': salt_cmd + "'cfg01*' state.sls salt",
53 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
54 'retry': {'count': 3, 'delay': 5},
55 },
56 '5': {
57 'cmd': salt_cmd + "'cfg01*' state.sls reclass.storage",
58 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
59 'retry': {'count': 3, 'delay': 5},
60 },
61 '6': {
62 'cmd': salt_cmd + "'*' saltutil.refresh_pillar",
63 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
64 'retry': {'count': 3, 'delay': 5},
65 },
66 '7': {
67 'cmd': salt_cmd + "'ctl*' state.sls ntp",
68 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
69 'retry': {'count': 3, 'delay': 5},
70 },
71 '8': {
72 'cmd': salt_cmd + "'ctl*' state.sls linux,salt.minion,openssh",
73 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
74 'retry': {'count': 3, 'delay': 5},
75 },
76 '9': {
77 'cmd': salt_cmd + "'ctl01*' state.sls keepalived",
78 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
79 'retry': {'count': 3, 'delay': 5},
80 },
81 '10': {
82 'cmd': salt_cmd + "'ctl01*' cmd.run 'ip a'",
83 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
84 'retry': {'count': 3, 'delay': 5},
85 },
86 '11': {
87 'cmd': salt_cmd + "'ctl0[23].*' state.sls keepalived",
88 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
89 'retry': {'count': 3, 'delay': 5},
90 },
91 '12': {
92 'cmd': salt_cmd + "'ctl*' state.sls glusterfs.server.service",
93 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
94 'retry': {'count': 3, 'delay': 5},
95 },
96 '13': {
97 'cmd': salt_call_cmd + "state.sls glusterfs.server.setup",
98 'node_name': 'ctl01.mk20-lab-advanced.local', # hardcoded for now
99 'retry': {'count': 3, 'delay': 5},
100 },
101 '14': {
102 'cmd': "gluster peer status",
103 'node_name': 'ctl01.mk20-lab-advanced.local', # hardcoded for now
104 'retry': {'count': 3, 'delay': 5},
105 },
106 '15': {
107 'cmd': "gluster volume status",
108 'node_name': 'ctl01.mk20-lab-advanced.local', # hardcoded for now
109 'retry': {'count': 3, 'delay': 5},
110 },
111 '16': {
112 'cmd': salt_cmd + "'ctl*' state.sls rabbitmq",
113 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
114 'retry': {'count': 3, 'delay': 5},
115 },
116 '17': {
117 'cmd': salt_call_cmd + "state.sls galera",
118 'node_name': 'ctl01.mk20-lab-advanced.local', # hardcoded for now
119 'retry': {'count': 3, 'delay': 5},
120 },
121 '18': {
122 'cmd': salt_cmd + "'ctl0[23]*' state.sls galera",
123 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
124 'retry': {'count': 3, 'delay': 5},
125 },
126 '19': {
127 'cmd': salt_cmd + "'ctl01*' mysql.status | grep -A1 'wsrep_incoming_addresses:'",
128 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
129 'retry': {'count': 3, 'delay': 5},
130 },
131 '20': {
132 'cmd': salt_cmd + "'ctl*' state.sls haproxy",
133 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
134 'retry': {'count': 3, 'delay': 5},
135 },
136 '21': {
137 'cmd': salt_cmd + "'ctl*' cmd.run 'netstat -tulnp | grep 3306'",
138 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
139 'retry': {'count': 3, 'delay': 5},
140 },
141 '22': {
142 'cmd': salt_call_cmd + "state.sls memcached,keystone",
143 'node_name': 'ctl01.mk20-lab-advanced.local', # hardcoded for now
144 'retry': {'count': 3, 'delay': 5},
145 },
146 '23': {
147 'cmd': salt_call_cmd + "state.sls memcached,keystone",
148 'node_name': 'ctl02.mk20-lab-advanced.local', # hardcoded for now
149 'retry': {'count': 3, 'delay': 5},
150 },
151 '24': {
152 'cmd': salt_call_cmd + "state.sls memcached,keystone",
153 'node_name': 'ctl03.mk20-lab-advanced.local', # hardcoded for now
154 'retry': {'count': 3, 'delay': 5},
155 },
156 '25': {
157 'cmd': "source ~/keystonerc; keystone user-list",
158 'node_name': 'ctl01.mk20-lab-advanced.local', # hardcoded for now
159 'retry': {'count': 3, 'delay': 5},
160 },
161 '26': {
162 'cmd': "source ~/keystonerc; keystone tenant-list",
163 'node_name': 'ctl01.mk20-lab-advanced.local', # hardcoded for now
164 'retry': {'count': 3, 'delay': 5},
165 },
166 '27': {
167 'cmd': "source ~/keystonerc; keystone endpoint-list",
168 'node_name': 'ctl01.mk20-lab-advanced.local', # hardcoded for now
169 'retry': {'count': 3, 'delay': 5},
170 },
171 '28': {
172 'cmd': salt_cmd + "'ctl*' state.sls glance",
173 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
174 'retry': {'count': 3, 'delay': 5},
175 },
176 '29': {
177 'cmd': salt_cmd + "'ctl*' state.sls glusterfs.client",
178 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
179 'retry': {'count': 3, 'delay': 5},
180 },
181 '30': {
182 'cmd': salt_cmd + "'ctl*' cmd.run 'df -h'",
183 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
184 'retry': {'count': 3, 'delay': 5},
185 },
186 '31': {
187 'cmd': salt_call_cmd + "state.sls keystone",
188 'node_name': 'ctl01.mk20-lab-advanced.local', # hardcoded for now
189 'retry': {'count': 3, 'delay': 5},
190 },
191 '32': {
192 'cmd': ("source ~/keystonerc;"
193 "wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-i386-disk.img;"
194 "glance image-create --name 'cirros-0.3.4'"
195 " --disk-format qcow2 --container-format bare"
196 " --progress --file /root/cirros-0.3.4-i386-disk.img;"
197 "glance image-list;"),
198 'node_name': 'ctl01.mk20-lab-advanced.local', # hardcoded for now
199 'retry': {'count': 3, 'delay': 5},
200 },
201 '33': {
202 'cmd': salt_cmd + "'ctl*' cmd.run 'ls -al /var/lib/keystone/fernet-keys' ",
203 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
204 'retry': {'count': 3, 'delay': 5},
205 },
206 '34': {
207 'cmd': salt_cmd + "'ctl*' cinder",
208 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
209 'retry': {'count': 3, 'delay': 5},
210 },
211 '35': {
212 'cmd': salt_cmd + "'ctl*' nova",
213 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
214 'retry': {'count': 3, 'delay': 5},
215 },
216 '36': {
217 'cmd': "source ~/keystonerc; cinder list",
218 'node_name': 'ctl01.mk20-lab-advanced.local', # hardcoded for now
219 'retry': {'count': 3, 'delay': 5},
220 },
221 '37': {
222 'cmd': "source ~/keystonerc; nova-manage service list",
223 'node_name': 'ctl01.mk20-lab-advanced.local', # hardcoded for now
224 'retry': {'count': 3, 'delay': 5},
225 },
226 '38': {
227 'cmd': "source ~/keystonerc; nova list",
228 'node_name': 'ctl01.mk20-lab-advanced.local', # hardcoded for now
229 'retry': {'count': 3, 'delay': 5},
230 },
231 '39': {
232 'cmd': salt_cmd + "'ctl*' state.sls neutron",
233 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
234 'retry': {'count': 3, 'delay': 5},
235 },
236 '40': {
237 'cmd': ("source ~/keystonerc;"
238 "neutron net-create --router:external=true --shared external;"
239 "neutron subnet-create external 10.177.0.0/24;"
240 "neutron floatingip-create;"),
241 'node_name': 'ctl01.mk20-lab-advanced.local', # hardcoded for now
242 'retry': {'count': 3, 'delay': 5},
243 },
244 '41': {
245 'cmd': salt_cmd + "'ctl*' state.sls opencontrail.database",
246 'node_name': 'cfg01.mk20-lab-advanced.local', # hardcoded for now
247 'retry': {'count': 3, 'delay': 5},
248 },
249 '42': {
250 'cmd': ("nodetool status;"
251 "nodetool compactionstats;"
252 "nodetool describecluster;"),
253 'node_name': 'ctl01.mk20-lab-advanced.local', # hardcoded for now
254 'retry': {'count': 3, 'delay': 5},
255 },
256
257 })
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300258 @pytest.mark.revert_snapshot(ext.SNAPSHOT.underlay)
Dennis Dmitriev474e3f72016-10-21 16:46:09 +0300259 # @pytest.mark.snapshot_needed
260 # @pytest.mark.fail_snapshot
261 def test_tcp_install_default(self, underlay, tcp_actions, steps, show_step):
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300262 """Test for deploying an tcp environment and check it
263
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300264 Scenario:
Dennis Dmitriev474e3f72016-10-21 16:46:09 +0300265 1. Run 'linux' formula on cfg01
266 2. Run 'openssh' formula on cfg01
267 3. *Workaround* of the bug https://mirantis.jira.com/browse/PROD-7962
268 4. Run 'salt' formula on cfg01
269 5. Generate inventory for all the nodes to the /srv/salt/reclass/nodes/_generated
270 6. Refresh pillars on all minions
271 7. Configure ntp on controllers
272 8. Configure linux, openssh and salt.minion on controllers
273 9. Install keepalived on primary controller
274 10. Show VIP on primary controller
275 11. Install keepalived on other controllers
276 12. Install glusterfs on all controllers
277 13. Setup glusterfs on primary controller
278 14. Show glusterfs peer status
279 15. Show glusterfs volume status
280 16. Install RabbitMQ on all controllers
281 17. Install Galera on primary controller
282 18. Install Galera on other controllers
283 19. Check Galera addresses
284 20. Install haproxy on all controllers
285 21. Check haproxy on all controllers with Galera port
286 22. Install memcached and keystone on ctl01
287 23. Install memcached and keystone on ctl02
288 24. Install memcached and keystone on ctl03
289 25. Check keystone user-list
290 26. Check keystone tenant-list
291 27. Check keystone endpoint-list
292 28. Install glance on controllers
293 29. Install glusterfs on controllers
294 30. Check that glusterfs was added on controllers
295 31. *Workaround* Re-run keystone formula on ctl01 to create fernet keys
296 32. Check glance on ctl01
297 33. Check keystone fernet keys on controllers
298 34. Install cinder on controllers
299 35. Install nova on controllers
300 36. Check cinder status
301 37. Check nova services status
302 38. Check nova status
303 39. Install neutron on controllers
304 40. Create a neutron subnet
305 41. Install contrail database on controllers
306 42. Check cassandra status on ctl01
307
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300308
Dennis Dmitriev75fce1b2016-10-18 15:04:28 +0300309 """
Dennis Dmitriev474e3f72016-10-21 16:46:09 +0300310 for step in sorted(steps):
311 LOG.info(" #######################################################################")
312 show_step(int(step))
313 with underlay.remote(node_name=steps[step]['node_name']) as remote:
314 for x in range(steps[step]['retry']['count']):
315 result = remote.execute(steps[step]['cmd'], verbose=True)
316 if result.exit_code != 0:
317 sleep(steps[step]['retry']['delay'])
318 LOG.info(" ========================= retry...")
319 else:
320 break