2021-11-25 14:10:28 +00:00
|
|
|
import json
|
2020-06-11 10:17:53 +00:00
|
|
|
import logging
|
2021-11-25 14:10:28 +00:00
|
|
|
import time
|
2020-06-11 10:17:53 +00:00
|
|
|
|
|
|
|
from tasks.mgr.mgr_test_case import MgrTestCase
|
2021-11-25 14:10:28 +00:00
|
|
|
from teuthology.contextutil import safe_while
|
2020-06-11 10:17:53 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class TestCephadmCLI(MgrTestCase):
|
2021-02-23 15:05:22 +00:00
|
|
|
def _cmd(self, *args) -> str:
|
|
|
|
assert self.mgr_cluster is not None
|
2020-06-11 10:17:53 +00:00
|
|
|
return self.mgr_cluster.mon_manager.raw_cluster_cmd(*args)
|
|
|
|
|
2021-02-23 15:05:22 +00:00
|
|
|
def _orch_cmd(self, *args) -> str:
|
2020-06-11 10:17:53 +00:00
|
|
|
return self._cmd("orch", *args)
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(TestCephadmCLI, self).setUp()
|
|
|
|
|
|
|
|
def test_yaml(self):
|
|
|
|
"""
|
|
|
|
to prevent oddities like
|
|
|
|
|
|
|
|
>>> import yaml
|
|
|
|
... from collections import OrderedDict
|
|
|
|
... assert yaml.dump(OrderedDict()) == '!!python/object/apply:collections.OrderedDict\\n- []\\n'
|
|
|
|
"""
|
|
|
|
out = self._orch_cmd('device', 'ls', '--format', 'yaml')
|
|
|
|
self.assertNotIn('!!python', out)
|
|
|
|
|
|
|
|
out = self._orch_cmd('host', 'ls', '--format', 'yaml')
|
|
|
|
self.assertNotIn('!!python', out)
|
|
|
|
|
|
|
|
out = self._orch_cmd('ls', '--format', 'yaml')
|
|
|
|
self.assertNotIn('!!python', out)
|
|
|
|
|
|
|
|
out = self._orch_cmd('ps', '--format', 'yaml')
|
|
|
|
self.assertNotIn('!!python', out)
|
|
|
|
|
2020-06-26 17:44:45 +00:00
|
|
|
out = self._orch_cmd('status', '--format', 'yaml')
|
|
|
|
self.assertNotIn('!!python', out)
|
2020-06-30 13:13:51 +00:00
|
|
|
|
|
|
|
def test_pause(self):
|
|
|
|
self._orch_cmd('pause')
|
2022-02-10 01:42:42 +00:00
|
|
|
self.wait_for_health('CEPHADM_PAUSED', 60)
|
2020-06-30 13:13:51 +00:00
|
|
|
self._orch_cmd('resume')
|
2022-02-10 01:42:42 +00:00
|
|
|
self.wait_for_health_clear(60)
|
2020-07-29 21:02:04 +00:00
|
|
|
|
|
|
|
def test_daemon_restart(self):
|
|
|
|
self._orch_cmd('daemon', 'stop', 'osd.0')
|
2022-02-10 01:42:42 +00:00
|
|
|
self.wait_for_health('OSD_DOWN', 60)
|
|
|
|
with safe_while(sleep=2, tries=30) as proceed:
|
2021-11-25 14:10:28 +00:00
|
|
|
while proceed():
|
|
|
|
j = json.loads(self._orch_cmd('ps', '--format', 'json'))
|
|
|
|
d = {d['daemon_name']: d for d in j}
|
|
|
|
if d['osd.0']['status_desc'] != 'running':
|
|
|
|
break
|
|
|
|
time.sleep(5)
|
2020-07-29 21:02:04 +00:00
|
|
|
self._orch_cmd('daemon', 'start', 'osd.0')
|
2022-02-10 01:42:42 +00:00
|
|
|
self.wait_for_health_clear(120)
|
2020-07-29 21:02:04 +00:00
|
|
|
self._orch_cmd('daemon', 'restart', 'osd.0')
|
2020-09-03 02:53:22 +00:00
|
|
|
|
|
|
|
def test_device_ls_wide(self):
|
|
|
|
self._orch_cmd('device', 'ls', '--wide')
|
2021-02-23 15:05:47 +00:00
|
|
|
|
|
|
|
def test_cephfs_mirror(self):
|
|
|
|
self._orch_cmd('apply', 'cephfs-mirror')
|
2022-02-10 01:42:42 +00:00
|
|
|
self.wait_until_true(lambda: 'cephfs-mirror' in self._orch_cmd('ps'), 60)
|
|
|
|
self.wait_for_health_clear(60)
|
2021-02-23 15:05:47 +00:00
|
|
|
self._orch_cmd('rm', 'cephfs-mirror')
|
2022-02-10 01:42:42 +00:00
|
|
|
self.wait_until_true(lambda: 'cephfs-mirror' not in self._orch_cmd('ps'), 60)
|