summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDan Radez <dradez@redhat.com>2016-05-31 22:58:00 -0400
committerDan Radez <dradez@redhat.com>2016-06-07 09:26:24 -0400
commit4b7436673f7bc8422a793f94c9fed5c2fc671167 (patch)
treeb35a9625290be117a09f292e54831e85ae2c46f4 /tests
parent5aa09cb2a69b677baf6e7614b734e155e8205a5b (diff)
Enabling python coverage tests in build.sh
Change-Id: Iececedb03a60dd0bfc1ad6ef1275f6a0427350eb Signed-off-by: Dan Radez <dradez@redhat.com>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/python-coverage.sh60
-rw-r--r--tests/python_coverage_ip_utils.py25
2 files changed, 76 insertions, 9 deletions
diff --git a/tests/python-coverage.sh b/tests/python-coverage.sh
index ee471446..8de6157d 100755
--- a/tests/python-coverage.sh
+++ b/tests/python-coverage.sh
@@ -3,21 +3,63 @@ set -x
all_networks="admin_network private_network storage_network external_network"
# exercise help
-coverage-3.4 run ../lib/python/apex-python-utils.py -l /dev/null > /dev/null
+coverage3 run ../lib/python/apex-python-utils.py -l /dev/null > /dev/null
# exercise parse-net-settings
# throw debug on the first to exercise it
-coverage-3.4 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
+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
# exercise proper nic-template runs
-coverage-3.4 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
-coverage-3.4 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
-coverage-3.4 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
-coverage-3.4 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
+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
+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
+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
+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
# exercise find-ip
-coverage-3.4 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
+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
+
+# exercise parse-deploy-settings
+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
+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
+
+# exercise parse-deploy-settings errors
+echo "global_params:" > /tmp/python-coverage.test
+coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
+echo "deploy_options: string" > /tmp/python-coverage.test
+coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
+echo "global_params:" >> /tmp/python-coverage.test
+coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
+cat > /tmp/python-coverage.test << EOF
+global_params:
+deploy_options:
+ error: error
+EOF
+coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
+cat > /tmp/python-coverage.test << EOF
+global_params:
+deploy_options:
+ performance: string
+EOF
+coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
+cat > /tmp/python-coverage.test << EOF
+global_params:
+deploy_options:
+ performance:
+ error: error
+EOF
+coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
+cat > /tmp/python-coverage.test << EOF
+global_params:
+deploy_options:
+ performance:
+ Controller:
+ error: error
+EOF
+coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
+
+# coverage for ip_utils
+PYTHONPATH=../lib/python/ coverage3 run -a python_coverage_ip_utils.py $(ip r | grep default | awk '{ print $5 }')
# generate reports
-coverage-3.4 report --include '*lib/python/*' -m
-coverage-3.4 html --include '*lib/python/*'
+coverage3 html --include '*lib/python/*'
+coverage3 report --include '*lib/python/*' -m
diff --git a/tests/python_coverage_ip_utils.py b/tests/python_coverage_ip_utils.py
new file mode 100644
index 00000000..35280c18
--- /dev/null
+++ b/tests/python_coverage_ip_utils.py
@@ -0,0 +1,25 @@
+import sys
+from apex import ip_utils
+
+iface = ip_utils.get_interface(sys.argv[1])
+
+erroring_tests = (
+ "ip_utils.get_interface('')",
+ "ip_utils.get_interface('lo', address_family=0)",
+ "ip_utils.get_interface('lo', address_family=6)",
+ "ip_utils.get_interface('lo')",
+ "ip_utils.get_ip_range()",
+ "ip_utils.get_ip_range(interface=iface)")
+
+for t in erroring_tests:
+ try:
+ eval(t)
+ except:
+ pass
+
+ip_utils.find_gateway(interface=iface)
+ip_utils.get_ip(1, cidr="10.10.10.0/24")
+ip_utils.get_ip(1, interface=iface)
+ip_utils.get_ip_range(interface=iface, start_offset=1, end_offset=20)
+ip_utils.get_ip_range(interface=iface, start_offset=1, count=10)
+ip_utils.get_ip_range(interface=iface, end_offset=20, count=10)