blob: 615e26feb6621589065e03bcb2762f9caf8a1578 [file] [log] [blame]
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +03001# Copyright 2017 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.
Dennis Dmitriev8ce85152017-11-29 00:05:12 +020014from devops.helpers import helpers
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +030015import pytest
16
17from tcp_tests import logger
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +020018from tcp_tests.helpers import ext
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +030019
20LOG = logger.logger
21
22
23class TestFailover(object):
24 """Test class for testing OpenStack nodes failover"""
25
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +020026 @staticmethod
Dennis Dmitriev28fd0492017-11-29 13:33:21 +020027 def check_influxdb_xfail(sl_deployed, node_name, value):
28
29 def check_influxdb_data():
30 return value in sl_deployed.check_data_in_influxdb(node_name)
31
32 try:
33 helpers.wait(
34 check_influxdb_data,
35 timeout=10, interval=2,
36 timeout_msg=('Influxdb data {0} was not replicated to {1} '
37 '[https://mirantis.jira.com/browse/PROD-16272]'
38 .format(value, node_name)))
39 except Exception:
40 pytest.xfail('Influxdb data {0} was not replicated to {1} '
41 '[https://mirantis.jira.com/browse/PROD-16272]'
42 .format(value, node_name))
43
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +030044 @pytest.mark.grab_versions
45 @pytest.mark.fail_snapshot
46 def test_warm_shutdown_ctl01_node(self, underlay, openstack_deployed,
47 openstack_actions, show_step):
48 """Test warm shutdown ctl01
49
50 Scenario:
51 1. Prepare salt on hosts
52 2. Setup controller nodes
53 3. Setup compute nodes
54 4. Shutdown ctl01
55 5. Run tempest smoke after failover
56
57
58 """
59 # STEP #1,2,3
60 show_step(1)
61 show_step(2)
62 show_step(3)
63 # STEP #4
64 show_step(4)
65 openstack_actions.warm_shutdown_openstack_nodes('ctl01')
66 # STEP #5
67 show_step(5)
68 openstack_actions.run_tempest(pattern='smoke')
69
70 LOG.info("*************** DONE **************")
71
72 @pytest.mark.grab_versions
73 @pytest.mark.fail_snapshot
74 def test_restart_ctl01_node(self, underlay, openstack_deployed,
Dennis Dmitriev9b02c8b2017-11-13 15:31:35 +020075 openstack_actions, show_step):
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +030076 """Test restart ctl01
77
78 Scenario:
79 1. Prepare salt on hosts
80 2. Setup controller nodes
81 3. Setup compute nodes
82 4. Restart ctl01
83 5. Run tempest smoke after failover
84
85
86 """
87 # STEP #1,2,3
88 show_step(1)
89 show_step(2)
90 show_step(3)
91
92 # STEP #4
93 show_step(4)
94 openstack_actions.warm_restart_nodes('ctl01')
95 # STEP #5
96 show_step(5)
97 openstack_actions.run_tempest(pattern='smoke')
98
99 LOG.info("*************** DONE **************")
100
101 @pytest.mark.grab_versions
102 @pytest.mark.fail_snapshot
103 def test_warm_shutdown_cmp01_node(self, underlay, openstack_deployed,
104 openstack_actions, show_step):
105 """Test warm shutdown cmp01
106
107 Scenario:
108 1. Prepare salt on hosts
109 2. Setup controller nodes
110 3. Setup compute nodes
111 4. Shutdown cmp01
112 5. Run tempest smoke after failover
113
114
115 """
116 # STEP #1,2,3
117 show_step(1)
118 show_step(2)
119 show_step(3)
120
121 # STEP #4
122 show_step(4)
123 openstack_actions.warm_shutdown_openstack_nodes('cmp01')
124 # STEP #5
125 show_step(5)
126 openstack_actions.run_tempest(pattern='smoke')
127
128 LOG.info("*************** DONE **************")
129
130 @pytest.mark.grab_versions
131 @pytest.mark.fail_snapshot
132 def test_restart_cmp01_node(self, underlay, openstack_deployed,
133 openstack_actions, show_step):
134 """Test restart cmp01
135
136 Scenario:
137 1. Prepare salt on hosts
138 2. Setup controller nodes
139 3. Setup compute nodes
140 4. Restart cmp01
141 5. Run tempest smoke after failover
142
143
144 """
145 # STEP #1,2,3
146 show_step(1)
147 show_step(2)
148 show_step(3)
149
150 # STEP #4
151 show_step(4)
152 openstack_actions.warm_restart_nodes('cmp01')
153 # STEP #5
154 show_step(5)
155 openstack_actions.run_tempest(pattern='smoke')
156
157 LOG.info("*************** DONE **************")
158
159 @pytest.mark.grab_versions
160 @pytest.mark.fail_snapshot
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200161 @pytest.mark.revert_snapshot(ext.SNAPSHOT.sl_deployed)
Dennis Dmitriev513fdf72017-11-30 12:22:25 +0200162 def test_restart_mon01_node(self, openstack_actions,
163 sl_os_deployed, show_step):
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300164 """Test restart mon01
165
166 Scenario:
167 1. Prepare salt on hosts
168 2. Setup controller nodes
169 3. Setup compute, monitoring nodes
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300170 4. Check targets before restart
171 5. Restart mon01
172 6. Check targets after restart
Oleksii Butenko112ebdf2018-01-05 11:33:39 +0200173 7. Run LMA smoke after failover
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300174
175
176 """
177 # STEP #1,2,3
178 show_step(1)
179 show_step(2)
180 show_step(3)
181
182 # STEP #4
183 show_step(4)
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200184 mon_nodes = sl_os_deployed.get_monitoring_nodes()
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300185 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200186 sl_os_deployed.check_prometheus_targets(mon_nodes)
187 before_result = sl_os_deployed.run_sl_tests_json(
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300188 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
189 'tests/prometheus/', 'test_alerts.py')
190 failed_tests = [test['name'] for test in
191 before_result if 'passed' not in test['outcome']]
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300192 # STEP #5
193 show_step(5)
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300194 openstack_actions.warm_restart_nodes('mon01')
195 # STEP #6
196 show_step(6)
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200197 sl_os_deployed.check_prometheus_targets(mon_nodes)
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300198 # STEP #7
199 show_step(7)
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300200 # Run SL component tetsts
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200201 after_result = sl_os_deployed.run_sl_tests_json(
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300202 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
203 'tests/prometheus/', 'test_alerts.py')
204 for test in after_result:
205 if test['name'] not in failed_tests:
206 assert 'passed' in test['outcome'], \
207 'Failed test {}'.format(test)
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300208 LOG.info("*************** DONE **************")
209
210 @pytest.mark.grab_versions
211 @pytest.mark.fail_snapshot
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200212 @pytest.mark.revert_snapshot(ext.SNAPSHOT.sl_deployed)
213 def test_warm_shutdown_mon01_node(self, openstack_actions,
214 sl_os_deployed,
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300215 show_step):
216 """Test warm shutdown mon01
217
218 Scenario:
219 1. Prepare salt on hosts
220 2. Setup controller nodes
221 3. Setup compute, monitoring nodes
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300222 4. Check LMA before mon node shutdown
223 5. Shutdown mon01 node
224 6. Run LMA tests after failover
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300225
226
227 """
228 # STEP #1,2,3
229 show_step(1)
230 show_step(2)
231 show_step(3)
232
233 # STEP #4
234 show_step(4)
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200235 mon_nodes = sl_os_deployed.get_monitoring_nodes()
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300236 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200237 sl_os_deployed.check_prometheus_targets(mon_nodes)
238 before_result = sl_os_deployed.run_sl_tests_json(
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300239 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
240 'tests/prometheus/', 'test_alerts.py')
241 failed_tests = [test['name'] for test in
242 before_result if 'passed' not in test['outcome']]
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300243 # STEP #5
244 show_step(5)
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300245 openstack_actions.warm_shutdown_openstack_nodes('mon01')
246 # STEP #6
247 show_step(6)
248 # Run SL component tetsts
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200249 after_result = sl_os_deployed.run_sl_tests_json(
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300250 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
251 'tests/prometheus/', 'test_alerts.py')
252 for test in after_result:
253 if test['name'] not in failed_tests:
254 assert 'passed' in test['outcome'], \
255 'Failed test {}'.format(test)
256 LOG.info("*************** DONE **************")
257
258 @pytest.mark.grab_versions
259 @pytest.mark.fail_snapshot
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200260 @pytest.mark.revert_snapshot(ext.SNAPSHOT.sl_deployed)
261 def test_kill_influxdb_relay_mon01_node(self, sl_os_deployed,
262 show_step):
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300263 """Test kill influxdb relay on mon01 node
264
265 Scenario:
266 1. Prepare salt on hosts
267 2. Setup controller nodes
268 3. Setup compute, monitoring nodes
269 4. Check LMA before mon node shutdown
270 5. Kill influxdb relay on mon01 node
271 6. Post data into influx
272 7. Get data from all healthy nodes
273 8. Start influx db
274 9. Request data on mon01
275 10. Run LMA tests after fail and compare with result before fail
276
277
278 """
279 # STEP #1,2,3
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200280 show_step(1)
281 show_step(2)
282 show_step(3)
283
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300284 # STEP #4
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200285 show_step(4)
286 mon_nodes = sl_os_deployed.get_monitoring_nodes()
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300287 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200288 before_result = sl_os_deployed.run_sl_tests_json(
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300289 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
290 'tests/prometheus/', 'test_alerts.py')
291 failed_tests = [test['name'] for test in
292 before_result if 'passed' not in test['outcome']]
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200293
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300294 # STEP #5
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200295 show_step(5)
296 sl_os_deployed.kill_sl_service_on_node('mon01', 'influxdb-relay')
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200297
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300298 # STEP #6
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200299 show_step(6)
300 sl_os_deployed.post_data_into_influx('mon02')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300301
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200302 # STEP #7
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200303 show_step(7)
304 assert 'mymeas' in sl_os_deployed.check_data_in_influxdb('mon02')
305 assert 'mymeas' in sl_os_deployed.check_data_in_influxdb('mon03')
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200306
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300307 # STEP #8
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200308 show_step(8)
309 sl_os_deployed.start_service('mon01', 'influxdb-relay')
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200310
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300311 # STEP #9
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200312 show_step(9)
313 assert 'mymeas' in sl_os_deployed.check_data_in_influxdb('mon01')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300314
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300315 # STEP #10
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200316 show_step(10)
317 after_result = sl_os_deployed.run_sl_tests_json(
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300318 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
319 'tests/prometheus/', 'test_alerts.py')
320 for test in after_result:
321 if test['name'] not in failed_tests:
322 assert 'passed' in test['outcome'], \
323 'Failed test {}'.format(test)
324 LOG.info("*************** DONE **************")
325
326 @pytest.mark.grab_versions
327 @pytest.mark.fail_snapshot
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200328 @pytest.mark.revert_snapshot(ext.SNAPSHOT.sl_deployed)
329 def test_kill_influxdb_mon01_node(self, sl_os_deployed, show_step):
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300330 """Test kill influxdb on mon01 node
331
332 Scenario:
333 1. Prepare salt on hosts
334 2. Setup controller nodes
335 3. Setup compute, monitoring nodes
336 4. Check LMA before mon node shutdown
337 5. Kill influxdb on mon01 node
338 6. Post data into influx
339 7. Get data from all healthy nodes
340 8. Start influx db
341 9. Request data on mon01
342 10. Run LMA tests after fail and compare with result before fail
343
344
345 """
346 # STEP #1,2,3
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200347 show_step(1)
348 show_step(2)
349 show_step(3)
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300350
351 # STEP #4
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200352 show_step(4)
353 mon_nodes = sl_os_deployed.get_monitoring_nodes()
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300354 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200355 before_result = sl_os_deployed.run_sl_tests_json(
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300356 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
357 'tests/prometheus/', 'test_alerts.py')
358 failed_tests = [test['name'] for test in
359 before_result if 'passed' not in test['outcome']]
360 # STEP #5
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200361 show_step(5)
362 sl_os_deployed.kill_sl_service_on_node('mon01', 'influxd')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300363
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200364 # STEP #6
365 show_step(6)
366 sl_os_deployed.post_data_into_influx('mon02')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300367
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300368 # STEP #7
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200369 show_step(7)
370 assert 'mymeas' in sl_os_deployed.check_data_in_influxdb('mon02')
371 assert 'mymeas' in sl_os_deployed.check_data_in_influxdb('mon03')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300372
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300373 # STEP #8
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200374 show_step(8)
375 sl_os_deployed.start_service('mon01', 'influxd')
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200376
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300377 # STEP #9
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200378 show_step(9)
379 self.check_influxdb_xfail(sl_os_deployed, 'mon01', 'mymeas')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300380
Dennis Dmitriev28fd0492017-11-29 13:33:21 +0200381 # STEP #10
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200382 show_step(10)
383 after_result = sl_os_deployed.run_sl_tests_json(
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300384 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
385 'tests/prometheus/', 'test_alerts.py')
386 for test in after_result:
387 if test['name'] not in failed_tests:
388 assert 'passed' in test['outcome'], \
389 'Failed test {}'.format(test)
390 LOG.info("*************** DONE **************")
391
392 @pytest.mark.grab_versions
393 @pytest.mark.fail_snapshot
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200394 @pytest.mark.revert_snapshot(ext.SNAPSHOT.sl_deployed)
395 def test_stop_influxdb_relay_mon_nodes(self, sl_os_deployed,
396 show_step):
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300397 """Test stop influxdb relay on mon01 node
398
399 Scenario:
400 1. Prepare salt on hosts
401 2. Setup controller nodes
402 3. Setup compute, monitoring nodes
403 4. Check LMA before mon node shutdown
404 5. Stop influxdb relay on mon01 and mon02 nodes
405 6. Post data into influx
406 7. Get data from all healthy nodes
407 8. Start influx db
408 9. Request data on mon01, 02
409 10. Run LMA tests after fail and compare with result before fail
410
411
412 """
413 # STEP #1,2,3
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200414 show_step(1)
415 show_step(2)
416 show_step(3)
417
418 # STEP #4
419 show_step(4)
420 mon_nodes = sl_os_deployed.get_monitoring_nodes()
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300421 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200422 before_result = sl_os_deployed.run_sl_tests_json(
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300423 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
424 'tests/prometheus/', 'test_alerts.py')
425 failed_tests = [test['name'] for test in
426 before_result if 'passed' not in test['outcome']]
427 # STEP #5
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200428 show_step(5)
429 sl_os_deployed.stop_sl_service_on_node('mon01', 'influxdb-relay')
430 sl_os_deployed.stop_sl_service_on_node('mon02', 'influxdb-relay')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300431
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300432 # STEP #6
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200433 show_step(6)
434 sl_os_deployed.post_data_into_influx('mon03')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300435
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300436 # STEP #7
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200437 show_step(7)
438 assert 'mymeas' in sl_os_deployed.check_data_in_influxdb('mon03')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300439
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300440 # STEP #8
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200441 show_step(8)
442 sl_os_deployed.start_service('mon01', 'influxdb-relay')
443 sl_os_deployed.start_service('mon02', 'influxdb-relay')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300444
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200445 # STEP #9
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200446 show_step(9)
447 assert 'mymeas' in sl_os_deployed.check_data_in_influxdb('mon01')
448 assert 'mymeas' in sl_os_deployed.check_data_in_influxdb('mon02')
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200449
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300450 # STEP #10
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200451 show_step(10)
452 after_result = sl_os_deployed.run_sl_tests_json(
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300453 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
454 'tests/prometheus/', 'test_alerts.py')
455 for test in after_result:
456 if test['name'] not in failed_tests:
457 assert 'passed' in test['outcome'], \
458 'Failed test {}'.format(test)
459 LOG.info("*************** DONE **************")
460
461 @pytest.mark.grab_versions
462 @pytest.mark.fail_snapshot
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200463 @pytest.mark.revert_snapshot(ext.SNAPSHOT.sl_deployed)
464 def test_stop_influxdb_mon_nodes(self, sl_os_deployed, show_step):
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300465 """Test stop influxdb on mon01 node
466
467 Scenario:
468 1. Prepare salt on hosts
469 2. Setup controller nodes
470 3. Setup compute, monitoring nodes
471 4. Check LMA before mon node shutdown
472 5. Stop influxdb on mon01 and mon02 node
473 6. Post data into influx
474 7. Get data from all healthy nodes
475 8. Start influx db
476 9. Request data on mon01
477 10. Run LMA tests after fail and compare with result before fail
478
479
480 """
481 # STEP #1,2,3
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200482 show_step(1)
483 show_step(2)
484 show_step(3)
485
486 # STEP #4
487 show_step(4)
488 mon_nodes = sl_os_deployed.get_monitoring_nodes()
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300489 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200490 before_result = sl_os_deployed.run_sl_tests_json(
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300491 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
492 'tests/prometheus/', 'test_alerts.py')
493 failed_tests = [test['name'] for test in
494 before_result if 'passed' not in test['outcome']]
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200495
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300496 # STEP #5
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200497 show_step(5)
498 sl_os_deployed.stop_sl_service_on_node('mon01', 'influxdb')
499 sl_os_deployed.stop_sl_service_on_node('mon02', 'influxdb')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300500
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300501 # STEP #6
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200502 show_step(6)
503 sl_os_deployed.post_data_into_influx('mon03')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300504
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300505 # STEP #7
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200506 show_step(7)
507 assert 'mymeas' in sl_os_deployed.check_data_in_influxdb('mon03')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300508
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300509 # STEP #8
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200510 show_step(8)
511 sl_os_deployed.start_service('mon01', 'influxdb')
512 sl_os_deployed.start_service('mon02', 'influxdb')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300513
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200514 # STEP #9
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200515 show_step(9)
516 self.check_influxdb_xfail(sl_os_deployed, 'mon01', 'mymeas')
517 self.check_influxdb_xfail(sl_os_deployed, 'mon02', 'mymeas')
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200518
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300519 # STEP #10
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +0200520 show_step(10)
521 after_result = sl_os_deployed.run_sl_tests_json(
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300522 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
523 'tests/prometheus/', 'test_alerts.py')
524 for test in after_result:
525 if test['name'] not in failed_tests:
526 assert 'passed' in test['outcome'], \
527 'Failed test {}'.format(test)
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300528 LOG.info("*************** DONE **************")
Oleksii Butenko112ebdf2018-01-05 11:33:39 +0200529
530 @pytest.mark.grab_versions
531 @pytest.mark.fail_snapshot
532 @pytest.mark.revert_snapshot(ext.SNAPSHOT.sl_deployed)
533 def test_restart_mon_with_vip(self, sl_os_deployed,
534 openstack_actions, salt_actions,
535 common_services_actions, show_step):
536 """Test restart mon with VIP
537
538 Scenario:
539 1. Prepare salt on hosts
540 2. Setup controller nodes
541 3. Setup compute and monitoring nodes
542 4. Check LMA before mon node restart
543 5. Find mon minion id with VIP
544 6. Restart mon minion id with VIP
545 7. Check that VIP was actually migrated on a new node
546 8. Run tempest smoke after failover
547
548
549 """
550 # TR case #4753939
551 common_services_actions.check_keepalived_pillar()
552 salt = salt_actions
553
554 # STEP #1,2,3
555 show_step(1)
556 show_step(2)
557 show_step(3)
558
559 # STEP #4
560 show_step(4)
561 mon_nodes = sl_os_deployed.get_monitoring_nodes()
562 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
563 before_result = sl_os_deployed.run_sl_tests_json(
564 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
565 'tests/prometheus/', 'test_alerts.py')
566 failed_tests = [test['name'] for test in
567 before_result if 'passed' not in test['outcome']]
568
569 # STEP #5
570 show_step(5)
571 mon_vip_pillar = salt.get_pillar(
572 tgt="mon0*",
573 pillar="_param:cluster_vip_address")[0]
574 vip = [vip for minion_id, vip in mon_vip_pillar.items()][0]
575 minion_vip = common_services_actions.get_keepalived_vip_minion_id(vip)
576 LOG.info("VIP {0} is on {1}".format(vip, minion_vip))
577
578 # STEP #6
579 show_step(6)
580 openstack_actions.warm_restart_nodes(minion_vip)
581
582 # STEP #7
583 show_step(7)
584 # Check that VIP has been actually migrated to a new node
585 new_minion_vip = common_services_actions.get_keepalived_vip_minion_id(
586 vip)
587 LOG.info("Migrated VIP {0} is on {1}".format(vip, new_minion_vip))
588 assert new_minion_vip != minion_vip, (
589 "VIP {0} wasn't migrated from {1} after node reboot!"
590 .format(vip, new_minion_vip))
591 common_services_actions.check_keepalived_pillar()
592
593 # STEP #8
594 show_step(8)
595 # Run SL component tetsts
596 after_result = sl_os_deployed.run_sl_tests_json(
597 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
598 'tests/prometheus/', 'test_alerts.py')
599 for test in after_result:
600 if test['name'] not in failed_tests:
601 assert 'passed' in test['outcome'], \
602 'Failed test {}'.format(test)
603 LOG.info("*************** DONE **************")