.. _`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/>`_
--- /dev/null
+#!/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"
--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
$ 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"