summaryrefslogtreecommitdiffstats
path: root/run_unit_tests.sh
blob: 0abf3c279fa40a833ba04de2da31db20d10a8d58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
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..."

# start vitual env
virtualenv $WORKSPACE/functest_venv
source $WORKSPACE/functest_venv/bin/activate

# install python packages
easy_install -U setuptools
easy_install -U pip
pip install -r $WORKSPACE/docker/requirements.pip
pip install -e $WORKSPACE

python $WORKSPACE/setup.py develop

# unit tests
# TODO: remove cover-erase
# To be deleted when all functest packages will be listed
nosetests --with-xunit \
         --with-coverage \
         --cover-erase \
         --cover-package=functest.core.TestCasesBase \
         --cover-package=functest.opnfv_tests.Controllers.ODL.OpenDaylightTesting \
         --cover-xml \
         --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