]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
src/script: add run-cbt.sh
authorKefu Chai <kchai@redhat.com>
Mon, 12 Aug 2019 14:38:25 +0000 (22:38 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 14 Aug 2019 03:16:31 +0000 (11:16 +0800)
this script will be used by jenkins to drive the CBT based test

also, this test can be used by developer for testing crimson or classic
OSD.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/script/run-cbt.sh [new file with mode: 0755]

diff --git a/src/script/run-cbt.sh b/src/script/run-cbt.sh
new file mode 100755 (executable)
index 0000000..491c61c
--- /dev/null
@@ -0,0 +1,105 @@
+#!/bin/sh
+
+usage() {
+    local prog_name=$1
+    shift
+    cat <<EOF
+usage:
+  $prog_name [options] <config-file>...
+
+options:
+  -a,--archive-dir    directory in which the test result is stored, default to $PWD/cbt-archive
+  --build-dir         directory where CMakeCache.txt is located, default to $PWD
+  --cbt-dir           directory of cbt if you have already a copy of it. ceph/cbt:master will be cloned from github if not specified
+  -h,--help           print this help message
+  --source-dir        the path to the top level of Ceph source tree, default to $PWD/..
+  --use-existing      do not setup/teardown a vstart cluster for testing
+
+example:
+  $prog_name --cbt ~/dev/cbt -a /tmp ../src/test/crimson/cbt/radosbench_4K_read.yaml
+EOF
+}
+
+prog_name=$(basename $0)
+archive_dir=$PWD/cbt-archive
+build_dir=$PWD
+source_dir=$(dirname $PWD)
+use_existing=false
+opts=$(getopt --options "a:h" --longoptions "archive-dir:,build-dir:,source-dir:,cbt:,help,use-existing" --name $prog_name -- "$@")
+eval set -- "$opts"
+
+while true; do
+    case "$1" in
+        -a|--archive-dir)
+            archive_dir=$2
+            shift 2
+            ;;
+        --build-dir)
+            build_dir=$2
+            shift 2
+            ;;
+        --source_dir)
+            source_dir=$2
+            shift 2
+            ;;
+        --cbt)
+            cbt_dir=$2
+            shift 2
+            ;;
+        --use-existing)
+            use_existing=true
+            shift
+            ;;
+        -h|--help)
+            usage $prog_name
+            return 0
+            ;;
+        --)
+            shift
+            break
+            ;;
+        *)
+            echo "unexpected argument $1" 1>&2
+            return 1
+            ;;
+    esac
+done
+
+if test $# -gt 0; then
+    config_files="$@"
+else
+    echo "$prog_name: please specify one or more .yaml files" 1>&2
+    usage $prog_name
+    return 1
+fi
+
+if test -z "$cbt_dir"; then
+    cbt_dir=$PWD/cbt
+    git clone --depth 1 -b master https://github.com/ceph/cbt.git $cbt_dir
+fi
+
+if ! $use_existing; then
+    MDS=0 MGR=1 OSD=3 MON=1 $source_dir/src/vstart.sh -n -X \
+       --without-dashboard --memstore \
+       -o "memstore_device_bytes=34359738368" \
+       --crimson --nodaemon --redirect-output \
+       --osd-args "--memory 4G"
+fi
+
+for config_file in $config_files; do
+    echo "testing $config_file"
+    cbt_config=$(mktemp $config_file.XXXX.yaml)
+    $source_dir/src/test/crimson/cbt//t2c.py \
+        --build-dir $build_dir \
+        --input $config_file \
+        --output $cbt_config
+    $cbt_dir/cbt.py \
+        --archive $archive_dir \
+        --conf $build_dir/ceph.conf \
+        $cbt_config
+    rm -f $cbt_config
+done
+
+if ! $use_existing; then
+    $source_dir/src/stop.sh --crimson
+fi