]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Merge pull request #3847 from trociny/wip-test_with_crushtool.master
authorKefu Chai <tchaikov@gmail.com>
Mon, 20 Apr 2015 08:04:25 +0000 (16:04 +0800)
committerKefu Chai <tchaikov@gmail.com>
Mon, 20 Apr 2015 08:04:25 +0000 (16:04 +0800)
mon: ceph osd setcrushmap: test_with_crushtool improvements

Reviewed-by: Kefu Chai <kchai@redhat.com>
1  2 
qa/workunits/cephtool/test.sh
src/common/Makefile.am
src/common/config_opts.h
src/mon/OSDMonitor.cc
src/test/Makefile.am

index 4a2e90ea0fc50701988fa1f084e1ad1b3cbe7cc7,ef0b675d1ab4b2f9e50d6ebd2caf887ce0d80a2e..fab48b53ce7d2f3e5d86d54f227fffd4e7b62a11
@@@ -1431,29 -1427,60 +1431,69 @@@ 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 'took too long'
-   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}"
  }
  
 +function test_mon_ping()
 +{
 +  ceph ping mon.a
 +  ceph ping mon.b
 +  expect_false ceph ping mon.foo
 +
 +  ceph ping mon.*
 +}
 +
  #
  # New tests should be added to the TESTS array below
  #
Simple merge
Simple merge
Simple merge
index f724fad0e71db5ff6acbab10d51cf6847e02cd74,36302159f218800368061aa136d6c5a184a27499..4b4440d57cd588ee4c50d1f09986924b92e8d0fd
@@@ -409,8 -398,13 +409,13 @@@ check_TESTPROGRAMS += unittest_tablefor
  unittest_bit_vector_SOURCES = test/common/test_bit_vector.cc
  unittest_bit_vector_CXXFLAGS = $(UNITTEST_CXXFLAGS)
  unittest_bit_vector_LDADD = $(UNITTEST_LDADD) $(CEPH_GLOBAL)
 -check_PROGRAMS += unittest_bit_vector
 +check_TESTPROGRAMS += unittest_bit_vector
  
+ unittest_subprocess_SOURCES = test/test_subprocess.cc
+ unittest_subprocess_LDADD = $(LIBCOMMON) $(UNITTEST_LDADD)
+ unittest_subprocess_CXXFLAGS = $(UNITTEST_CXXFLAGS)
+ check_PROGRAMS += unittest_subprocess
  check_SCRIPTS += test/pybind/test_ceph_argparse.py
  check_SCRIPTS += test/pybind/test_ceph_daemon.py