From 4c77ef70f01ce40574de97fd21a854fe485329a5 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Thu, 11 Jun 2020 12:17:53 +0200 Subject: [PATCH] qa/cephadm: Add test for --format=yaml Signed-off-by: Sebastian Wagner (cherry picked from commit 1650257015b9470918f50478a6151f2f40467dd3) --- .../cephadm/workunits/task/test_orch_cli.yaml | 1 + qa/tasks/cephadm_cases/__init__.py | 0 qa/tasks/cephadm_cases/test_cli.py | 37 +++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 qa/tasks/cephadm_cases/__init__.py create mode 100644 qa/tasks/cephadm_cases/test_cli.py diff --git a/qa/suites/rados/cephadm/workunits/task/test_orch_cli.yaml b/qa/suites/rados/cephadm/workunits/task/test_orch_cli.yaml index d57b3e47aa2d3..abf511946330c 100644 --- a/qa/suites/rados/cephadm/workunits/task/test_orch_cli.yaml +++ b/qa/suites/rados/cephadm/workunits/task/test_orch_cli.yaml @@ -15,3 +15,4 @@ tasks: - cephfs_test_runner: modules: - tasks.cephfs.test_nfs + - tasks.cephadm_cases.test_cli diff --git a/qa/tasks/cephadm_cases/__init__.py b/qa/tasks/cephadm_cases/__init__.py new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/qa/tasks/cephadm_cases/test_cli.py b/qa/tasks/cephadm_cases/test_cli.py new file mode 100644 index 0000000000000..a953efc7b8846 --- /dev/null +++ b/qa/tasks/cephadm_cases/test_cli.py @@ -0,0 +1,37 @@ +import logging + +from tasks.mgr.mgr_test_case import MgrTestCase + +log = logging.getLogger(__name__) + + +class TestCephadmCLI(MgrTestCase): + def _cmd(self, *args): + return self.mgr_cluster.mon_manager.raw_cluster_cmd(*args) + + def _orch_cmd(self, *args): + 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) + -- 2.39.5