]> git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/cephadm_cases/test_cli.py
c05395673c878222aa9b438b5f550325b7d9f671
[ceph.git] / ceph / qa / tasks / cephadm_cases / test_cli.py
1 import json
2 import logging
3 import time
4
5 from tasks.mgr.mgr_test_case import MgrTestCase
6 from teuthology.contextutil import safe_while
7
8 log = logging.getLogger(__name__)
9
10
11 class TestCephadmCLI(MgrTestCase):
12 def _cmd(self, *args) -> str:
13 assert self.mgr_cluster is not None
14 return self.mgr_cluster.mon_manager.raw_cluster_cmd(*args)
15
16 def _orch_cmd(self, *args) -> str:
17 return self._cmd("orch", *args)
18
19 def setUp(self):
20 super(TestCephadmCLI, self).setUp()
21
22 def test_yaml(self):
23 """
24 to prevent oddities like
25
26 >>> import yaml
27 ... from collections import OrderedDict
28 ... assert yaml.dump(OrderedDict()) == '!!python/object/apply:collections.OrderedDict\\n- []\\n'
29 """
30 out = self._orch_cmd('device', 'ls', '--format', 'yaml')
31 self.assertNotIn('!!python', out)
32
33 out = self._orch_cmd('host', 'ls', '--format', 'yaml')
34 self.assertNotIn('!!python', out)
35
36 out = self._orch_cmd('ls', '--format', 'yaml')
37 self.assertNotIn('!!python', out)
38
39 out = self._orch_cmd('ps', '--format', 'yaml')
40 self.assertNotIn('!!python', out)
41
42 out = self._orch_cmd('status', '--format', 'yaml')
43 self.assertNotIn('!!python', out)
44
45 def test_pause(self):
46 self._orch_cmd('pause')
47 self.wait_for_health('CEPHADM_PAUSED', 30)
48 self._orch_cmd('resume')
49 self.wait_for_health_clear(30)
50
51 def test_daemon_restart(self):
52 self._orch_cmd('daemon', 'stop', 'osd.0')
53 self.wait_for_health('OSD_DOWN', 30)
54 with safe_while(sleep=1, tries=30) as proceed:
55 while proceed():
56 j = json.loads(self._orch_cmd('ps', '--format', 'json'))
57 d = {d['daemon_name']: d for d in j}
58 if d['osd.0']['status_desc'] != 'running':
59 break
60 time.sleep(5)
61 self._orch_cmd('daemon', 'start', 'osd.0')
62 self.wait_for_health_clear(90)
63 self._orch_cmd('daemon', 'restart', 'osd.0')
64
65 def test_device_ls_wide(self):
66 self._orch_cmd('device', 'ls', '--wide')
67
68 def test_cephfs_mirror(self):
69 self._orch_cmd('apply', 'cephfs-mirror')
70 self.wait_until_true(lambda: 'cephfs-mirror' in self._orch_cmd('ps'), 30)
71 self.wait_for_health_clear(30)
72 self._orch_cmd('rm', 'cephfs-mirror')
73 self.wait_until_true(lambda: 'cephfs-mirror' not in self._orch_cmd('ps'), 30)