]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/workunits: Add large number of files in a directory test script
authorYan, Zheng <zheng.z.yan@intel.com>
Thu, 3 Oct 2013 09:18:01 +0000 (17:18 +0800)
committerYan, Zheng <zheng.z.yan@intel.com>
Sat, 5 Oct 2013 03:31:12 +0000 (11:31 +0800)
Test the directory fragments feature

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
qa/workunits/misc/dirfrag.sh [new file with mode: 0755]

diff --git a/qa/workunits/misc/dirfrag.sh b/qa/workunits/misc/dirfrag.sh
new file mode 100755 (executable)
index 0000000..104b7bc
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/sh -e
+
+DEPTH=5
+COUNT=10000
+
+function kill_jobs {
+  jobs -p | xargs kill
+}
+trap kill_jobs SIGINT
+
+function create_files {
+  for i in `seq 1 $COUNT`
+  do
+    touch file$i
+  done
+}
+
+function delete_files {
+  for i in `ls -f`
+  do
+    if [[ ${i}a = file*a ]]
+    then
+      rm -f $i
+    fi
+  done
+}
+
+rm -rf testdir
+mkdir testdir
+cd testdir
+
+for i in `seq 1 $DEPTH`; do
+  mkdir dir$i
+  cd dir$i
+  create_files &
+done
+wait
+
+for i in `seq 1 $DEPTH`; do
+  delete_files &
+  cd ..
+done
+wait
+
+cd ..
+rm -rf testdir