]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
src/test: update show-choose-tries.t tests 68662/head
authorKamoltat (Junior) Sirivadhna <ksirivad@redhat.com>
Wed, 29 Apr 2026 14:11:41 +0000 (14:11 +0000)
committerKamoltat (Junior) Sirivadhna <ksirivad@redhat.com>
Wed, 29 Apr 2026 18:38:06 +0000 (18:38 +0000)
Since we modified crushtool cli commands, we need to also update
its test with new flag: --show-retry-exhaustion
and also the modified --show-choose-tries option

Also added /src/script/run-cli-tests.sh to run the cram test
easily without having the config headache

Signed-off-by: Kamoltat (Junior) Sirivadhna <ksirivad@redhat.com>
doc/dev/developer_guide/tests-unit-tests.rst
src/script/run-cli-tests.sh [new file with mode: 0755]
src/test/cli/crushtool/help.t
src/test/cli/crushtool/show-choose-tries.t

index e6026dd3c63e2da4e04fe717242d2936b6350c0b..0ee137792344c085424557c0c027c2ead9b68766 100644 (file)
@@ -71,6 +71,31 @@ teuthology using the `cram task`_.
 .. _`cram`: https://bitheap.org/cram/
 .. _`cram task`: https://github.com/ceph/ceph/blob/master/qa/tasks/cram.py
 
+Running CLI tools tests
+-----------------------
+
+A convenience script is provided to run CLI tests easily without having to manually set up the environment.
+From the Ceph source tree root directory:
+
+  .. prompt:: bash $
+
+     # Run all CLI tests
+     ./src/script/run-cli-tests.sh
+
+     # Run with custom build directory
+     ./src/script/run-cli-tests.sh -b /path/to/build
+
+Alternatively, you can run the tests directly from the build directory by setting up your PATH:
+
+  .. prompt:: bash $
+
+     cd build
+     PATH="$PWD/bin:$PATH" ../src/test/run-cli-tests
+
+The test suite includes tests for: ``ceph-authtool``, ``ceph-conf``, 
+``ceph-kvstore-tool``, ``crushtool``, ``monmaptool``, ``osdmaptool``, 
+``radosgw-admin``, and ``rbd``.
+
 Tox-based testing of Python modules
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 Some of the Python modules in Ceph use `tox <https://tox.readthedocs.io/en/latest/>`_ 
diff --git a/src/script/run-cli-tests.sh b/src/script/run-cli-tests.sh
new file mode 100755 (executable)
index 0000000..1e6c852
--- /dev/null
@@ -0,0 +1,67 @@
+#!/usr/bin/env bash
+
+set -e
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+CEPH_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
+BUILD_DIR="${BUILD_DIR:-$CEPH_ROOT/build}"
+
+usage() {
+    cat <<EOF
+Usage: $0 [OPTIONS]
+
+Run CLI tests for Ceph tools using the cram testing framework.
+
+Options:
+    -h, --help      Show this help message
+    -b, --build     Specify build directory (default: $CEPH_ROOT/build)
+
+Examples:
+    # Run all CLI tests:
+    $0
+
+    # Run with custom build directory:
+    $0 -b /path/to/build
+
+EOF
+    exit 0
+}
+
+# Parse options
+while [[ $# -gt 0 ]]; do
+    case $1 in
+        -h|--help)
+            usage
+            ;;
+        -b|--build)
+            BUILD_DIR="$2"
+            shift 2
+            ;;
+        *)
+            echo "Unknown option: $1"
+            usage
+            ;;
+    esac
+done
+
+# Verify build directory exists
+if [ ! -d "$BUILD_DIR" ]; then
+    echo "Error: Build directory not found: $BUILD_DIR"
+    echo "Please build Ceph first or specify correct build directory with -b"
+    exit 1
+fi
+
+# Verify build/bin directory exists
+if [ ! -d "$BUILD_DIR/bin" ]; then
+    echo "Error: Build binaries not found in $BUILD_DIR/bin"
+    echo "Please run './do_cmake.sh && cd build && ninja' first"
+    exit 1
+fi
+
+# Change to build directory and run tests
+cd "$BUILD_DIR"
+export PATH="$PWD/bin:$PATH"
+
+echo "Running all CLI tests from build directory: $BUILD_DIR"
+echo "=================================================="
+exec "$CEPH_ROOT/src/test/run-cli-tests"
index 72085688c680d073e85c971c8c4899031dfa6224..ec83dfb96a3f454480cbf8738bf52d4cef4026e0 100644 (file)
      --show-mappings       show mappings
      --show-bad-mappings   show bad mappings
      --show-choose-tries   show choose tries histogram
+     --show-retry-exhaustion
+                           check for and report CRUSH retry exhaustion
      --output-name name
                            prepend the data file(s) generated during the
                            testing routine with name
