blob: 15dc2a15586ed685bb464d55404e68c3fad1ea17 [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
Dennis Dmitriev28fd0492017-11-29 13:33:21 +020025 def check_influxdb_xfail(sl_deployed, node_name, value):
26
27 def check_influxdb_data():
28 return value in sl_deployed.check_data_in_influxdb(node_name)
29
30 try:
31 helpers.wait(
32 check_influxdb_data,
33 timeout=10, interval=2,
34 timeout_msg=('Influxdb data {0} was not replicated to {1} '
35 '[https://mirantis.jira.com/browse/PROD-16272]'
36 .format(value, node_name)))
37 except Exception:
38 pytest.xfail('Influxdb data {0} was not replicated to {1} '
39 '[https://mirantis.jira.com/browse/PROD-16272]'
40 .format(value, node_name))
41
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +030042 @pytest.mark.grab_versions
43 @pytest.mark.fail_snapshot
44 def test_warm_shutdown_ctl01_node(self, underlay, openstack_deployed,
45 openstack_actions, show_step):
46 """Test warm shutdown ctl01
47
48 Scenario:
49 1. Prepare salt on hosts
50 2. Setup controller nodes
51 3. Setup compute nodes
52 4. Shutdown ctl01
53 5. Run tempest smoke after failover
54
55
56 """
57 # STEP #1,2,3
58 show_step(1)
59 show_step(2)
60 show_step(3)
61 # STEP #4
62 show_step(4)
63 openstack_actions.warm_shutdown_openstack_nodes('ctl01')
64 # STEP #5
65 show_step(5)
66 openstack_actions.run_tempest(pattern='smoke')
67
68 LOG.info("*************** DONE **************")
69
70 @pytest.mark.grab_versions
71 @pytest.mark.fail_snapshot
72 def test_restart_ctl01_node(self, underlay, openstack_deployed,
Dennis Dmitriev9b02c8b2017-11-13 15:31:35 +020073 openstack_actions, show_step):
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +030074 """Test restart ctl01
75
76 Scenario:
77 1. Prepare salt on hosts
78 2. Setup controller nodes
79 3. Setup compute nodes
80 4. Restart ctl01
81 5. Run tempest smoke after failover
82
83
84 """
85 # STEP #1,2,3
86 show_step(1)
87 show_step(2)
88 show_step(3)
89
90 # STEP #4
91 show_step(4)
92 openstack_actions.warm_restart_nodes('ctl01')
93 # STEP #5
94 show_step(5)
95 openstack_actions.run_tempest(pattern='smoke')
96
97 LOG.info("*************** DONE **************")
98
99 @pytest.mark.grab_versions
100 @pytest.mark.fail_snapshot
101 def test_warm_shutdown_cmp01_node(self, underlay, openstack_deployed,
102 openstack_actions, show_step):
103 """Test warm shutdown cmp01
104
105 Scenario:
106 1. Prepare salt on hosts
107 2. Setup controller nodes
108 3. Setup compute nodes
109 4. Shutdown cmp01
110 5. Run tempest smoke after failover
111
112
113 """
114 # STEP #1,2,3
115 show_step(1)
116 show_step(2)
117 show_step(3)
118
119 # STEP #4
120 show_step(4)
121 openstack_actions.warm_shutdown_openstack_nodes('cmp01')
122 # STEP #5
123 show_step(5)
124 openstack_actions.run_tempest(pattern='smoke')
125
126 LOG.info("*************** DONE **************")
127
128 @pytest.mark.grab_versions
129 @pytest.mark.fail_snapshot
130 def test_restart_cmp01_node(self, underlay, openstack_deployed,
131 openstack_actions, show_step):
132 """Test restart cmp01
133
134 Scenario:
135 1. Prepare salt on hosts
136 2. Setup controller nodes
137 3. Setup compute nodes
138 4. Restart cmp01
139 5. Run tempest smoke after failover
140
141
142 """
143 # STEP #1,2,3
144 show_step(1)
145 show_step(2)
146 show_step(3)
147
148 # STEP #4
149 show_step(4)
150 openstack_actions.warm_restart_nodes('cmp01')
151 # STEP #5
152 show_step(5)
153 openstack_actions.run_tempest(pattern='smoke')
154
155 LOG.info("*************** DONE **************")
156
157 @pytest.mark.grab_versions
158 @pytest.mark.fail_snapshot
159 def test_restart_mon01_node(self, underlay, openstack_deployed,
160 openstack_actions, sl_deployed,
161 show_step):
162 """Test restart mon01
163
164 Scenario:
165 1. Prepare salt on hosts
166 2. Setup controller nodes
167 3. Setup compute, monitoring nodes
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300168 4. Check targets before restart
169 5. Restart mon01
170 6. Check targets after restart
171 6. Run LMA smoke after failover
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300172
173
174 """
175 # STEP #1,2,3
176 show_step(1)
177 show_step(2)
178 show_step(3)
179
180 # STEP #4
181 show_step(4)
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300182 mon_nodes = sl_deployed.get_monitoring_nodes()
183 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
184 sl_deployed.check_prometheus_targets(mon_nodes)
185 before_result = sl_deployed.run_sl_tests_json(
186 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
187 'tests/prometheus/', 'test_alerts.py')
188 failed_tests = [test['name'] for test in
189 before_result if 'passed' not in test['outcome']]
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300190 # STEP #5
191 show_step(5)
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300192 openstack_actions.warm_restart_nodes('mon01')
193 # STEP #6
194 show_step(6)
195 sl_deployed.check_prometheus_targets(mon_nodes)
196 # STEP #7
197 show_step(7)
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300198 # Run SL component tetsts
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300199 after_result = sl_deployed.run_sl_tests_json(
200 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
201 'tests/prometheus/', 'test_alerts.py')
202 for test in after_result:
203 if test['name'] not in failed_tests:
204 assert 'passed' in test['outcome'], \
205 'Failed test {}'.format(test)
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300206 LOG.info("*************** DONE **************")
207
208 @pytest.mark.grab_versions
209 @pytest.mark.fail_snapshot
210 def test_warm_shutdown_mon01_node(self, underlay, openstack_deployed,
211 openstack_actions, sl_deployed,
212 show_step):
213 """Test warm shutdown mon01
214
215 Scenario:
216 1. Prepare salt on hosts
217 2. Setup controller nodes
218 3. Setup compute, monitoring nodes
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300219 4. Check LMA before mon node shutdown
220 5. Shutdown mon01 node
221 6. Run LMA tests after failover
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300222
223
224 """
225 # STEP #1,2,3
226 show_step(1)
227 show_step(2)
228 show_step(3)
229
230 # STEP #4
231 show_step(4)
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300232 mon_nodes = sl_deployed.get_monitoring_nodes()
233 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
234 sl_deployed.check_prometheus_targets(mon_nodes)
235 before_result = sl_deployed.run_sl_tests_json(
236 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
237 'tests/prometheus/', 'test_alerts.py')
238 failed_tests = [test['name'] for test in
239 before_result if 'passed' not in test['outcome']]
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300240 # STEP #5
241 show_step(5)
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300242 openstack_actions.warm_shutdown_openstack_nodes('mon01')
243 # STEP #6
244 show_step(6)
245 # Run SL component tetsts
246 after_result = sl_deployed.run_sl_tests_json(
247 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
248 'tests/prometheus/', 'test_alerts.py')
249 for test in after_result:
250 if test['name'] not in failed_tests:
251 assert 'passed' in test['outcome'], \
252 'Failed test {}'.format(test)
253 LOG.info("*************** DONE **************")
254
255 @pytest.mark.grab_versions
256 @pytest.mark.fail_snapshot
257 def test_kill_influxdb_relay_mon01_node(self, underlay,
258 openstack_deployed,
259 openstack_actions,
260 sl_deployed):
261 """Test kill influxdb relay on mon01 node
262
263 Scenario:
264 1. Prepare salt on hosts
265 2. Setup controller nodes
266 3. Setup compute, monitoring nodes
267 4. Check LMA before mon node shutdown
268 5. Kill influxdb relay on mon01 node
269 6. Post data into influx
270 7. Get data from all healthy nodes
271 8. Start influx db
272 9. Request data on mon01
273 10. Run LMA tests after fail and compare with result before fail
274
275
276 """
277 # STEP #1,2,3
278 # STEP #4
279 mon_nodes = sl_deployed.get_monitoring_nodes()
280 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
281 before_result = sl_deployed.run_sl_tests_json(
282 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
283 'tests/prometheus/', 'test_alerts.py')
284 failed_tests = [test['name'] for test in
285 before_result if 'passed' not in test['outcome']]
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200286
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300287 # STEP #5
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300288 sl_deployed.kill_sl_service_on_node('mon01', 'influxdb-relay')
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200289
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300290 # STEP #6
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300291 sl_deployed.post_data_into_influx('mon02')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300292
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200293 # STEP #7
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300294 assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon02')
295 assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon03')
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200296
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300297 # STEP #8
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300298 sl_deployed.start_service('mon01', 'influxdb-relay')
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200299
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300300 # STEP #9
Dennis Dmitriev28fd0492017-11-29 13:33:21 +0200301 assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon01')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300302
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300303 # STEP #10
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300304 after_result = sl_deployed.run_sl_tests_json(
305 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
306 'tests/prometheus/', 'test_alerts.py')
307 for test in after_result:
308 if test['name'] not in failed_tests:
309 assert 'passed' in test['outcome'], \
310 'Failed test {}'.format(test)
311 LOG.info("*************** DONE **************")
312
313 @pytest.mark.grab_versions
314 @pytest.mark.fail_snapshot
315 def test_kill_influxdb_mon01_node(self, underlay,
316 openstack_deployed,
317 openstack_actions,
318 sl_deployed):
319 """Test kill influxdb on mon01 node
320
321 Scenario:
322 1. Prepare salt on hosts
323 2. Setup controller nodes
324 3. Setup compute, monitoring nodes
325 4. Check LMA before mon node shutdown
326 5. Kill influxdb on mon01 node
327 6. Post data into influx
328 7. Get data from all healthy nodes
329 8. Start influx db
330 9. Request data on mon01
331 10. Run LMA tests after fail and compare with result before fail
332
333
334 """
335 # STEP #1,2,3
336
337 # STEP #4
338
339 mon_nodes = sl_deployed.get_monitoring_nodes()
340 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
341 before_result = sl_deployed.run_sl_tests_json(
342 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
343 'tests/prometheus/', 'test_alerts.py')
344 failed_tests = [test['name'] for test in
345 before_result if 'passed' not in test['outcome']]
346 # STEP #5
347
348 sl_deployed.kill_sl_service_on_node('mon01', 'influxd')
349
350 sl_deployed.post_data_into_influx('mon02')
351 # STEP #7
352
353 assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon02')
354 assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon03')
355 # STEP #8
356
357 sl_deployed.start_service('mon01', 'influxd')
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200358
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300359 # STEP #9
Dennis Dmitriev28fd0492017-11-29 13:33:21 +0200360 self.check_influxdb_xfail(sl_deployed, 'mon01', 'mymeas')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300361
Dennis Dmitriev28fd0492017-11-29 13:33:21 +0200362 # STEP #10
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300363 after_result = sl_deployed.run_sl_tests_json(
364 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
365 'tests/prometheus/', 'test_alerts.py')
366 for test in after_result:
367 if test['name'] not in failed_tests:
368 assert 'passed' in test['outcome'], \
369 'Failed test {}'.format(test)
370 LOG.info("*************** DONE **************")
371
372 @pytest.mark.grab_versions
373 @pytest.mark.fail_snapshot
374 def test_stop_influxdb_relay_mon_nodes(self, underlay,
Dennis Dmitriev9b02c8b2017-11-13 15:31:35 +0200375 openstack_deployed,
376 openstack_actions,
377 sl_deployed):
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300378 """Test stop influxdb relay on mon01 node
379
380 Scenario:
381 1. Prepare salt on hosts
382 2. Setup controller nodes
383 3. Setup compute, monitoring nodes
384 4. Check LMA before mon node shutdown
385 5. Stop influxdb relay on mon01 and mon02 nodes
386 6. Post data into influx
387 7. Get data from all healthy nodes
388 8. Start influx db
389 9. Request data on mon01, 02
390 10. Run LMA tests after fail and compare with result before fail
391
392
393 """
394 # STEP #1,2,3
395 mon_nodes = sl_deployed.get_monitoring_nodes()
396 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
397 before_result = sl_deployed.run_sl_tests_json(
398 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
399 'tests/prometheus/', 'test_alerts.py')
400 failed_tests = [test['name'] for test in
401 before_result if 'passed' not in test['outcome']]
402 # STEP #5
403
404 sl_deployed.stop_sl_service_on_node('mon01', 'influxdb-relay')
405 sl_deployed.stop_sl_service_on_node('mon02', 'influxdb-relay')
406 # STEP #6
407
408 sl_deployed.post_data_into_influx('mon03')
409 # STEP #7
410
411 assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon03')
412 # STEP #8
413
414 sl_deployed.start_service('mon01', 'influxdb-relay')
415 sl_deployed.start_service('mon02', 'influxdb-relay')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300416
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200417 # STEP #9
Dennis Dmitriev28fd0492017-11-29 13:33:21 +0200418 assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon01')
419 assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon02')
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200420
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300421 # STEP #10
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300422 after_result = sl_deployed.run_sl_tests_json(
423 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
424 'tests/prometheus/', 'test_alerts.py')
425 for test in after_result:
426 if test['name'] not in failed_tests:
427 assert 'passed' in test['outcome'], \
428 'Failed test {}'.format(test)
429 LOG.info("*************** DONE **************")
430
431 @pytest.mark.grab_versions
432 @pytest.mark.fail_snapshot
433 def test_stop_influxdb_mon_nodes(self, underlay,
Dennis Dmitriev9b02c8b2017-11-13 15:31:35 +0200434 openstack_deployed,
435 openstack_actions,
436 sl_deployed):
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300437 """Test stop influxdb on mon01 node
438
439 Scenario:
440 1. Prepare salt on hosts
441 2. Setup controller nodes
442 3. Setup compute, monitoring nodes
443 4. Check LMA before mon node shutdown
444 5. Stop influxdb on mon01 and mon02 node
445 6. Post data into influx
446 7. Get data from all healthy nodes
447 8. Start influx db
448 9. Request data on mon01
449 10. Run LMA tests after fail and compare with result before fail
450
451
452 """
453 # STEP #1,2,3
454 mon_nodes = sl_deployed.get_monitoring_nodes()
455 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
456 before_result = sl_deployed.run_sl_tests_json(
457 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
458 'tests/prometheus/', 'test_alerts.py')
459 failed_tests = [test['name'] for test in
460 before_result if 'passed' not in test['outcome']]
461 # STEP #5
462
463 sl_deployed.stop_sl_service_on_node('mon01', 'influxdb')
464 sl_deployed.stop_sl_service_on_node('mon02', 'influxdb')
465 # STEP #6
466
467 sl_deployed.post_data_into_influx('mon03')
468 # STEP #7
469
470 assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon03')
471 # STEP #8
472
473 sl_deployed.start_service('mon01', 'influxdb')
474 sl_deployed.start_service('mon02', 'influxdb')
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300475
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200476 # STEP #9
Dennis Dmitriev28fd0492017-11-29 13:33:21 +0200477 self.check_influxdb_xfail(sl_deployed, 'mon01', 'mymeas')
478 self.check_influxdb_xfail(sl_deployed, 'mon02', 'mymeas')
Dennis Dmitriev8ce85152017-11-29 00:05:12 +0200479
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300480 # STEP #10
Tatyana Leontovicha6c64a72017-10-25 22:21:18 +0300481 after_result = sl_deployed.run_sl_tests_json(
482 'cfg01', '/root/stacklight-pytest/stacklight_tests/',
483 'tests/prometheus/', 'test_alerts.py')
484 for test in after_result:
485 if test['name'] not in failed_tests:
486 assert 'passed' in test['outcome'], \
487 'Failed test {}'.format(test)
Tatyana Leontoviche5ccdb32017-10-09 20:10:43 +0300488 LOG.info("*************** DONE **************")