blob: 9b416187dfdc40eaa09f4dc34064e2a52c158066 [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
18
19LOG = logger.logger
20
21
22class TestFailover(object):
23 """Test class for testing OpenStack nodes failover"""
24
25 @pytest.mark.grab_versions
26 @pytest.mark.fail_snapshot
27 def test_warm_shutdown_ctl01_node(self, underlay, openstack_deployed,
28 openstack_actions, show_step):
29 """Test warm shutdown ctl01
30
31 Scenario:
32 1. Prepare salt on hosts
33 2. Setup controller nodes
34 3. Setup compute nodes
35 4. Shutdown ctl01
36 5. Run tempest smoke after failover
37
38
39 """
40 # STEP #1,2,3
41 show_step(1)
42 show_step(2)
43 show_step(3)
44 # STEP #4
45 show_step(4)
46 openstack_actions.warm_shutdown_openstack_nodes('ctl01')
47 # STEP #5
48 show_step(5)
49 openstack_actions.run_tempest(pattern='smoke')
50
51 LOG.info("*************** DONE **************")
52
53 @pytest.mark.grab_versions
54 @pytest.mark.fail_snapshot
55 def test_restart_ctl01_node(self, underlay, openstack_deployed,
Dennis Dmitriev9b02c8b2017-11-13 15:31:35 +020056 openstack_actions, show_step):
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +030057 """Test restart ctl01
58
59 Scenario:
60 1. Prepare salt on hosts
61 2. Setup controller nodes
62 3. Setup compute nodes
63 4. Restart ctl01
64 5. Run tempest smoke after failover
65
66
67 """
68 # STEP #1,2,3
69 show_step(1)
70 show_step(2)
71 show_step(3)
72
73 # STEP #4
74 show_step(4)
75 openstack_actions.warm_restart_nodes('ctl01')
76 # STEP #5
77 show_step(5)
78 openstack_actions.run_tempest(pattern='smoke')
79
80 LOG.info("*************** DONE **************")
81
82 @pytest.mark.grab_versions
83 @pytest.mark.fail_snapshot
84 def test_warm_shutdown_cmp01_node(self, underlay, openstack_deployed,
85 openstack_actions, show_step):
86 """Test warm shutdown cmp01
87
88 Scenario:
89 1. Prepare salt on hosts
90 2. Setup controller nodes
91 3. Setup compute nodes
92 4. Shutdown cmp01
93 5. Run tempest smoke after failover
94
95
96 """
97 # STEP #1,2,3
98 show_step(1)
99 show_step(2)
100 show_step(3)
101
102 # STEP #4
103 show_step(4)
104 openstack_actions.warm_shutdown_openstack_nodes('cmp01')
105 # STEP #5
106 show_step(5)
107 openstack_actions.run_tempest(pattern='smoke')
108
109 LOG.info("*************** DONE **************")
110
111 @pytest.mark.grab_versions
112 @pytest.mark.fail_snapshot
113 def test_restart_cmp01_node(self, underlay, openstack_deployed,
114 openstack_actions, show_step):
115 """Test restart cmp01
116
117 Scenario:
118 1. Prepare salt on hosts
119 2. Setup controller nodes
120 3. Setup compute nodes
121 4. Restart cmp01
122 5. Run tempest smoke after failover
123
124
125 """
126 # STEP #1,2,3
127 show_step(1)
128 show_step(2)
129 show_step(3)
130
131 # STEP #4
132 show_step(4)
133 openstack_actions.warm_restart_nodes('cmp01')
134 # STEP #5
135 show_step(5)
136 openstack_actions.run_tempest(pattern='smoke')
137
138 LOG.info("*************** DONE **************")
139
140 @pytest.mark.grab_versions
141 @pytest.mark.fail_snapshot
142 def test_restart_mon01_node(self, underlay, openstack_deployed,
143 openstack_actions, sl_deployed,
144 show_step):
145 """Test restart mon01
146
147 Scenario:
148 1. Prepare salt on hosts
149 2. Setup controller nodes
150 3. Setup compute, monitoring nodes
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300151 4. Check targets before restart
152 5. Restart mon01
153 6. Check targets after restart
154 6. Run LMA smoke after failover
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300155
156
157 """
158 # STEP #1,2,3
159 show_step(1)
160 show_step(2)
161 show_step(3)
162
163 # STEP #4
164 show_step(4)
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300165 mon_nodes = sl_deployed.get_monitoring_nodes()
166 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
167 sl_deployed.check_prometheus_targets(mon_nodes)
168 before_result = sl_deployed.run_sl_tests_json(
169 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
170 'tests/prometheus/', 'test_alerts.py')
171 failed_tests = [test['name'] for test in
172 before_result if 'passed' not in test['outcome']]
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300173 # STEP #5
174 show_step(5)
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300175 openstack_actions.warm_restart_nodes('mon01')
176 # STEP #6
177 show_step(6)
178 sl_deployed.check_prometheus_targets(mon_nodes)
179 # STEP #7
180 show_step(7)
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300181 # Run SL component tetsts
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300182 after_result = sl_deployed.run_sl_tests_json(
183 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
184 'tests/prometheus/', 'test_alerts.py')
185 for test in after_result:
186 if test['name'] not in failed_tests:
187 assert 'passed' in test['outcome'], \
188 'Failed test {}'.format(test)
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300189 LOG.info("*************** DONE **************")
190
191 @pytest.mark.grab_versions
192 @pytest.mark.fail_snapshot
193 def test_warm_shutdown_mon01_node(self, underlay, openstack_deployed,
194 openstack_actions, sl_deployed,
195 show_step):
196 """Test warm shutdown mon01
197
198 Scenario:
199 1. Prepare salt on hosts
200 2. Setup controller nodes
201 3. Setup compute, monitoring nodes
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300202 4. Check LMA before mon node shutdown
203 5. Shutdown mon01 node
204 6. Run LMA tests after failover
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300205
206
207 """
208 # STEP #1,2,3
209 show_step(1)
210 show_step(2)
211 show_step(3)
212
213 # STEP #4
214 show_step(4)
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300215 mon_nodes = sl_deployed.get_monitoring_nodes()
216 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
217 sl_deployed.check_prometheus_targets(mon_nodes)
218 before_result = sl_deployed.run_sl_tests_json(
219 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
220 'tests/prometheus/', 'test_alerts.py')
221 failed_tests = [test['name'] for test in
222 before_result if 'passed' not in test['outcome']]
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300223 # STEP #5
224 show_step(5)
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300225 openstack_actions.warm_shutdown_openstack_nodes('mon01')
226 # STEP #6
227 show_step(6)
228 # Run SL component tetsts
229 after_result = sl_deployed.run_sl_tests_json(
230 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
231 'tests/prometheus/', 'test_alerts.py')
232 for test in after_result:
233 if test['name'] not in failed_tests:
234 assert 'passed' in test['outcome'], \
235 'Failed test {}'.format(test)
236 LOG.info("*************** DONE **************")
237
238 @pytest.mark.grab_versions
239 @pytest.mark.fail_snapshot
240 def test_kill_influxdb_relay_mon01_node(self, underlay,
241 openstack_deployed,
242 openstack_actions,
243 sl_deployed):
244 """Test kill influxdb relay on mon01 node
245
246 Scenario:
247 1. Prepare salt on hosts
248 2. Setup controller nodes
249 3. Setup compute, monitoring nodes
250 4. Check LMA before mon node shutdown
251 5. Kill influxdb relay on mon01 node
252 6. Post data into influx
253 7. Get data from all healthy nodes
254 8. Start influx db
255 9. Request data on mon01
256 10. Run LMA tests after fail and compare with result before fail
257
258
259 """
260 # STEP #1,2,3
261 # STEP #4
262 mon_nodes = sl_deployed.get_monitoring_nodes()
263 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
264 before_result = sl_deployed.run_sl_tests_json(
265 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
266 'tests/prometheus/', 'test_alerts.py')
267 failed_tests = [test['name'] for test in
268 before_result if 'passed' not in test['outcome']]
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200269
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300270 # STEP #5
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300271 sl_deployed.kill_sl_service_on_node('mon01', 'influxdb-relay')
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200272
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300273 # STEP #6
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300274 sl_deployed.post_data_into_influx('mon02')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300275
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200276 # STEP #7
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300277 assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon02')
278 assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon03')
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200279
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300280 # STEP #8
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300281 sl_deployed.start_service('mon01', 'influxdb-relay')
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200282
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300283 # STEP #9
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200284 def check_relay_mon01():
285 return 'mymeas' in sl_deployed.check_data_in_influxdb('mon01')
286 helpers.wait(check_relay_mon01,
287 timeout=10, interval=2,
288 timeout_msg=('Influxdb data was not replicated to mon01'))
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300289
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300290 # STEP #10
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300291 after_result = sl_deployed.run_sl_tests_json(
292 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
293 'tests/prometheus/', 'test_alerts.py')
294 for test in after_result:
295 if test['name'] not in failed_tests:
296 assert 'passed' in test['outcome'], \
297 'Failed test {}'.format(test)
298 LOG.info("*************** DONE **************")
299
300 @pytest.mark.grab_versions
301 @pytest.mark.fail_snapshot
302 def test_kill_influxdb_mon01_node(self, underlay,
303 openstack_deployed,
304 openstack_actions,
305 sl_deployed):
306 """Test kill influxdb on mon01 node
307
308 Scenario:
309 1. Prepare salt on hosts
310 2. Setup controller nodes
311 3. Setup compute, monitoring nodes
312 4. Check LMA before mon node shutdown
313 5. Kill influxdb on mon01 node
314 6. Post data into influx
315 7. Get data from all healthy nodes
316 8. Start influx db
317 9. Request data on mon01
318 10. Run LMA tests after fail and compare with result before fail
319
320
321 """
322 # STEP #1,2,3
323
324 # STEP #4
325
326 mon_nodes = sl_deployed.get_monitoring_nodes()
327 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
328 before_result = sl_deployed.run_sl_tests_json(
329 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
330 'tests/prometheus/', 'test_alerts.py')
331 failed_tests = [test['name'] for test in
332 before_result if 'passed' not in test['outcome']]
333 # STEP #5
334
335 sl_deployed.kill_sl_service_on_node('mon01', 'influxd')
336
337 sl_deployed.post_data_into_influx('mon02')
338 # STEP #7
339
340 assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon02')
341 assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon03')
342 # STEP #8
343
344 sl_deployed.start_service('mon01', 'influxd')
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200345
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300346 # STEP #9
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200347 def check_relay_mon01():
348 return 'mymeas' in sl_deployed.check_data_in_influxdb('mon01')
349 helpers.wait(check_relay_mon01,
350 timeout=10, interval=2,
351 timeout_msg=('Influxdb data was not replicated to mon01'))
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300352 # STEP #10
353
354 after_result = sl_deployed.run_sl_tests_json(
355 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
356 'tests/prometheus/', 'test_alerts.py')
357 for test in after_result:
358 if test['name'] not in failed_tests:
359 assert 'passed' in test['outcome'], \
360 'Failed test {}'.format(test)
361 LOG.info("*************** DONE **************")
362
363 @pytest.mark.grab_versions
364 @pytest.mark.fail_snapshot
365 def test_stop_influxdb_relay_mon_nodes(self, underlay,
Dennis Dmitriev9b02c8b2017-11-13 15:31:35 +0200366 openstack_deployed,
367 openstack_actions,
368 sl_deployed):
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300369 """Test stop influxdb relay on mon01 node
370
371 Scenario:
372 1. Prepare salt on hosts
373 2. Setup controller nodes
374 3. Setup compute, monitoring nodes
375 4. Check LMA before mon node shutdown
376 5. Stop influxdb relay on mon01 and mon02 nodes
377 6. Post data into influx
378 7. Get data from all healthy nodes
379 8. Start influx db
380 9. Request data on mon01, 02
381 10. Run LMA tests after fail and compare with result before fail
382
383
384 """
385 # STEP #1,2,3
386 mon_nodes = sl_deployed.get_monitoring_nodes()
387 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
388 before_result = sl_deployed.run_sl_tests_json(
389 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
390 'tests/prometheus/', 'test_alerts.py')
391 failed_tests = [test['name'] for test in
392 before_result if 'passed' not in test['outcome']]
393 # STEP #5
394
395 sl_deployed.stop_sl_service_on_node('mon01', 'influxdb-relay')
396 sl_deployed.stop_sl_service_on_node('mon02', 'influxdb-relay')
397 # STEP #6
398
399 sl_deployed.post_data_into_influx('mon03')
400 # STEP #7
401
402 assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon03')
403 # STEP #8
404
405 sl_deployed.start_service('mon01', 'influxdb-relay')
406 sl_deployed.start_service('mon02', 'influxdb-relay')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300407
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200408 # STEP #9
409 def check_relay_mon01():
410 return 'mymeas' in sl_deployed.check_data_in_influxdb('mon01')
411
412 def check_relay_mon02():
413 return 'mymeas' in sl_deployed.check_data_in_influxdb('mon02')
414 helpers.wait(check_relay_mon01,
415 timeout=10, interval=2,
416 timeout_msg=('Influxdb data was not replicated to mon01'))
417 helpers.wait(check_relay_mon02,
418 timeout=10, interval=2,
419 timeout_msg=('Influxdb data was not replicated to mon02'))
420
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300421 # STEP #10
422
423 after_result = sl_deployed.run_sl_tests_json(
424 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
425 'tests/prometheus/', 'test_alerts.py')
426 for test in after_result:
427 if test['name'] not in failed_tests:
428 assert 'passed' in test['outcome'], \
429 'Failed test {}'.format(test)
430 LOG.info("*************** DONE **************")
431
432 @pytest.mark.grab_versions
433 @pytest.mark.fail_snapshot
434 def test_stop_influxdb_mon_nodes(self, underlay,
Dennis Dmitriev9b02c8b2017-11-13 15:31:35 +0200435 openstack_deployed,
436 openstack_actions,
437 sl_deployed):
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300438 """Test stop influxdb on mon01 node
439
440 Scenario:
441 1. Prepare salt on hosts
442 2. Setup controller nodes
443 3. Setup compute, monitoring nodes
444 4. Check LMA before mon node shutdown
445 5. Stop influxdb on mon01 and mon02 node
446 6. Post data into influx
447 7. Get data from all healthy nodes
448 8. Start influx db
449 9. Request data on mon01
450 10. Run LMA tests after fail and compare with result before fail
451
452
453 """
454 # STEP #1,2,3
455 mon_nodes = sl_deployed.get_monitoring_nodes()
456 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
457 before_result = sl_deployed.run_sl_tests_json(
458 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
459 'tests/prometheus/', 'test_alerts.py')
460 failed_tests = [test['name'] for test in
461 before_result if 'passed' not in test['outcome']]
462 # STEP #5
463
464 sl_deployed.stop_sl_service_on_node('mon01', 'influxdb')
465 sl_deployed.stop_sl_service_on_node('mon02', 'influxdb')
466 # STEP #6
467
468 sl_deployed.post_data_into_influx('mon03')
469 # STEP #7
470
471 assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon03')
472 # STEP #8
473
474 sl_deployed.start_service('mon01', 'influxdb')
475 sl_deployed.start_service('mon02', 'influxdb')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300476
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200477 # STEP #9
478 def check_relay_mon01():
479 return 'mymeas' in sl_deployed.check_data_in_influxdb('mon01')
480
481 def check_relay_mon02():
482 return 'mymeas' in sl_deployed.check_data_in_influxdb('mon02')
483 helpers.wait(check_relay_mon01,
484 timeout=10, interval=2,
485 timeout_msg=('Influxdb data was not replicated to mon01'))
486 helpers.wait(check_relay_mon02,
487 timeout=10, interval=2,
488 timeout_msg=('Influxdb data was not replicated to mon02'))
489
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300490 # STEP #10
Dennis Dmitriev9b02c8b2017-11-13 15:31:35 +0200491
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300492 after_result = sl_deployed.run_sl_tests_json(
493 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
494 'tests/prometheus/', 'test_alerts.py')
495 for test in after_result:
496 if test['name'] not in failed_tests:
497 assert 'passed' in test['outcome'], \
498 'Failed test {}'.format(test)
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300499 LOG.info("*************** DONE **************")