]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: cephtool tests for `tell mds.X` 2569/head
authorJohn Spray <john.spray@redhat.com>
Tue, 30 Sep 2014 13:45:42 +0000 (14:45 +0100)
committerJohn Spray <john.spray@redhat.com>
Wed, 8 Oct 2014 11:01:21 +0000 (12:01 +0100)
Signed-off-by: John Spray <john.spray@redhat.com>
qa/workunits/cephtool/test.sh
src/test/vstart_wrapper.sh

index c50a313a2e10f944aac90eb92466fbad6d1c06f1..9f01d7f469a3575536c87cf0c0fd26860ebded46 100755 (executable)
@@ -466,25 +466,109 @@ function test_mon_misc()
 }
 
 
+function check_mds_active()
+{
+    ceph mds dump | grep active
+}
+
+function wait_mds_active()
+{
+  for i in $(seq 1 300) ; do
+      if ! check_mds_active ; then
+          echo "waiting for an active MDS daemon"
+          sleep 5
+      else
+          break
+      fi
+  done
+  check_mds_active
+}
+
+function get_mds_gids()
+{
+    ceph mds dump --format=json | python -c "import json; import sys; print ' '.join([m['gid'].__str__() for m in json.load(sys.stdin)['info'].values()])"
+}
+
 function fail_all_mds()
 {
   ceph mds cluster_down
-  mds_gids=`ceph mds dump | grep up: | while read line ; do echo $line | awk '{print substr($1, 0, length($1)-1);}' ; done`
+  mds_gids=$(get_mds_gids)
   for mds_gid in $mds_gids ; do
       ceph mds fail $mds_gid
   done
+  if check_mds_active ; then
+      echo "An active MDS remains, something went wrong"
+      ceph mds dump
+      exit -1
+  fi
+
 }
 
-function test_mon_mds()
+function remove_all_fs()
 {
-  existing_fs=$(ceph fs ls | grep "name:" | awk '{print substr($2,0,length($2)-1);}')
-  num_mds=$(ceph mds stat | awk '{print $2;}' | cut -f1 -d'/')
+  existing_fs=$(ceph fs ls --format=json | python -c "import json; import sys; print ' '.join([fs['name'] for fs in json.load(sys.stdin)])")
   if [ -n "$existing_fs" ] ; then
       fail_all_mds
       echo "Removing existing filesystem '${existing_fs}'..."
       ceph fs rm $existing_fs --yes-i-really-mean-it
       echo "Removed '${existing_fs}'."
   fi
+}
+
+# So that tests requiring MDS can skip if one is not configured
+# in the cluster at all
+function mds_exists()
+{
+    ceph auth list | grep "^mds"
+}
+
+function test_mds_tell()
+{
+  if ! mds_exists ; then
+      echo "Skipping test, no MDS found"
+      return
+  fi
+
+  remove_all_fs
+  ceph osd pool create fs_data 10
+  ceph osd pool create fs_metadata 10
+  ceph fs new cephfs fs_metadata fs_data
+  wait_mds_active
+
+  # Test injectargs by GID
+  old_mds_gids=$(get_mds_gids)
+  echo Old GIDs: $old_mds_gids
+
+  for mds_gid in $old_mds_gids ; do
+      ceph tell mds.$mds_gid injectargs "--debug-mds 20"
+  done
+
+  # Test respawn by rank
+  ceph tell mds.0 respawn
+  new_mds_gids=$old_mds_gids
+  while [ $new_mds_gids -eq $old_mds_gids ] ; do
+      sleep 5
+      new_mds_gids=$(get_mds_gids)
+  done
+  echo New GIDs: $new_mds_gids
+
+  # Test respawn by ID
+  ceph tell mds.a respawn
+  new_mds_gids=$old_mds_gids
+  while [ $new_mds_gids -eq $old_mds_gids ] ; do
+      sleep 5
+      new_mds_gids=$(get_mds_gids)
+  done
+  echo New GIDs: $new_mds_gids
+
+  remove_all_fs
+  ceph osd pool delete fs_data fs_data --yes-i-really-really-mean-it
+  ceph osd pool delete fs_metadata fs_metadata --yes-i-really-really-mean-it
+}
+
+function test_mon_mds()
+{
+  remove_all_fs
 
   ceph osd pool create fs_data 10
   ceph osd pool create fs_metadata 10
@@ -1182,6 +1266,7 @@ TESTS=(
   mon_osd_misc
   mon_heap_profiler
   osd_bench
+  mds_tell
 )
 
 #
index b150c4f0e02577da85d5ff471d147e35aff952bf..a2ffe2f554464fbc07ee670027393b4faa23c425 100755 (executable)
@@ -31,9 +31,9 @@ function vstart_setup()
     mkdir -p $CEPH_DEV_DIR
     trap "vstart_teardown ; rm -f $TMPFILE" EXIT
     export LC_ALL=C # some tests are vulnerable to i18n
-    MON=1 OSD=3 ./vstart.sh \
+    MDS=1 MON=1 OSD=3 ./vstart.sh \
         -o 'paxos propose interval = 0.01' \
-        -n -l mon osd || return 1
+        -n -l mon osd mds || return 1
     export PATH=.:$PATH
     export CEPH_CONF=ceph.conf