]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: generalise cephtool for vstart+MDS 2119/head
authorJohn Spray <john.spray@redhat.com>
Wed, 9 Jul 2014 11:43:04 +0000 (12:43 +0100)
committerJohn Spray <john.spray@redhat.com>
Fri, 18 Jul 2014 15:53:58 +0000 (16:53 +0100)
Previously this test assumed no pre-existing
filesystem and no MDS running.  Generalize it
to nuke any existing filesystems found before
running, so that you can use it inside a vstart
cluster that had MDS>0.

Signed-off-by: John Spray <john.spray@redhat.com>
qa/workunits/cephtool/test.sh

index b7f1c209bd38d9f09cbed52af275ecc8081ff2d5..f8d13947eeb23f3bdef3a55b0ef5fe59def06f3d 100755 (executable)
@@ -3,7 +3,7 @@
 set -e
 set -o functrace
 PS4=' ${FUNCNAME[0]}: $LINENO: '
-SUDO=sudo
+SUDO=${SUDO:-sudo}
 
 function get_pg()
 {
@@ -330,12 +330,34 @@ function test_mon_misc()
 }
 
 
+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`
+  for mds_gid in $mds_gids ; do
+      ceph mds fail $mds_gid
+  done
+}
+
 function test_mon_mds()
 {
+  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'/')
+  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
+
   ceph osd pool create fs_data 10
   ceph osd pool create fs_metadata 10
   ceph fs new cephfs fs_metadata fs_data
 
+  # We don't want any MDSs to be up, their activity can interfere with
+  # the "current_epoch + 1" checking below if they're generating updates
+  fail_all_mds
+
   # Check for default crash_replay_interval set automatically in 'fs new'
   ceph osd dump | grep fs_data > $TMPFILE
   check_response "crash_replay_interval 45 "
@@ -398,13 +420,14 @@ function test_mon_mds()
   ceph mds add_data_pool mds-ec-pool 2>$TMPFILE
   check_response 'erasure-code' $? 22
   set -e
-  ec_poolnum=$(ceph osd dump | grep 'pool.*mds-ec-pool' | awk '{print $2;}')
-  data_poolnum=$(ceph osd dump | grep 'pool.*fs_data' | awk '{print $2;}')
-  metadata_poolnum=$(ceph osd dump | grep 'pool.*fs_metadata' | awk '{print $2;}')
-  set +e
+  ec_poolnum=$(ceph osd dump | grep "pool.* 'mds-ec-pool" | awk '{print $2;}')
+  data_poolnum=$(ceph osd dump | grep "pool.* 'fs_data" | awk '{print $2;}')
+  metadata_poolnum=$(ceph osd dump | grep "pool.* 'fs_metadata" | awk '{print $2;}')
 
+  fail_all_mds
   ceph fs rm cephfs --yes-i-really-mean-it
 
+  set +e
   ceph mds newfs $metadata_poolnum $ec_poolnum --yes-i-really-mean-it 2>$TMPFILE
   check_response 'erasure-code' $? 22
   ceph mds newfs $ec_poolnum $data_poolnum --yes-i-really-mean-it 2>$TMPFILE