From: Adam King Date: Thu, 25 Aug 2022 16:09:49 +0000 (-0400) Subject: mgr/orchestrator/tests: don't match exact whitespace in table output X-Git-Tag: v18.0.0~166^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F47811%2Fhead;p=ceph.git mgr/orchestrator/tests: don't match exact whitespace in table output It seems that the exact spacing may differ a bit between python versions. Currently seeing py3 (which cooresponds to py 3.6 on my system) passing these tests and py37 (which is python 3.7 obviously) failing. I think verifying against the exact whitespace is unnecessary anyhow. As long as it isn't egregious, we don't really need to worry about exactly what the spacing is. Signed-off-by: Adam King --- diff --git a/src/pybind/mgr/orchestrator/tests/test_orchestrator.py b/src/pybind/mgr/orchestrator/tests/test_orchestrator.py index c6b41251005c..726a7ac7937c 100644 --- a/src/pybind/mgr/orchestrator/tests/test_orchestrator.py +++ b/src/pybind/mgr/orchestrator/tests/test_orchestrator.py @@ -191,11 +191,15 @@ def test_orch_ps(_describe_service): } m = OrchestratorCli('orchestrator', 0, 0) r = m._handle_command(None, cmd) - out = 'NAME HOST PORTS STATUS REFRESHED AGE MEM USE MEM LIM VERSION IMAGE ID \n'\ - 'osd.1 unknown - - - - \n'\ - 'osd.2 unknown - - - - \n'\ - 'osd.10 unknown - - - - ' - assert r == HandleCommandResult(retval=0, stdout=out, stderr='') + expected_out = 'NAME HOST PORTS STATUS REFRESHED AGE MEM USE MEM LIM VERSION IMAGE ID \n'\ + 'osd.1 unknown - - - - \n'\ + 'osd.2 unknown - - - - \n'\ + 'osd.10 unknown - - - - ' + expected_out = [c for c in expected_out if c.isalpha()] + actual_out = [c for c in r.stdout if c.isalpha()] + assert r.retval == 0 + assert expected_out == actual_out + assert r.stderr == '' hlist = OrchResult([HostSpec("ceph-node-1"), HostSpec("ceph-node-2"), HostSpec("ceph-node-10")]) @@ -210,12 +214,16 @@ def test_orch_host_ls(_describe_service): } m = OrchestratorCli('orchestrator', 0, 0) r = m._handle_command(None, cmd) - out = 'HOST ADDR LABELS STATUS \n'\ - 'ceph-node-1 ceph-node-1 \n'\ - 'ceph-node-2 ceph-node-2 \n'\ - 'ceph-node-10 ceph-node-10 \n'\ - '3 hosts in cluster' - assert r == HandleCommandResult(retval=0, stdout=out, stderr='') + expected_out = 'HOST ADDR LABELS STATUS \n'\ + 'ceph-node-1 ceph-node-1 \n'\ + 'ceph-node-2 ceph-node-2 \n'\ + 'ceph-node-10 ceph-node-10 \n'\ + '3 hosts in cluster' + expected_out = [c for c in expected_out if c.isalpha()] + actual_out = [c for c in r.stdout if c.isalpha()] + assert r.retval == 0 + assert expected_out == actual_out + assert r.stderr == '' def test_orch_device_ls(): @@ -230,11 +238,15 @@ def test_orch_device_ls(): } m = OrchestratorCli('orchestrator', 0, 0) r = m._handle_command(None, cmd) - out = 'HOST PATH TYPE DEVICE ID SIZE AVAILABLE REFRESHED REJECT REASONS \n'\ - 'ceph-node-1 /dev/vdb unknown None 0 Yes 0s ago \n'\ - 'ceph-node-2 /dev/vdb unknown None 0 Yes 0s ago \n'\ - 'ceph-node-10 /dev/vdb unknown None 0 Yes 0s ago ' - assert r == HandleCommandResult(retval=0, stdout=out, stderr='') + expected_out = 'HOST PATH TYPE DEVICE ID SIZE AVAILABLE REFRESHED REJECT REASONS \n'\ + 'ceph-node-1 /dev/vdb unknown None 0 Yes 0s ago \n'\ + 'ceph-node-2 /dev/vdb unknown None 0 Yes 0s ago \n'\ + 'ceph-node-10 /dev/vdb unknown None 0 Yes 0s ago ' + expected_out = [c for c in expected_out if c.isalpha()] + actual_out = [c for c in r.stdout if c.isalpha()] + assert r.retval == 0 + assert expected_out == actual_out + assert r.stderr == '' def test_preview_table_osd_smoke():