Skip to content

Commit

Permalink
optimising evpn and alarm testcases
Browse files Browse the repository at this point in the history
1)reducing number of retries for dhclient in evpn testcases
2)reducing number of contrail-status checks in alarm testcases

Closes-bug: #1769571

Change-Id: If0185ec0762d3bc9f77d6a756c2efc0aae331c94
  • Loading branch information
aswanikumar90 committed May 10, 2018
1 parent 6ae2d1f commit 47c4253
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
13 changes: 7 additions & 6 deletions common/contrail_test_init.py
Expand Up @@ -1471,10 +1471,10 @@ def verify_service_state(self, host, service=None, role=None):
"contrail-vrouter-agent", container name like "agent" or a non contrail service
like docker.
'''
contrail_svc = []
non_contrail_svc = []
if service:
services = [service] if isinstance(service, str) else service
contrail_svc = []
non_contrail_svc = []
for s in services:
svc_container = self.get_container_for_service(s)
if svc_container:
Expand Down Expand Up @@ -1701,10 +1701,11 @@ def _action_on_container(self, hosts, event, container, services=None, verify_se
(issue_cmd, self.host_data[host]['name']))
self.run_cmd_on_server(host, issue_cmd, username, password, pty=True, as_sudo=True)
if verify_service:
container_status = self.is_container_up(host, container)
assert container_status if 'start' in event else not container_status
service_status = self.verify_service_state(host, container)[0]
assert service_status if 'start' in event else not service_status
if 'stop' in event:
service_status = self.verify_service_down(host, container)[0]
else:
service_status = self.verify_service_state(host, container)[0]
assert service_status
#end _action_on_container

def restart_container(self, host_ips=None, container=None, verify_service=True):
Expand Down
6 changes: 3 additions & 3 deletions serial_scripts/evpn/verify.py
Expand Up @@ -141,7 +141,7 @@ def verify_dns_disabled(self, encap):
sleep(2)

self.bringup_interface_forcefully(vn_l2_vm1_fixture)
for i in range(5):
for i in range(2):
self.logger.info("Retry %s for bringing up eth1 up" % (i))
cmd_to_pass3 = ['dhclient eth1']
vn_l2_vm1_fixture.run_cmd_on_vm(
Expand Down Expand Up @@ -1025,7 +1025,7 @@ def verify_l2_vm_file_trf_by_scp(self, encap):
self.bringup_interface_forcefully(vn_l2_vm2_fixture)
sleep(10)

for i in range(7):
for i in range(2):
self.logger.info("Retry %s for bringing up eth1 up" % (i))
cmd_to_pass3 = ['dhclient eth1']
vn_l2_vm1_fixture.run_cmd_on_vm(
Expand Down Expand Up @@ -1227,7 +1227,7 @@ def verify_l2_vm_file_trf_by_tftp(self, encap):
self.bringup_interface_forcefully(vn_l2_vm2_fixture)
sleep(10)

for i in range(7):
for i in range(2):
self.logger.info("Retry %s for bringing up eth1 up" % (i))
cmd_to_pass3 = ['dhclient eth1']
vn_l2_vm1_fixture.run_cmd_on_vm(
Expand Down
17 changes: 11 additions & 6 deletions tcutils/collector/analytics_tests.py
Expand Up @@ -2257,6 +2257,7 @@ def verify_alarms(self, role, alarm_type='process-status', service=None, verify_
if len(self.inputs.cfgm_ips) > 1:
multi_instances = True
if alarm_type == 'process-status':
result = result and self.inputs.verify_state()
for process in cfgm_processes:
if process == 'supervisor-config':
if len(self.inputs.cfgm_ips) > 1:
Expand All @@ -2268,6 +2269,7 @@ def verify_alarms(self, role, alarm_type='process-status', service=None, verify_
result = result and False
else:
self.logger.info("Config alarms were generated after stopping the process %s " % (role))

elif alarm_type == 'partial-sysinfo-config':
if not self._verify_contrail_alarms(None, 'config-node', 'partial_sysinfo_config', multi_instances=multi_instances):
result = result and False
Expand All @@ -2279,6 +2281,7 @@ def verify_alarms(self, role, alarm_type='process-status', service=None, verify_
if len(self.inputs.database_ips) > 1:
multi_instances = True
if alarm_type == 'process-status':
result = result and self.inputs.verify_state()
for process in db_processes:
if process == 'kafka' or process == 'supervisor-database':
if len(self.inputs.database_ips) > 1:
Expand All @@ -2296,12 +2299,13 @@ def verify_alarms(self, role, alarm_type='process-status', service=None, verify_
if len(self.inputs.bgp_control_ips) > 1:
multi_instances = True
if alarm_type == 'process-status':
result = result and self.inputs.verify_state()
for process in control_processes:
if not self._verify_contrail_alarms(process, 'control-node', 'service_stop', multi_instances=multi_instances):
result = result and False
else:
self.logger.info("Control alarms were generated after stopping the process %s " % (role))

elif alarm_type == 'bgp-connectivity':
if not self._verify_contrail_alarms(None, 'control-node', 'bgp_peer_mismatch', multi_instances=multi_instances):
self.logger.error("Control bgp connectivity alarm verification failed for %s " % (role))
Expand Down Expand Up @@ -2329,6 +2333,7 @@ def verify_alarms(self, role, alarm_type='process-status', service=None, verify_
if len(self.inputs.collector_ips) > 1:
multi_instances = True
if alarm_type == 'process-status':
result = result and self.inputs.verify_state()
for process in analytics_processes:
if process == 'contrail-collector' or process == 'supervisor-analytics':
if len(self.inputs.collector_ips) > 1:
Expand All @@ -2342,6 +2347,7 @@ def verify_alarms(self, role, alarm_type='process-status', service=None, verify_
result = result and False
else:
self.logger.info("Analytics alarms were generated after stopping the process %s " % (role))

elif alarm_type == 'process-connectivity' and service == 'contrail-alarm-gen':
if not self._verify_contrail_alarms('contrail-alarm-gen', 'analytics-node', 'process_connectivity',
multi_instances=multi_instances):
Expand All @@ -2352,11 +2358,13 @@ def verify_alarms(self, role, alarm_type='process-status', service=None, verify_
if len(self.inputs.compute_ips) > 1:
multi_instances = True
if alarm_type == 'process-status':
result = result and self.inputs.verify_state()
for process in vrouter_processes:
if not self._verify_contrail_alarms(process, 'vrouter','service_stop', multi_instances=multi_instances):
result = result and False
else:
self.logger.info("Vrouter alarms were generated after stopping the process %s " % (role))

elif alarm_type == 'address-mismatch-control':
if not self._verify_contrail_alarms('contrail-vrouter-agent', 'vrouter', 'address_mismatch',
multi_instances=multi_instances):
Expand Down Expand Up @@ -2808,9 +2816,6 @@ def _verify_alarms_stop_svc(self, service, service_ip, role, alarm_type, multi_i
cfgm_ndmgr_ctl_required = False
cfgm_services = ['contrail-config-nodemgr', 'contrail-device-manager']
try:
if not self.inputs.verify_state():
self.logger.error( "All the contrail services are not up")
result = result and False
if not self.inputs.is_microservices_env and service in cfgm_services and dist in ['centos', 'fedora', 'redhat']:
supervisorctl_cfg = 'supervisorctl -s unix:///var/run/supervisord_config.sock'
issue_stop_cmd = supervisorctl_cfg + ' stop ' + service
Expand All @@ -2835,7 +2840,7 @@ def _verify_alarms_stop_svc(self, service, service_ip, role, alarm_type, multi_i
self.inputs.start_service(service, host_ips=[service_ip],
container=container)
time.sleep(10)
if not self.inputs.verify_state():
if not self.inputs.verify_service_state(host=None)[0]:
self.logger.error( "All the contrail services are not up")
result = result and False
if not self._verify_alarms_by_type(service, service_ip, role, alarm_type, multi_instances,
Expand Down Expand Up @@ -4745,7 +4750,7 @@ def verify_purge_info_in_database_uve(self,purge_id,start_time):
limit=1500000)
else:
self.logger.debug("Stat table not found")

# @classmethod
def setUp(self):
super(AnalyticsVerification, self).setUp()
Expand Down

0 comments on commit 47c4253

Please sign in to comment.