]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/test_dedup_tool: fix test cases for ceph-dedup-tool 43481/head
authormyoungwon oh <ohmyoungwon@gmail.com>
Wed, 10 Nov 2021 10:42:22 +0000 (19:42 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Fri, 12 Nov 2021 04:22:48 +0000 (13:22 +0900)
1. add a delay after pool creation
2. fix checking output due to changed output format
3. fix wrong variable to test chunk-repair

Signed-off-by: Myoungwon Oh <myoungwon.oh@samsung.com>
qa/workunits/rados/test_dedup_tool.sh

index d0f995c748923e67ce43aa593dc2071f97255bd9..f8db0ed0e7785854fd5a67d3dd5f33da6bc60aee 100755 (executable)
@@ -48,28 +48,38 @@ OBJ=test_rados_obj
 [ -x "$CEPH_TOOL" ] || die "couldn't find $CEPH_TOOL binary to test"
 
 run_expect_succ "$CEPH_TOOL" osd pool create "$POOL" 8
+sleep 5
 
 function test_dedup_ratio_fixed()
 {
   # case 1
   dd if=/dev/urandom of=dedup_object_1k bs=1K count=1
-  dd if=dedup_object_1k of=dedup_object_100k bs=1K count=100
+  for num in `seq 1 50`
+  do
+    dd if=dedup_object_1k of=dedup_object_100k bs=1K oflag=append conv=notrunc
+  done
+  for num in `seq 1 50`
+  do
+    dd if=/dev/zero of=dedup_object_100k bs=1K count=1 oflag=append conv=notrunc
+  done
 
   $RADOS_TOOL -p $POOL put $OBJ ./dedup_object_100k
-  RESULT=$($DEDUP_TOOL --op estimate --pool $POOL --chunk-size 1024  --chunk-algorithm fixed --fingerprint-algorithm sha1 --debug | grep result | awk '{print$4}')
-  if [ 1024 -ne $RESULT ];
+  RESULT=$($DEDUP_TOOL --op estimate --pool $POOL --chunk-size 1024  --chunk-algorithm fixed --fingerprint-algorithm sha1 | grep chunk_size_average | awk '{print$2}' | sed "s/\,//g")
+  # total size / the number of deduped object = 100K / 1
+  if [ 51200 -ne $RESULT ];
   then
-    die "Estimate failed expecting 1024 result $RESULT"
+    die "Estimate failed expecting 51200 result $RESULT"
   fi
 
   # case 2
   dd if=/dev/zero of=dedup_object_10m bs=10M count=1
 
   $RADOS_TOOL -p $POOL put $OBJ ./dedup_object_10m
-  RESULT=$($DEDUP_TOOL --op estimate --pool $POOL --chunk-size 4096  --chunk-algorithm fixed --fingerprint-algorithm sha1 --debug | grep result | awk '{print$4}')
-  if [ 4096 -ne $RESULT ];
+  RESULT=$($DEDUP_TOOL --op estimate --pool $POOL --chunk-size 4096  --chunk-algorithm fixed --fingerprint-algorithm sha1 | grep examined_bytes | awk '{print$2}')
+  # 10485760
+  if [ 10485760 -ne $RESULT ];
   then
-    die "Estimate failed expecting 4096 result $RESULT"
+    die "Estimate failed expecting 10485760 result $RESULT"
   fi
 
   # case 3 max_thread
@@ -79,7 +89,7 @@ function test_dedup_ratio_fixed()
     $RADOS_TOOL -p $POOL put dedup_object_$num ./dedup_object_$num
   done
 
-  RESULT=$($DEDUP_TOOL --op estimate --pool $POOL --chunk-size 4096  --chunk-algorithm fixed --fingerprint-algorithm sha1 --max-thread 4 --debug | grep result | awk '{print$2}')
+  RESULT=$($DEDUP_TOOL --op estimate --pool $POOL --chunk-size 4096  --chunk-algorithm fixed --fingerprint-algorithm sha1 --max-thread 4 | grep chunk_size_average | awk '{print$2}' | sed "s/\,//g")
 
   if [ 98566144 -ne $RESULT ];
   then
@@ -133,10 +143,10 @@ function test_dedup_chunk_scrub()
   $RADOS_TOOL -p $POOL tier-flush foo
   sleep 2
 
-  rados ls -p $CHUNK_POOL
+  $RADOS_TOOL ls -p $CHUNK_POOL
   CHUNK_OID=$(echo -n "There hi" | sha1sum | awk '{print $1}')
 
-  POOL_ID=$(ceph osd pool ls detail | grep $POOL |  awk '{print$2}')
+  POOL_ID=$($CEPH_TOOL osd pool ls detail | grep $POOL |  awk '{print$2}')
   $DEDUP_TOOL --op chunk-get-ref --chunk-pool $CHUNK_POOL --object $CHUNK_OID --target-ref bar --target-ref-pool-id $POOL_ID
   RESULT=$($DEDUP_TOOL --op dump-chunk-refs --chunk-pool $CHUNK_POOL --object $CHUNK_OID)
 
@@ -191,17 +201,19 @@ function test_dedup_chunk_repair()
   CHUNK_OID=$(echo -n "hi there" | sha1sum | awk '{print $1}')
 
   POOL_ID=$($CEPH_TOOL osd pool ls detail | grep $POOL |  awk '{print$2}')
-
+  $RADOS_TOOL -p $CHUNK_POOL put $CHUNK_OID ./foo
 
   # increase ref count by two, resuling in mismatch
   $DEDUP_TOOL --op chunk-get-ref --chunk-pool $CHUNK_POOL --object $CHUNK_OID --target-ref foo --target-ref-pool-id $POOL_ID
   $DEDUP_TOOL --op chunk-get-ref --chunk-pool $CHUNK_POOL --object $CHUNK_OID --target-ref foo --target-ref-pool-id $POOL_ID
+  $DEDUP_TOOL --op chunk-get-ref --chunk-pool $CHUNK_POOL --object $CHUNK_OID --target-ref foo --target-ref-pool-id $POOL_ID
+  $DEDUP_TOOL --op chunk-get-ref --chunk-pool $CHUNK_POOL --object $CHUNK_OID --target-ref foo --target-ref-pool-id $POOL_ID
   $DEDUP_TOOL --op chunk-get-ref --chunk-pool $CHUNK_POOL --object bar-chunk --target-ref bar --target-ref-pool-id $POOL_ID
   $DEDUP_TOOL --op chunk-get-ref --chunk-pool $CHUNK_POOL --object bar-chunk --target-ref bar --target-ref-pool-id $POOL_ID
 
   RESULT=$($DEDUP_TOOL --op dump-chunk-refs --chunk-pool $CHUNK_POOL --object $CHUNK_OID)
   RESULT=$($DEDUP_TOOL --op chunk-scrub --chunk-pool $CHUNK_POOL | grep "Damaged object" | awk '{print$4}')
-  if [ $RESULT -ne "1" ] ; then
+  if [ $RESULT -ne "2" ] ; then
     $CEPH_TOOL osd pool delete $POOL $POOL --yes-i-really-really-mean-it
     $CEPH_TOOL osd pool delete $CHUNK_POOL $CHUNK_POOL --yes-i-really-really-mean-it
     die "Chunk-scrub failed expecting damaged objects is not 1"
@@ -210,15 +222,14 @@ function test_dedup_chunk_repair()
   $DEDUP_TOOL --op chunk-repair --chunk-pool $CHUNK_POOL --object $CHUNK_OID --target-ref foo --target-ref-pool-id $POOL_ID
   $DEDUP_TOOL --op chunk-repair --chunk-pool $CHUNK_POOL --object bar-chunk --target-ref bar --target-ref-pool-id $POOL_ID
 
-  $DEDUP_TOOL --op dump-chunk-refs --chunk-pool $CHUNK_POOL --object $CHUNK_OID | grep foo
   RESULT=$($DEDUP_TOOL --op dump-chunk-refs --chunk-pool $CHUNK_POOL --object $CHUNK_OID | grep foo | wc -l)
-  if [ -n "$RESULT" ] ; then
+  if [ 0 -ne "$RESULT" ] ; then
     $CEPH_TOOL osd pool delete $POOL $POOL --yes-i-really-really-mean-it
     $CEPH_TOOL osd pool delete $CHUNK_POOL $CHUNK_POOL --yes-i-really-really-mean-it
     die "Scrub failed expecting bar is removed"
   fi
-  RESULT=$($DEDUP_TOOL --op dump-chunk-refs --chunk-pool $CHUNK_POOL --object bar-chunk | grep bar)
-  if [ -n "$RESULT" ] ; then
+  RESULT=$($DEDUP_TOOL --op dump-chunk-refs --chunk-pool $CHUNK_POOL --object bar-chunk | grep bar | wc -l)
+  if [ 0 -ne "$RESULT" ] ; then
     $CEPH_TOOL osd pool delete $POOL $POOL --yes-i-really-really-mean-it
     $CEPH_TOOL osd pool delete $CHUNK_POOL $CHUNK_POOL --yes-i-really-really-mean-it
     die "Scrub failed expecting bar is removed"
@@ -239,5 +250,3 @@ $CEPH_TOOL osd pool delete $POOL $POOL --yes-i-really-really-mean-it
 
 echo "SUCCESS!"
 exit 0
-
-