This patch is used to add grafana config to opnfv dashboard for
[yardstick.git] / run_tests.sh
1 #!/bin/bash
2
3 ##############################################################################
4 # Copyright (c) 2015 Ericsson AB and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12 # Run yardstick's flake8, unit, coverage, functional test
13
14 getopts ":f" FILE_OPTION
15
16 run_flake8() {
17     echo "Running flake8 ... "
18     logfile=test_results.log
19     if [ $FILE_OPTION == "f" ]; then
20         flake8 yardstick > $logfile
21     else
22         flake8 yardstick
23     fi
24
25     if [ $? -ne 0 ]; then
26         echo "FAILED"
27         if [ $FILE_OPTION == "f" ]; then
28             echo "Results in $logfile"
29         fi
30         exit 1
31     else
32         echo "OK"
33     fi
34 }
35
36 run_tests() {
37     echo "Running unittest ... "
38     if [ $FILE_OPTION == "f" ]; then
39         python -m unittest discover -v -s tests/unit > $logfile 2>&1
40     else
41         python -m unittest discover -v -s tests/unit
42     fi
43
44     if [ $? -ne 0 ]; then
45         if [ $FILE_OPTION == "f" ]; then
46             echo "FAILED, results in $logfile"
47         fi
48         exit 1
49     else
50         if [ $FILE_OPTION == "f" ]; then
51             echo "OK, results in $logfile"
52         fi
53     fi
54 }
55
56 run_coverage() {
57     source tests/ci/cover.sh
58     run_coverage_test
59 }
60
61 run_functional_test() {
62
63     mkdir -p .testrepository
64     python -m subunit.run discover tests/functional > .testrepository/subunit.log
65
66     subunit2pyunit < .testrepository/subunit.log
67     EXIT_CODE=$?
68     subunit-stats < .testrepository/subunit.log
69
70     if [ $EXIT_CODE -ne 0 ]; then
71         exit 1
72     else
73         echo "OK"
74     fi
75 }
76
77 export PYTHONPATH='yardstick/vTC/apexlake'
78
79 run_flake8
80 run_tests
81 run_coverage
82 run_functional_test