X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=run_unit_tests.sh;h=71d21c9db502cb3a8e80034c060443e3eb89d432;hb=1eaaf380669f26c8ad45d4b207a4d029b61268f6;hp=a37cd3d98db222e579593f99e09fa76293787842;hpb=6eff0316f429c3af1c459740a7a7c869d8d3be98;p=functest.git diff --git a/run_unit_tests.sh b/run_unit_tests.sh index a37cd3d98..71d21c9db 100755 --- a/run_unit_tests.sh +++ b/run_unit_tests.sh @@ -2,24 +2,74 @@ set -o errexit set -o pipefail +# ****************************** +# prepare the env for the tests +# ****************************** +# clean useless results dir +# should be done at the end +# but in case of crash during unit test +# clean it anyway +if [ -d "/home/opnfv/functest/results" ] +then + sudo rm -rf /home/opnfv/functest +fi + +# TODO clean that... +# Create log dir if needed +# log shall be disabled during unit tests +# fix to be done in Logger +echo "Create dummy log file...." +sudo mkdir -p /home/opnfv/functest/results/odl +sudo touch /home/opnfv/functest/results/functest.log +sudo touch /home/opnfv/functest/results/odl/stdout.txt +sudo chmod -Rf a+rw /home/opnfv + +# Either Workspace is set (CI) +if [ -z $WORKSPACE ] +then + WORKSPACE="." +fi + + +# *************** +# Run unit tests +# *************** echo "Running unit tests..." -cd . # start vitual env -virtualenv ./functest_venv -source ./functest_venv/bin/activate +virtualenv $WORKSPACE/functest_venv +source $WORKSPACE/functest_venv/bin/activate # install python packages -easy_install -U setuptools -easy_install -U pip -pip install -r docker/requirements.pip -pip install -e . +sudo apt-get install -y build-essential python-dev python-pip +pip install --upgrade pip +pip install -r $WORKSPACE/test-requirements.txt +pip install $WORKSPACE +export CONFIG_FUNCTEST_YAML=$(pwd)/functest/ci/config_functest.yaml # unit tests +# TODO: remove cover-erase +# To be deleted when all functest packages will be listed nosetests --with-xunit \ --with-coverage \ - --cover-package=functest\ + --cover-erase \ + --cover-tests \ + --cover-package=functest.core.testcase_base \ + --cover-package=functest.opnfv_tests.sdn.odl.odl \ --cover-xml \ - unit_tests + --cover-html \ + functest/tests/unit +rc=$? deactivate + +# ******* +# clean +# ******* +# Clean useless logs +if [ -d "/home/opnfv/functest/results" ] +then + sudo rm -rf /home/opnfv/functest/results +fi + +exit $rc