index 6a7ecaec07aa2f469b0a95627af6da19642919d2..18ffa0586f38d77cfaca268126f42e6c14ef9c17 100644 (file)
   $ crushtool -c "$TESTDIR/show-choose-tries.txt" -o "$TESTDIR/show-choose-tries.crushmap"
   $ FIRSTN_RULESET=0
   $ crushtool -i "$TESTDIR/show-choose-tries.crushmap" --test --show-choose-tries --rule $FIRSTN_RULESET --x 1 --num-rep 2
-   0:         1
-   1:         1
-   2:         0
-   3:         0
-   4:         0
-   5:         0
-   6:         0
-   7:         0
-   8:         0
-   9:         0
-  10:         0
-  11:         0
-  12:         0
-  13:         0
-  14:         0
-  15:         0
-  16:         0
-  17:         0
-  18:         0
-  19:         0
-  20:         0
-  21:         0
-  22:         0
-  23:         0
-  24:         0
-  25:         0
-  26:         0
-  27:         0
-  28:         0
-  29:         0
-  30:         0
-  31:         0
-  32:         0
-  33:         0
-  34:         0
-  35:         0
-  36:         0
-  37:         0
-  38:         0
-  39:         0
-  40:         0
-  41:         0
-  42:         0
-  43:         0
-  44:         0
-  45:         0
-  46:         0
-  47:         0
-  48:         0
-  49:         0
+  tries 1:         1
+  tries 2:         1
+  tries 3:         0
+  tries 4:         0
+  tries 5:         0
+  tries 6:         0
+  tries 7:         0
+  tries 8:         0
+  tries 9:         0
+  tries 10:         0
+  tries 11:         0
+  tries 12:         0
+  tries 13:         0
+  tries 14:         0
+  tries 15:         0
+  tries 16:         0
+  tries 17:         0
+  tries 18:         0
+  tries 19:         0
+  tries 20:         0
+  tries 21:         0
+  tries 22:         0
+  tries 23:         0
+  tries 24:         0
+  tries 25:         0
+  tries 26:         0
+  tries 27:         0
+  tries 28:         0
+  tries 29:         0
+  tries 30:         0
+  tries 31:         0
+  tries 32:         0
+  tries 33:         0
+  tries 34:         0
+  tries 35:         0
+  tries 36:         0
+  tries 37:         0
+  tries 38:         0
+  tries 39:         0
+  tries 40:         0
+  tries 41:         0
+  tries 42:         0
+  tries 43:         0
+  tries 44:         0
+  tries 45:         0
+  tries 46:         0
+  tries 47:         0
+  tries 48:         0
+  tries 49:         0
+  tries 50:         0
   $ INDEP_RULESET=1
   $ crushtool -i "$TESTDIR/show-choose-tries.crushmap" --test --show-choose-tries --rule $INDEP_RULESET --x 1 --num-rep 1
-   0:         0
-   1:         1
-   2:         0
-   3:         0
-   4:         0
-   5:         0
-   6:         0
-   7:         0
-   8:         0
-   9:         0
-  10:         0
-  11:         0
-  12:         0
-  13:         0
-  14:         0
-  15:         0
-  16:         0
-  17:         0
-  18:         0
-  19:         0
-  20:         0
-  21:         0
-  22:         0
-  23:         0
-  24:         0
-  25:         0
-  26:         0
-  27:         0
-  28:         0
-  29:         0
-  30:         0
-  31:         0
-  32:         0
-  33:         0
-  34:         0
-  35:         0
-  36:         0
-  37:         0
-  38:         0
-  39:         0
-  40:         0
-  41:         0
-  42:         0
-  43:         0
-  44:         0
-  45:         0
-  46:         0
-  47:         0
-  48:         0
-  49:         0
+  tries 1:         0
+  tries 2:         1
+  tries 3:         0
+  tries 4:         0
+  tries 5:         0
+  tries 6:         0
+  tries 7:         0
+  tries 8:         0
+  tries 9:         0
+  tries 10:         0
+  tries 11:         0
+  tries 12:         0
+  tries 13:         0
+  tries 14:         0
+  tries 15:         0
+  tries 16:         0
+  tries 17:         0
+  tries 18:         0
+  tries 19:         0
+  tries 20:         0
+  tries 21:         0
+  tries 22:         0
+  tries 23:         0
+  tries 24:         0
+  tries 25:         0
+  tries 26:         0
+  tries 27:         0
+  tries 28:         0
+  tries 29:         0
+  tries 30:         0
+  tries 31:         0
+  tries 32:         0
+  tries 33:         0
+  tries 34:         0
+  tries 35:         0
+  tries 36:         0
+  tries 37:         0
+  tries 38:         0
+  tries 39:         0
+  tries 40:         0
+  tries 41:         0
+  tries 42:         0
+  tries 43:         0
+  tries 44:         0
+  tries 45:         0
+  tries 46:         0
+  tries 47:         0
+  tries 48:         0
+  tries 49:         0
+  tries 50:         0
   $ rm -f "$TESTDIR/show-choose-tries.crushmap"
 # Local Variables:
 # compile-command: "cd ../../.. ; make -j4 crushtool && test/run-cli-tests"