Skip to content

Commit

Permalink
Merge "SG changes to accomodate changes in mainline UI page"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Dec 7, 2015
2 parents e233fc8 + 214a27c commit 91cc681
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 36 deletions.
37 changes: 18 additions & 19 deletions fixtures/webui_test.py
Expand Up @@ -638,15 +638,13 @@ def create_security_group(self, fixture):
result = True
try:
if not self.ui.click_on_create(
'SG',
'Security Group',
'security_groups',
fixture.secgrp_name,
prj_name=fixture.project_name):
result = result and False
self.ui.send_keys(fixture.secgrp_name, 'txtRuleName')
if not fixture.secgrp_rules:
self.ui.click_element('icon-minus', 'class')
for index, rule in enumerate(fixture.secgrp_rules):
self.ui.send_keys(fixture.secgrp_name, 'display_name', 'name')
for index, rule in enumerate(fixture.secgrp_entries):
direction = rule['direction']
ether_type = rule['eth_type']
src_addresses = rule['src_addresses'][0]
Expand All @@ -667,32 +665,32 @@ def create_security_group(self, fixture):
addresses = dst_addresses['subnet']
addresses = addresses['ip_prefix'] + \
'/' + str(addresses['ip_prefix_len'])
if index:
self.ui.click_element('btnCommonAddSGRule')
sg_grp_tuple = self.ui.find_element(
['sGRuleTuples', 'rule-item'], ['id', 'class'], if_elements=[1])
self.ui.click_element('editable-grid-add-link', 'class')
sg_grp_tuple = self.browser.find_elements_by_class_name(
'data-row')[index]
self.ui.dropdown(
"div[id$='direction']",
"td[id$='direction']",
direction,
element_type='css',
browser_obj=sg_grp_tuple[0])
browser_obj=sg_grp_tuple)
self.ui.dropdown(
"div[id$='protocol']",
"td[id$='protocol']",
protocol,
element_type='css',
browser_obj=sg_grp_tuple[0])
browser_obj=sg_grp_tuple)
self.ui.dropdown(
"div[id$='ether']",
"td[id$='ethertype']",
ether_type,
element_type='css',
browser_obj=sg_grp_tuple[0])
browser_obj=sg_grp_tuple)
text_box = self.ui.find_element(
"input[id$='remotePorts']",
"input[name$='remotePorts']",
'css',
browser=sg_grp_tuple[0])
browser=sg_grp_tuple)
text_box.clear()
text_box.send_keys(port_range)
self.ui.click_element("div[id$='remoteAddr']", 'css')
self.ui.click_element("td[id$='remoteAddr']",
'css', browser=sg_grp_tuple)
self.ui.send_keys(
addresses,
"input[id^='s2id_autogen']",
Expand All @@ -705,7 +703,8 @@ def create_security_group(self, fixture):
if element.text == addresses:
element.click()
break
if not self.ui.click_on_create('SG', save=True):
if not self.ui.click_on_create('Security Group',
'security_groups', save=True):
result = result and False
self.logger.info(
"Security group %s creation successful" %
Expand Down
38 changes: 25 additions & 13 deletions serial_scripts/webui/webui_common.py
Expand Up @@ -257,11 +257,19 @@ def click_on_create(
func_suffix=None,
name=None,
save=False,
new_rule=True,
select_project=True,
prj_name='admin'):
element = 'btnCreate' + element_type
browser = self.browser
if element_type == 'Security Group':
element = 'Edit ' + element_type
element_new = func_suffix[:-1]
elif element_type == 'Floating IP':
element = 'Allocate ' + element_type
else:
element = 'Create ' + element_type
if save:
element = element + 'OK'
elem = 'configure-%sbtn1' % (element_new)
else:
click_func = 'click_configure_' + func_suffix
click_func = getattr(self, click_func)
Expand All @@ -278,7 +286,9 @@ def click_on_create(
self.logger.info("Creating %s %s using contrail-webui" %
(element_type, name))
try:
self.click_element(element)
browser.find_element_by_xpath(
"//a[@class='widget-toolbar-icon' and @title='%s']" %
element).click()
except WebDriverException:
try:
self.click_element('close', 'class', screenshot=False)
Expand All @@ -287,19 +297,20 @@ def click_on_create(
raise
self.wait_till_ajax_done(self.browser)
if save:
self.click_element(elem)
if not self.check_error_msg(
"Click on %s" %
(element),
(elem),
close_window=True):
self.logger.error("Click on save button %s failed" % (element))
self.logger.error("Click on save button %s failed" % (elem))
try:
self.click_element('close', 'class', screenshot=False)
except:
pass
return False
self.logger.info(
"Click on save button %s successful" %
(element_type))
self.logger.info(
"Click on save button %s successful" %
(element_type))
else:
self.logger.info("Click on icon + %s successful" % (element_type))
return True
Expand Down Expand Up @@ -727,10 +738,10 @@ def click_if_element_found(self, objs, element_text, grep=False):

def select_project(self, project_name='admin'):
current_project = self.find_element(
['s2id_ddProjectSwitcher', 'span'], ['id', 'tag']).text
['s2id_projects\-breadcrumb\-dropdown', 'span'], ['id', 'tag']).text
if not current_project == project_name:
self.click_element(
['s2id_ddProjectSwitcher', 'a'], ['id', 'tag'], jquery=False, wait=4)
['s2id_projects\-breadcrumb\-dropdown', 'a'], ['id', 'tag'], jquery=False, wait=4)
elements_obj_list = self.find_select2_drop_elements(self.browser)
self.click_if_element_found(elements_obj_list, project_name)
# end select_project
Expand Down Expand Up @@ -1146,8 +1157,8 @@ def delete_element(self, fixture=None, element_type=None):
if not self.click_configure_security_groups():
result = result and False
element_name = fixture.secgrp_name
element_id = 'btnDeleteSG'
popup_id = 'btnCnfRemoveMainPopupOK'
element_id = 'btnActionDelSecGrp'
popup_id = 'configure-security_groupbtn1'
rows = self.get_rows(canvas=True)
ln = 0
if rows:
Expand Down Expand Up @@ -1463,7 +1474,8 @@ def click_configure_interfaces(self):
def click_configure_dns_servers(self):
self.wait_till_ajax_done(self.browser)
self._click_on_config_dropdown(self.browser, 4)
self.click_element(['config_dns_dnsservers', 'a'], ['id', 'tag'])
# self.click_element(['config_dns_dnsservers', 'a'], ['id', 'tag'])
self.click_element(['config_dns_servers', 'a'], ['id', 'tag'])
time.sleep(2)
return self.check_error_msg("configure dns servers")
# end click_configure_dns_servers
Expand Down
8 changes: 4 additions & 4 deletions serial_scripts/webui/webui_topology.py
Expand Up @@ -133,13 +133,13 @@ def __init__(
'dst_ports': [{'start_port': 50, 'end_port': 15000}],
'src_ports': [{'start_port': 50, 'end_port': 20000}],
'src_addresses': [{'subnet': {'ip_prefix': '50.2.0.0', 'ip_prefix_len': 9}}],
'rule_uuid': uuid_1, 'eth_type': 'IPV4'
'rule_uuid': uuid_1, 'eth_type': 'IPv4'
}, {'direction': '>',
'protocol': 'any',
'src_addresses': [{'security_group': 'local', 'subnet': None}],
'dst_ports': [{'start_port': 0, 'end_port': 5000}],
'src_ports': [{'start_port': 25, 'end_port': 6000}],
'dst_addresses': [{'subnet': {'ip_prefix': '20.1.0.0', 'ip_prefix_len': 16}}], 'rule_uuid': uuid_2, 'eth_type': 'IPV4'}]
'dst_addresses': [{'subnet': {'ip_prefix': '20.1.0.0', 'ip_prefix_len': 16}}], 'rule_uuid': uuid_2, 'eth_type': 'IPv4'}]

