]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: extend mon_crushmap_validation test
authorMykola Golub <mgolub@mirantis.com>
Thu, 26 Feb 2015 19:21:49 +0000 (21:21 +0200)
committerMykola Golub <mgolub@mirantis.com>
Fri, 27 Mar 2015 13:44:35 +0000 (15:44 +0200)
Signed-off-by: Mykola Golub <mgolub@mirantis.com>
qa/workunits/cephtool/test.sh

index 8d473078c4894b203cb0f5a7778aa396dde9fe6a..ef0b675d1ab4b2f9e50d6ebd2caf887ce0d80a2e 100755 (executable)
@@ -1427,18 +1427,58 @@ function test_mon_crushmap_validation()
 {
   local map=$TMPDIR/map
   ceph osd getcrushmap -o $map
-  # crushtool validation timesout and is ignored
-  cat > $TMPDIR/crushtool <<EOF
-#!/bin/sh
-sleep 1000
-exit 0 # success
-EOF
-  chmod +x $TMPDIR/crushtool
-  ceph tell mon.* injectargs --crushtool $TMPDIR/crushtool
-  ceph osd setcrushmap -i $map 2>&1 | grep 'timed out'
-  ceph tell mon.* injectargs --crushtool crushtool
-  # crushtool validation succeeds
+
+  local crushtool_path="${TMPDIR}/crushtool"
+  touch "${crushtool_path}"
+  chmod +x "${crushtool_path}"
+  local crushtool_path_old=`ceph-conf --show-config-value crushtool`
+  ceph tell mon.* injectargs --crushtool "${crushtool_path}"
+
+  printf "%s\n" \
+      "#!/bin/sh
+       cat > /dev/null
+       exit 0" > "${crushtool_path}"
+
+  ceph osd setcrushmap -i $map
+
+  printf "%s\n" \
+      "#!/bin/sh
+       cat > /dev/null
+       exit 1" > "${crushtool_path}"
+
+  expect_false ceph osd setcrushmap -i $map
+
+  printf "%s\n" \
+      "#!/bin/sh
+       cat > /dev/null
+       echo 'TEST FAIL' >&2
+       exit 1" > "${crushtool_path}"
+
+  expect_false ceph osd setcrushmap -i $map 2> $TMPFILE
+  check_response "Error EINVAL: Failed to parse crushmap: TEST FAIL"
+
+  local mon_lease=`ceph-conf --show-config-value mon_lease`
+
+  test "${mon_lease}" -gt 0
+
+  printf "%s\n" \
+      "#!/bin/sh
+       cat > /dev/null
+       sleep $((mon_lease - 1))" > "${crushtool_path}"
+
   ceph osd setcrushmap -i $map
+
+  printf "%s\n" \
+      "#!/bin/sh
+       cat > /dev/null
+       sleep $((mon_lease + 1))" > "${crushtool_path}"
+
+  expect_false ceph osd setcrushmap -i $map 2> $TMPFILE
+  check_response "Error EINVAL: Failed to parse crushmap: ${crushtool_path}: timed out (${mon_lease} sec)"
+
+  ceph tell mon.* injectargs --crushtool "${crushtool_path_old}"
+
+  rm -f "${crushtool_path}"
 }
 
 #