]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Fix flaky QA tests
authorPatrick Nawracay <pnawracay@suse.com>
Tue, 11 Sep 2018 06:53:56 +0000 (08:53 +0200)
committerPatrick Nawracay <pnawracay@suse.com>
Wed, 12 Sep 2018 08:16:54 +0000 (10:16 +0200)
Signed-off-by: Patrick Nawracay <pnawracay@suse.com>
qa/tasks/mgr/dashboard/test_osd.py
src/pybind/mgr/dashboard/controllers/osd.py

index 6e22399a9821f01896fe1b4c2fee95686a5ed1cc..73b7da2463e5397cf42ed9868bfb5b16b3097a89 100644 (file)
@@ -99,13 +99,17 @@ class OsdTest(DashboardTestCase):
         self.assertStatus(200)
 
     def test_safe_to_destroy(self):
-        self._get('/api/osd/5/safe_to_destroy')
+        osd_dump = json.loads(self._ceph_cmd(['osd', 'dump', '-f', 'json']))
+        unused_osd_id = max(map(lambda e: e['osd'], osd_dump['osds'])) + 10
+        self._get('/api/osd/{}/safe_to_destroy'.format(unused_osd_id))
         self.assertStatus(200)
         self.assertJsonBody({'safe-to-destroy': True})
 
         def get_destroy_status():
             self._get('/api/osd/0/safe_to_destroy')
-            return self.jsonBody()['safe-to-destroy']
+            if 'safe-to-destroy' in self.jsonBody():
+                return self.jsonBody()['safe-to-destroy']
+            return None
         self.wait_until_equal(get_destroy_status, False, 10)
         self.assertStatus(200)
 
index 33f1b222ce0839454f76700d92d7b9411f6c256d..068d8da78050b45e15dd57d8223a618c7d51b3e6 100644 (file)
@@ -1,6 +1,5 @@
 # -*- coding: utf-8 -*-
 from __future__ import absolute_import
-import re
 from . import ApiController, RESTController, UpdatePermission
 from .. import mgr, logger
 from ..security import Scope
@@ -154,16 +153,10 @@ class Osd(RESTController):
                 'mon', 'osd safe-to-destroy', ids=svc_id, target=('mgr', ''))
             return {'safe-to-destroy': True}
         except SendCommandError as e:
-            match = re.match(
-                r'OSD\(s\) (\d+) have (\d+) pgs currently mapped to them',
-                e.message)
-            if match:
-                return {
-                    'message': e.message,
-                    'safe-to-destroy': False
-                }
-            else:
-                raise e
+            return {
+                'message': e.message,
+                'safe-to-destroy': False,
+            }
 
 
 @ApiController('/osd/flags', Scope.OSD)