self.sg_rules[self.sg_list[1]] = [
{'direction': '>',
Expand All @@ -148,13 +148,13 @@ def __init__(
'dst_ports': [{'start_port': 0, 'end_port': 65535}],
'src_ports': [{'start_port': 0, 'end_port': 65535}],
'src_addresses': [{'subnet': {'ip_prefix': '100.2.1.0', 'ip_prefix_len': 24}}],
'rule_uuid': uuid_1, 'eth_type': 'IPV4'
'rule_uuid': uuid_1, 'eth_type': 'IPv4'
}, {'direction': '>',
'protocol': 'any',
'src_addresses': [{'security_group': 'local', 'subnet': None}],
'dst_ports': [{'start_port': 0, 'end_port': 65535}],
'src_ports': [{'start_port': 0, 'end_port': 65535}],
'dst_addresses': [{'subnet': {'ip_prefix': '0.0.0.0', 'ip_prefix_len': 0}}], 'rule_uuid': uuid_2, 'eth_type': 'IPV4'}]
'dst_addresses': [{'subnet': {'ip_prefix': '0.0.0.0', 'ip_prefix_len': 0}}], 'rule_uuid': uuid_2, 'eth_type': 'IPv4'}]

# define service templates ##
self.st_list = ['tcp_svc_template']
Expand Down

0 comments on commit 91cc681

Please sign in to comment.