blob: 934e28b068f4f4011e3a244934abf1c2560d0f62 [file] [log] [blame]
Tatyana Leontovichc72604d2018-01-04 17:58:00 +02001# 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.
14import pytest
15
16from tcp_tests import logger
17
18LOG = logger.logger
19
20
21class TestFailoverCeph(object):
22 """Test class for testing MCP ceph failover"""
23
24 def get_ceph_health(self, underlay, node_names):
25 """Get ceph health on the specified nodes
26
27 Returns the dict {<node_name>: <str>, }
28 where <str> is the 'ceph -s' output
29 """
30 res = {
31 node_name: underlay.check_call("ceph -s",
32 node_name=node_name,
33 raise_on_err=False)['stdout_str']
34 for node_name in node_names
35 }
36 return res
37
38 def show_failed_msg(self, failed):
39 return "There are failed tempest tests:\n\n {0}".format(
40 '\n\n '.join([(name + ': ' + detail)
41 for name, detail in failed.items()]))
42
43 @pytest.mark.grab_versions
44 @pytest.mark.fail_snapshot
45 def test_restart_osd_node(self, func_name, underlay, config,
46 openstack_deployed, ceph_deployed,
Vladimir Jigulinee1faa52018-06-25 13:00:51 +040047 openstack_actions, hardware,
Tatyana Leontovichc72604d2018-01-04 17:58:00 +020048 rally, show_step):
49 """Test restart ceph osd node
50
51 Scenario:
52 1. Find ceph osd nodes
53 2. Check ceph health before restart
54 3. Restart 1 ceph osd node
55 4. Check ceph health after restart
56 5. Run tempest smoke after failover
57 6. Check tempest report for failed tests
58
59 Requiremets:
60 - Salt cluster
61 - OpenStack cluster
62 - Ceph cluster
63 """
64 openstack_actions._salt.local(
65 tgt='*', fun='cmd.run',
66 args='service ntp stop; ntpd -gq; service ntp start')
67 # STEP #1
68 show_step(1)
69 osd_node_names = underlay.get_target_node_names(
70 target='osd')
71
72 # STEP #2
73 show_step(2)
74 # Get the ceph health output before restart
75 health_before = self.get_ceph_health(underlay, osd_node_names)
76 assert all(["OK" in p for n, p in health_before.items()]), (
77 "'Ceph health is not ok from node: {0}".format(health_before))
78
79 # STEP #3
80 show_step(3)
Vladimir Jigulinee1faa52018-06-25 13:00:51 +040081 hardware.warm_restart_nodes(underlay, 'osd01')
Tatyana Leontovichc72604d2018-01-04 17:58:00 +020082
83 openstack_actions._salt.local(
84 tgt='*', fun='cmd.run',
85 args='service ntp stop; ntpd -gq; service ntp start')
86
87 # STEP #4
88 show_step(4)
89 # Get the ceph health output after restart
90 health_after = self.get_ceph_health(underlay, osd_node_names)
91 assert all(["OK" in p for n, p in health_before.items()]), (
92 "'Ceph health is not ok from node: {0}".format(health_after))
93
94 rally.run_container()
95
96 # STEP #5
97 show_step(5)
98 results = rally.run_tempest(pattern='set=smoke',
99 conf_name='/var/lib/ceph_mcp.conf',
100 report_prefix=func_name,
101 designate_plugin=False,
102 timeout=1800)
103 # Step #6
104 show_step(6)
105 assert not results['fail'], self.show_failed_msg(results['fail'])
106
107 LOG.info("*************** DONE **************")
108
109 @pytest.mark.grab_versions
110 @pytest.mark.fail_snapshot
111 def test_restart_cmn_node(self, func_name, underlay, config,
112 openstack_deployed, ceph_deployed,
Dennis Dmitrievea48cf52018-07-18 18:04:39 +0300113 core_actions,
Tatyana Leontovichc72604d2018-01-04 17:58:00 +0200114 salt_actions, openstack_actions,
Vladimir Jigulinee1faa52018-06-25 13:00:51 +0400115 rally, show_step, hardware):
Tatyana Leontovichc72604d2018-01-04 17:58:00 +0200116 """Test restart ceph cmn node
117
118 Scenario:
119 1. Find ceph cmn nodes
120 2. Check ceph health before restart
121 3. Restart 1 ceph cmn node
122 4. Check ceph health after restart
123 5. Run tempest smoke after failover
124 6. Check tempest report for failed tests
125
126 Requiremets:
127 - Salt cluster
128 - OpenStack cluster
129 - Ceph cluster
130 """
131 openstack_actions._salt.local(
132 tgt='*', fun='cmd.run',
133 args='service ntp stop; ntpd -gq; service ntp start')
134 # STEP #1
135 show_step(1)
136 cmn_node_names = underlay.get_target_node_names(
137 target='cmn')
138
139 # STEP #2
140 show_step(2)
141 # Get the ceph health output before restart
142 health_before = self.get_ceph_health(underlay, cmn_node_names)
143 assert all(["OK" in p for n, p in health_before.items()]), (
144 "'Ceph health is not ok from node: {0}".format(health_before))
145
146 # STEP #3
147 show_step(3)
Vladimir Jigulinee1faa52018-06-25 13:00:51 +0400148 hardware.warm_restart_nodes(underlay, 'cmn01')
Tatyana Leontovichc72604d2018-01-04 17:58:00 +0200149
150 openstack_actions._salt.local(
151 tgt='*', fun='cmd.run',
152 args='service ntp stop; ntpd -gq; service ntp start')
153
154 # STEP #4
155 show_step(4)
156 # Get the ceph health output after restart
157 health_after = self.get_ceph_health(underlay, cmn_node_names)
158 assert all(["OK" in p for n, p in health_before.items()]), (
159 "'Ceph health is not ok from node: {0}".format(health_after))
160
161 rally.run_container()
162
163 # STEP #5
164 show_step(5)
165 results = rally.run_tempest(pattern='set=smoke',
166 conf_name='/var/lib/ceph_mcp.conf',
167 report_prefix=func_name,
168 designate_plugin=False,
169 timeout=1800)
170 # Step #6
171 show_step(6)
172 assert not results['fail'], self.show_failed_msg(results['fail'])
173
174 LOG.info("*************** DONE **************")
175
176 @pytest.mark.grab_versions
177 @pytest.mark.fail_snapshot
178 def test_restart_rgw_node(self, func_name, underlay, config,
179 openstack_deployed, ceph_deployed,
Dennis Dmitrievea48cf52018-07-18 18:04:39 +0300180 core_actions, hardware,
Tatyana Leontovichc72604d2018-01-04 17:58:00 +0200181 salt_actions, openstack_actions,
182 rally, show_step):
183 """Test restart ceph rgw node
184
185 Scenario:
186 1. Find ceph rgw nodes
187 2. Check ceph health before restart
188 3. Restart 1 ceph rgw node
189 4. Check ceph health after restart
190 5. Run tempest smoke after failover
191 6. Check tempest report for failed tests
192
193 Requiremets:
194 - Salt cluster
195 - OpenStack cluster
196 - Ceph cluster
197 """
198 openstack_actions._salt.local(
199 tgt='*', fun='cmd.run',
200 args='service ntp stop; ntpd -gq; service ntp start')
201
202 # STEP #1
203 show_step(1)
204 rgw_node_names = underlay.get_target_node_names(
205 target='rgw')
206 if not rgw_node_names:
207 pytest.skip('Skip as there are not rgw nodes in deploy')
208
209 # STEP #2
210 show_step(2)
211 # Get the ceph health output before restart
212 health_before = self.get_ceph_health(underlay, rgw_node_names)
213 assert all(["OK" in p for n, p in health_before.items()]), (
214 "'Ceph health is not ok from node: {0}".format(health_before))
215
216 # STEP #3
217 show_step(3)
Vladimir Jigulinee1faa52018-06-25 13:00:51 +0400218 hardware.warm_restart_nodes(underlay, 'rgw01')
Tatyana Leontovichc72604d2018-01-04 17:58:00 +0200219
220 openstack_actions._salt.local(
221 tgt='*', fun='cmd.run',
222 args='service ntp stop; ntpd -gq; service ntp start')
223
224 # STEP #4
225 show_step(4)
226 # Get the ceph health output after restart
227 health_after = self.get_ceph_health(underlay, rgw_node_names)
228 assert all(["OK" in p for n, p in health_before.items()]), (
229 "'Ceph health is not ok from node: {0}".format(health_after))
230
231 rally.run_container()
232
233 # STEP #5
234 show_step(5)
235 results = rally.run_tempest(pattern='set=smoke',
236 conf_name='/var/lib/ceph_mcp.conf',
237 designate_plugin=False,
238 report_prefix=func_name,
239 timeout=1800)
240 # Step #6
241 show_step(6)
242 assert not results['fail'], self.show_failed_msg(results['fail'])
243
244 LOG.info("*************** DONE **************")