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