Rename add_floating_ip arg to floatingip_addr
[functest.git] / run_unit_tests.sh
1 #!/bin/bash
2 set -o errexit
3 set -o pipefail
4
5 # ******************************
6 # prepare the env for the tests
7 # ******************************
8 # clean useless results dir
9 # should be done at the end
10 # but in case of crash during unit test
11 # clean it anyway
12 if [ -d "/home/opnfv/functest/results" ]
13 then
14     sudo rm -rf /home/opnfv/functest
15 fi
16
17 # TODO clean that...
18 # Create log dir if needed
19 # log shall be disabled during unit tests
20 # fix to be done in Logger
21 echo "Create dummy log file...."
22 sudo mkdir -p /home/opnfv/functest/results/odl
23 sudo touch /home/opnfv/functest/results/functest.log
24 sudo touch /home/opnfv/functest/results/odl/stdout.txt
25 sudo chmod -Rf a+rw /home/opnfv
26
27 # Either Workspace is set (CI)
28 if [ -z $WORKSPACE ]
29 then
30     WORKSPACE="."
31 fi
32
33
34 # ***************
35 # Run unit tests
36 # ***************
37 echo "Running unit tests..."
38
39 # start vitual env
40 virtualenv $WORKSPACE/functest_venv
41 source $WORKSPACE/functest_venv/bin/activate
42
43 # install python packages
44 sudo apt-get install -y build-essential python-dev python-pip
45 pip install --upgrade pip
46 pip install -r $WORKSPACE/test-requirements.txt
47 pip install $WORKSPACE
48
49 export CONFIG_FUNCTEST_YAML=$(pwd)/functest/ci/config_functest.yaml
50 # unit tests
51 # TODO: remove cover-erase
52 # To be deleted when all functest packages will be listed
53 nosetests --with-xunit \
54          --with-coverage \
55          --cover-erase \
56          --cover-package=functest.core.testcase_base \
57          --cover-package=functest.opnfv_tests.sdn.odl.odl \
58          --cover-xml \
59          --cover-html \
60          functest/tests/unit
61 rc=$?
62
63 deactivate
64
65 # *******
66 # clean
67 # *******
68 # Clean useless logs
69 if [ -d "/home/opnfv/functest/results" ]
70 then
71     sudo rm -rf /home/opnfv/functest/results
72 fi
73
74 exit $rc