From: Kautilya Tripathi Date: Wed, 8 Apr 2026 05:01:59 +0000 (+0530) Subject: qa/crimson: add pg subcommands workunit X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=967b9711245f46e67f49fc6d4e1e213b635be039;p=ceph.git qa/crimson: add pg subcommands workunit Add a crimson workunit that validates pg query and list_unfound including offset behavior, and wire it into the singleton suite. Signed-off-by: Kautilya Tripathi --- diff --git a/qa/suites/crimson-rados/singleton/all/pg-subcommands.yaml b/qa/suites/crimson-rados/singleton/all/pg-subcommands.yaml index 320f261c0f7d..877762782d8e 100644 --- a/qa/suites/crimson-rados/singleton/all/pg-subcommands.yaml +++ b/qa/suites/crimson-rados/singleton/all/pg-subcommands.yaml @@ -28,7 +28,4 @@ tasks: - workunit: clients: client.0: - - osd/pg-subcommands.sh - basedir: qa/standalone - env: - PG_SUBCOMMANDS_FUNCS: "TEST_b_crimson_save_and_compare" + - crimson/test_pg_subcommands.sh diff --git a/qa/workunits/crimson/test_pg_subcommands.sh b/qa/workunits/crimson/test_pg_subcommands.sh new file mode 100755 index 000000000000..67c092125739 --- /dev/null +++ b/qa/workunits/crimson/test_pg_subcommands.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +. $(dirname $0)/../../standalone/ceph-helpers.sh + +set -x + +_cmp_json_field() { + local a=$1 + local b=$2 + local field=$3 + local name=$4 + local av + local bv + av=$(echo "$a" | jq -c "$field") || return 1 + bv=$(echo "$b" | jq -c "$field") || return 1 + if [ "$av" != "$bv" ]; then + echo "Mismatch for $name at $field: base=$av vs offset=$bv" + return 1 + fi +} + +_run_pg_json() { + local pgid=$1 + local subcmd=$2 + local offset_json=$3 + if [ -n "$offset_json" ]; then + ceph --format json pg "$pgid" "$subcmd" "$offset_json" | awk 'BEGIN{p=0} /^[[:space:]]*[\[{]/{p=1} p{print}' + else + ceph --format json pg "$pgid" "$subcmd" | awk 'BEGIN{p=0} /^[[:space:]]*[\[{]/{p=1} p{print}' + fi +} + +_wait_for_pg_query_ok() { + local pgid=$1 + local timeout=${2:-60} + local deadline=$(( $(date +%s) + timeout )) + + while [ $(date +%s) -lt $deadline ]; do + local q + q=$(_run_pg_json "$pgid" query 2>/dev/null || true) + if [ -n "$q" ]; then + echo "$q" | jq -e . >/dev/null 2>&1 && return 0 + fi + sleep 1 + done + + echo "Timed out waiting for pg $pgid query to succeed" + ceph -s || true + return 1 +} + +_get_any_pgid() { + ceph pg dump pgs_brief --format json | jq -r '.pg_stats[0].pgid' +} + +test_pg_subcommands() { + [ "$(ceph osd metadata 0 | jq -r '.osd_type')" = "crimson" ] || return 0 + + local pgid + pgid=$(_get_any_pgid) || return 1 + [ -n "$pgid" ] || return 1 + + _wait_for_pg_query_ok "$pgid" 120 || return 1 + + local qjson + qjson=$(_run_pg_json "$pgid" query) || return 1 + echo "$qjson" | jq -e . >/dev/null || return 1 + + local ujson ujson_offset + ujson=$(_run_pg_json "$pgid" list_unfound) || return 1 + echo "$ujson" | jq -e . >/dev/null || return 1 + + ujson_offset=$(_run_pg_json "$pgid" list_unfound '{}') || return 1 + echo "$ujson_offset" | jq -e . >/dev/null || return 1 + + _cmp_json_field "$ujson" "$ujson_offset" '(.missing.num_missing // .num_missing // 0)' "list_unfound.num_missing" || return 1 + _cmp_json_field "$ujson" "$ujson_offset" '(.missing.num_unfound // .num_unfound // 0)' "list_unfound.num_unfound" || return 1 +} + +test_pg_subcommands || { echo "test_pg_subcommands failed"; exit 1; } + +echo "OK"