From: Patrick Donnelly Date: Wed, 8 May 2024 15:19:07 +0000 (-0400) Subject: qa/workunits: add --output-file test in cephtool workunit X-Git-Tag: v19.2.3~303^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0aebb5d3c3ac88f35067ee941d2933dbd4a57c70;p=ceph.git qa/workunits: add --output-file test in cephtool workunit Signed-off-by: Patrick Donnelly (cherry picked from commit 2d26694f64387339c06056cbb975016a0d56c769) --- diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index ed652b9f74bf2..c45819011b24d 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -855,6 +855,47 @@ function without_test_dup_command() fi } +function test_tell_output_file() +{ + name="$1" + shift + + # Test --daemon-output-file + # N.B.: note this only works if $name is on the same node as this script! + J=$(ceph tell --format=json --daemon-output-file=/tmp/foo "$name" version) + expect_true jq -e '.path == "/tmp/foo"' <<<"$J" + expect_true test -e /tmp/foo + # only one line of json + expect_true sed '2q1' < /tmp/foo > /dev/null + expect_true jq -e '.version | length > 0' < /tmp/foo + rm -f /tmp/foo + + J=$(ceph tell --format=json-pretty --daemon-output-file=/tmp/foo "$name" version) + expect_true jq -e '.path == "/tmp/foo"' <<<"$J" + expect_true test -e /tmp/foo + # more than one line of json + expect_false sed '2q1' < /tmp/foo > /dev/null + expect_true jq -e '.version | length > 0' < /tmp/foo + rm -f /tmp/foo + + # Test --daemon-output-file=:tmp: + J=$(ceph tell --format=json --daemon-output-file=":tmp:" "$name" version) + path=$(jq -r .path <<<"$J") + expect_true test -e "$path" + # only one line of json + expect_true sed '2q1' < "$path" > /dev/null + expect_true jq -e '.version | length > 0' < "$path" + rm -f "$path" + + J=$(ceph tell --format=json-pretty --daemon-output-file=":tmp:" "$name" version) + path=$(jq -r .path <<<"$J") + expect_true test -e "$path" + # only one line of json + expect_false sed '2q1' < "$path" > /dev/null + expect_true jq -e '.version | length > 0' < "$path" + rm -f "$path" +} + function test_mds_tell() { local FS_NAME=cephfs @@ -896,6 +937,8 @@ function test_mds_tell() done echo New GIDs: $new_mds_gids + test_tell_output_file mds."$FS_NAME":0 + remove_all_fs ceph osd pool delete fs_data fs_data --yes-i-really-really-mean-it ceph osd pool delete fs_metadata fs_metadata --yes-i-really-really-mean-it @@ -2633,6 +2676,8 @@ function test_mon_tell() ceph_watch_wait "${m} \[DBG\] from.*cmd='sessions' args=\[\]: dispatch" done expect_false ceph tell mon.foo version + + test_tell_output_file mon.0 } function test_mon_ping()