From: Kefu Chai Date: Fri, 24 Jun 2016 07:26:54 +0000 (+0800) Subject: test: ceph-disk: run ceph-disk with cmake X-Git-Tag: v11.0.0~25^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F9919%2Fhead;p=ceph.git test: ceph-disk: run ceph-disk with cmake * CMakeLists.txt: do not run ceph-disk/run-tox.sh in its source directory anymore, "ceph" cli needs to run in the build directory. * CMakeLists.txt, run-tox.sh: - pass $CEPH_BUILD_DIR down to tox.ini, so tox can set the working directory to $CEPH_BUILD_DIR to $CMAKE_BINARY_DIR, in which the "ceph" cli will be able to figure out where the pybind dso are located, and respawn itself with the necessary paths set accordingly. - pass $CEPH_BUILD_VIRTUALENV to tox, so ceph-helpers.sh is able to set the paths to ceph-disk and ceph-detect-init right. * run-tox.sh: specify the full path of tox.ini, since we will call "tox" in the build directory. * tox.ini: - move the non-flake8 related settings into [testenv:py27] section. - always use absolute path, as we will call "tox" in the build directory, instead where "tox.ini" lives. Signed-off-by: Kefu Chai --- diff --git a/src/ceph-disk/run-tox.sh b/src/ceph-disk/run-tox.sh index 13447127de80..ae96e803dea1 100755 --- a/src/ceph-disk/run-tox.sh +++ b/src/ceph-disk/run-tox.sh @@ -18,8 +18,19 @@ # run from the ceph-disk directory or from its parent : ${CEPH_DISK_VIRTUALENV:=/tmp/ceph-disk-virtualenv} test -d ceph-disk && cd ceph-disk + +if [ -e tox.ini ]; then + TOX_PATH=`readlink -f tox.ini` +else + TOX_PATH=`readlink -f $(dirname $0)/tox.ini` +fi + +if [ -z $CEPH_BUILD_DIR ]; then + export CEPH_BUILD_DIR=$(dirname ${TOX_PATH}) +fi + source ${CEPH_DISK_VIRTUALENV}/bin/activate -tox > ${CEPH_DISK_VIRTUALENV}/tox.out 2>&1 +tox -c ${TOX_PATH} > ${CEPH_DISK_VIRTUALENV}/tox.out 2>&1 status=$? grep -v InterpreterNotFound < ${CEPH_DISK_VIRTUALENV}/tox.out exit $status diff --git a/src/ceph-disk/tox.ini b/src/ceph-disk/tox.ini index 34c58a7c853c..786136e058f9 100644 --- a/src/ceph-disk/tox.ini +++ b/src/ceph-disk/tox.ini @@ -5,7 +5,6 @@ envlist = flake8,py27 setenv = VIRTUAL_ENV={envdir} CEPH_DISK={envbindir}/coverage run --append --source=ceph_disk -- {envbindir}/ceph-disk -passenv = CEPH_ROOT CEPH_BIN CEPH_LIB usedevelop = true deps = {env:NO_INDEX:} @@ -15,9 +14,12 @@ deps = -r{toxinidir}/test-requirements.txt ../ceph-detect-init -commands = coverage run --append --source=ceph_disk {envbindir}/py.test -vv tests/test_main.py - coverage run --append --source=ceph_disk {envbindir}/py.test -vv tests/test_prepare.py - tests/ceph-disk.sh +[testenv:py27] +passenv = CEPH_ROOT CEPH_BIN CEPH_LIB CEPH_BUILD_VIRTUALENV +changedir = {env:CEPH_BUILD_DIR} +commands = coverage run --append --source=ceph_disk {envbindir}/py.test -vv {toxinidir}/tests/test_main.py + coverage run --append --source=ceph_disk {envbindir}/py.test -vv {toxinidir}/tests/test_prepare.py + {toxinidir}/tests/ceph-disk.sh coverage report --omit=*test*,*tox* --show-missing [testenv:flake8] diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 08baa54fd8de..aebddb3b3482 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -518,7 +518,7 @@ add_ceph_test(test_objectstore_memstore.sh ${CMAKE_CURRENT_SOURCE_DIR}/test_obje add_ceph_test(test_pidfile.sh ${CMAKE_CURRENT_SOURCE_DIR}/test_pidfile.sh) add_ceph_test(unittest_bufferlist.sh ${CMAKE_SOURCE_DIR}/src/unittest_bufferlist.sh) -add_test(NAME run-tox-ceph-disk COMMAND bash ${CMAKE_SOURCE_DIR}/src/ceph-disk/run-tox.sh WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src) +add_test(NAME run-tox-ceph-disk COMMAND bash ${CMAKE_SOURCE_DIR}/src/ceph-disk/run-tox.sh) add_dependencies(check run-tox-ceph-disk) add_test(NAME run-tox-ceph-detect-init COMMAND bash ${CMAKE_SOURCE_DIR}/src/ceph-detect-init/run-tox.sh WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src) @@ -530,10 +530,12 @@ set(CEPH_DETECT_INIT_VIRTUALENV ${CEPH_BUILD_VIRTUALENV}/ceph-detect-init-virtua set_property(TEST run-tox-ceph-disk run-tox-ceph-detect-init - PROPERTY ENVIRONMENT + PROPERTY ENVIRONMENT + CEPH_BUILD_DIR=${CMAKE_BINARY_DIR} CEPH_ROOT=${CMAKE_SOURCE_DIR} CEPH_BIN=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} CEPH_LIB=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + CEPH_BUILD_VIRTUALENV=${CEPH_BUILD_VIRTUALENV} CEPH_DISK_VIRTUALENV=${CEPH_DISK_VIRTUALENV} CEPH_DETECT_INIT_VIRTUALENV=${CEPH_DETECT_INIT_VIRTUALENV} LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib