Enabling python coverage tests in build.sh
[apex.git] / tests / python-coverage.sh
1 #!/bin/bash
2 set -x
3 all_networks="admin_network private_network storage_network external_network"
4
5 # exercise help
6 coverage3 run ../lib/python/apex-python-utils.py -l /dev/null > /dev/null
7
8 # exercise parse-net-settings
9 # throw debug on the first to exercise it
10 coverage3 run -a ../lib/python/apex-python-utils.py --debug parse-net-settings -s ../config/network/network_settings.yaml -i True -e ../build/network-environment.yaml > /dev/null
11
12 # exercise proper nic-template runs
13 coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null nic-template -t ../config/network/network_settings.yaml -n "$all_networks" -e interface -af 4 > /dev/null
14 coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null nic-template -t ../config/network/network_settings.yaml -n "$all_networks" -e interface -af 6 > /dev/null
15 coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null nic-template -t ../config/network/network_settings.yaml -n "$all_networks" -e br-ex -af 4 > /dev/null
16 coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null nic-template -t ../config/network/network_settings.yaml -n "$all_networks" -e br-ex -af 6 > /dev/null
17
18 # exercise find-ip
19 coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null find-ip -i $(ip a | grep 2: | cut -d \  -f 2 | head -n 1 | cut -d : -f 1) > /dev/null
20
21 # exercise parse-deploy-settings
22 coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f ../config/deploy/os-nosdn-nofeature-noha.yaml > /dev/null
23 coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f ../config/deploy/os-nosdn-performance-ha.yaml > /dev/null
24
25 # exercise parse-deploy-settings errors
26 echo "global_params:" > /tmp/python-coverage.test
27 coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
28 echo "deploy_options: string" > /tmp/python-coverage.test
29 coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
30 echo "global_params:" >> /tmp/python-coverage.test
31 coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
32 cat > /tmp/python-coverage.test << EOF
33 global_params:
34 deploy_options:
35   error: error
36 EOF
37 coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
38 cat > /tmp/python-coverage.test << EOF
39 global_params:
40 deploy_options:
41   performance: string
42 EOF
43 coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
44 cat > /tmp/python-coverage.test << EOF
45 global_params:
46 deploy_options:
47   performance:
48     error: error
49 EOF
50 coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
51 cat > /tmp/python-coverage.test << EOF
52 global_params:
53 deploy_options:
54   performance:
55     Controller:
56       error: error
57 EOF
58 coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
59
60 # coverage for ip_utils
61 PYTHONPATH=../lib/python/ coverage3 run -a python_coverage_ip_utils.py $(ip r | grep default | awk '{ print $5 }')
62
63 # generate reports
64 coverage3 html --include '*lib/python/*'
65 coverage3 report --include '*lib/python/*' -m