Merge "Fix calico tes suite"
diff --git a/tcp_tests/tests/system/test_calico.py b/tcp_tests/tests/system/test_calico.py
index 72f9ca9..cc44ba4 100644
--- a/tcp_tests/tests/system/test_calico.py
+++ b/tcp_tests/tests/system/test_calico.py
@@ -26,8 +26,6 @@
"""Test class for Calico network provider in k8s"""
@pytest.mark.fail_snapshot
- @pytest.mark.calico_ci
- @pytest.mark.cz8116
def test_k8s_netchecker_calico(self, show_step, config, k8s_deployed):
"""Test for deploying k8s environment with Calico plugin and check
network connectivity between different pods by k8s-netchecker
@@ -71,39 +69,56 @@
Scenario:
1. Install k8s with Calico network plugin.
- 2. Run netchecker-server service.
- 3. Run netchecker-agent daemon set.
+ 2. Check netchecker-server service.
+ 3. Check netchecker-agent daemon set.
4. Get network verification status. Check status is 'OK'.
- 5. Remove local route to netchecker-agent pod on the first node
- 6. Check that the route is automatically recovered
- 7. Get network verification status. Check status is 'OK'.
+ 5. Get metrics from netchecker
+ 6. Remove local route to netchecker-agent pod on the first node
+ 7. Check that the route is automatically recovered
+ 8. Get network verification status. Check status is 'OK'.
Duration: 3000 seconds
"""
- # STEP #1
show_step(1)
k8sclient = k8s_deployed.api
assert k8sclient.nodes.list() is not None, "Can not get nodes list"
-
- # STEP #2
+ netchecker_port = netchecker.get_service_port(k8sclient)
show_step(2)
- netchecker.start_server(k8s=k8s_deployed, config=config)
- LOG.info("Waiting for netchecker server is running")
- netchecker.wait_check_network(k8sclient, works=True,
- timeout=300)
+ netchecker.get_netchecker_pod_status(k8s=k8s_deployed,
+ namespace='netchecker')
- # STEP #3
show_step(3)
- netchecker.start_agent(k8s=k8s_deployed, config=config)
+ netchecker.get_netchecker_pod_status(k8s=k8s_deployed,
+ pod_name='netchecker-agent',
+ namespace='netchecker')
- # STEP #4
show_step(4)
- netchecker.wait_check_network(k8sclient, works=True,
- timeout=300)
-
- # STEP #5
+ netchecker.wait_check_network(k8sclient, namespace='netchecker',
+ netchecker_pod_port=netchecker_port)
show_step(5)
+ res = netchecker.get_metric(k8sclient,
+ netchecker_pod_port=netchecker_port,
+ namespace='netchecker')
+
+ assert res.status_code == 200, 'Unexpected response code {}'\
+ .format(res)
+ metrics = ['ncagent_error_count_total', 'ncagent_http_probe_code',
+ 'ncagent_http_probe_connect_time_ms',
+ 'ncagent_http_probe_connection_result',
+ 'ncagent_http_probe_content_transfer_time_ms',
+ 'ncagent_http_probe_dns_lookup_time_ms',
+ 'ncagent_http_probe_server_processing_time_ms',
+ 'ncagent_http_probe_tcp_connection_time_ms',
+ 'ncagent_http_probe_total_time_ms',
+ 'ncagent_report_count_tota']
+ for metric in metrics:
+ assert metric in res.text.strip(), \
+ 'Mandotory metric {0} is missing in {1}'.format(
+ metric, res.text)
+
+ # STEP #6
+ show_step(6)
first_node = k8sclient.nodes.list()[0]
first_node_ips = [addr.address for addr in first_node.status.addresses
if 'IP' in addr.type]
@@ -116,7 +131,7 @@
target_pod_ip = None
- for pod in k8sclient.pods.list():
+ for pod in k8sclient.pods.list(namespace='netchecker'):
if pod.status.host_ip not in first_node_ips:
continue
# TODO: get pods by daemonset with name 'netchecker-agent'
@@ -131,8 +146,8 @@
target_pod_ip, first_node.name
))
- # STEP #6
- show_step(6)
+ # STEP #7
+ show_step(7)
route_chk_cmd = 'ip route list | grep -q "{0}"'.format(target_pod_ip)
helpers.wait_pass(
lambda: underlay.sudo_check_call(cmd=route_chk_cmd,
@@ -140,14 +155,17 @@
timeout=120,
interval=2
)
- pod_ping_cmd = 'sleep 3 && ping -q -c 1 -w 3 {0}'.format(target_pod_ip)
+ pod_ping_cmd = 'sleep 120 && ping -q -c 1 -w 3 {0}'.format(
+ target_pod_ip)
underlay.sudo_check_call(cmd=pod_ping_cmd, node_name=first_node_name)
LOG.debug('Local route to pod IP {0} on node {1} is '
'recovered'.format(target_pod_ip, first_node.name))
- # STEP #7
- show_step(7)
- netchecker.wait_check_network(k8sclient, works=True)
+ # STEP #8
+ show_step(8)
+ netchecker.wait_check_network(k8sclient, namespace='netchecker',
+ netchecker_pod_port=netchecker_port,
+ works=True)
@pytest.mark.fail_snapshot
# FIXME(apanchenko): uncomment as soon as the following bug is fixed