]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/crimson: add pg subcommands workunit
authorKautilya Tripathi <kautilya.tripathi@ibm.com>
Wed, 8 Apr 2026 05:01:59 +0000 (10:31 +0530)
committerKautilya Tripathi <kautilya.tripathi@ibm.com>
Mon, 27 Apr 2026 04:14:50 +0000 (09:44 +0530)
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 <kautilya.tripathi@ibm.com>
qa/suites/crimson-rados/singleton/all/pg-subcommands.yaml
qa/workunits/crimson/test_pg_subcommands.sh [new file with mode: 0755]

index 320f261c0f7dcd30a5e35a2d4d6dafbe02f122d0..877762782d8e2fd9dbc1cd6072d5095bf22c0277 100644 (file)
@@ -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 (executable)
index 0000000..67c0921
--- /dev/null
@@ -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"