]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test: new test case for ceph-kvstore-tool
authorChang Liu <liuchang0812@gmail.com>
Fri, 6 Oct 2017 17:44:44 +0000 (01:44 +0800)
committerChang Liu <liuchang0812@gmail.com>
Mon, 16 Oct 2017 14:52:10 +0000 (22:52 +0800)
Signed-off-by: Chang Liu <liuchang0812@gmail.com>
qa/suites/rados/singleton-nomsgr/all/ceph-kvstore-tool.yaml [new file with mode: 0644]
qa/workunits/cephtool/test_kvstore_tool.sh [new file with mode: 0755]

diff --git a/qa/suites/rados/singleton-nomsgr/all/ceph-kvstore-tool.yaml b/qa/suites/rados/singleton-nomsgr/all/ceph-kvstore-tool.yaml
new file mode 100644 (file)
index 0000000..a40243d
--- /dev/null
@@ -0,0 +1,17 @@
+roles:
+- [mon.a, mgr.x, osd.0, osd.1, osd.2, client.0]
+
+overrides:
+  ceph:
+    log-whitelist:
+    - but it is still running
+    - overall HEALTH_
+    - \(POOL_APP_NOT_ENABLED\)
+
+tasks:
+- install:
+- ceph:
+- workunit:
+    clients:
+      all:
+        - cephtool/test_kvstore_tool.sh
diff --git a/qa/workunits/cephtool/test_kvstore_tool.sh b/qa/workunits/cephtool/test_kvstore_tool.sh
new file mode 100755 (executable)
index 0000000..39b6398
--- /dev/null
@@ -0,0 +1,71 @@
+#!/usr/bin/env bash
+
+set -x
+
+source $(dirname $0)/../../standalone/ceph-helpers.sh
+
+set -e
+set -o functrace
+PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}:  '
+SUDO=${SUDO:-sudo}
+export CEPH_DEV=1
+
+echo note: test ceph_kvstore_tool with bluestore
+
+expect_false()
+{
+    set -x
+    if "$@"; then return 1; else return 0; fi
+}
+
+TEMP_DIR=$(mktemp -d ${TMPDIR-/tmp}/cephtool.XXX)
+trap "rm -fr $TEMP_DIR" 0
+
+TEMP_FILE=$(mktemp $TEMP_DIR/test_invalid.XXX)
+
+function test_ceph_kvstore_tool()
+{
+  # create a data directory
+  ceph-objectstore-tool --data-path ${TEMP_DIR} --op mkfs 
+
+  # list
+  origin_kv_nums=`ceph-kvstore-tool  bluestore-kv ${TEMP_DIR} list 2>/dev/null | wc -l`
+  
+  # exists
+  prefix=`ceph-kvstore-tool bluestore-kv ${TEMP_DIR} list 2>/dev/null | head -n 1 | awk '{print $1}'`
+  ceph-kvstore-tool bluestore-kv ${TEMP_DIR} exists ${prefix}
+  expect_false ceph-kvstore-tool bluestore-kv ${TEMP_DIR} exists ${prefix}notexist
+
+  # list-crc
+  ceph-kvstore-tool  bluestore-kv ${TEMP_DIR} list-crc
+  ceph-kvstore-tool  bluestore-kv ${TEMP_DIR} list-crc ${prefix}
+
+  # list with prefix
+  ceph-kvstore-tool  bluestore-kv ${TEMP_DIR} list ${prefix}
+
+  # set
+  echo "helloworld" >> ${TEMP_FILE}
+  ceph-kvstore-tool bluestore-kv ${TEMP_DIR} set TESTPREFIX TESTKEY in ${TEMP_FILE}
+  ceph-kvstore-tool bluestore-kv ${TEMP_DIR} exists TESTPREFIX TESTKEY
+
+  # get 
+  ceph-kvstore-tool bluestore-kv ${TEMP_DIR} get TESTPREFIX TESTKEY out ${TEMP_FILE}.bak
+  diff ${TEMP_FILE} ${TEMP_FILE}.bak
+
+  # rm 
+  ceph-kvstore-tool bluestore-kv ${TEMP_DIR} rm TESTPREFIX TESTKEY
+  expect_false ceph-kvstore-tool bluestore-kv ${TEMP_DIR} exists TESTPREFIX TESTKEY
+
+  # compact
+  ceph-kvstore-tool bluestore-kv ${TEMP_DIR} compact
+
+  # repair 
+  ceph-kvstore-tool bluestore-kv ${TEMP_DIR} repair 
+
+  current_kv_nums=`ceph-kvstore-tool  bluestore-kv ${TEMP_DIR} list 2>/dev/null | wc -l`
+  test ${origin_kv_nums} -eq ${current_kv_nums}
+} 
+
+test_ceph_kvstore_tool
+
+echo OK