Skip to content

Commit 73fd480

Browse files
author
Aleksei Burlakov
committed
Tests: add /cib/live/primitives/{primitive-id}/edit tests
* test_copy_primitive * test_rename_primitive * test_delete_primitive The test_click_on_status is removed because it's implied in the new tests
1 parent 1c3cd25 commit 73fd480

File tree

2 files changed

+142
-11
lines changed

2 files changed

+142
-11
lines changed

e2e_test/hawk_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,11 @@ def main():
143143
browser.test('test_click_on_history', results)
144144
browser.test('test_generate_report', results)
145145
browser.test('test_click_on_command_log', results)
146-
browser.test('test_click_on_status', results)
147146
browser.test('test_add_primitive', results, primitive)
148147
ssh.verify_primitive(primitive, test_version, results)
148+
browser.test('test_copy_primitive', results)
149+
browser.test('test_rename_primitive', results)
150+
browser.test('test_delete_primitive', results)
149151
browser.test('test_remove_primitive', results, primitive)
150152
ssh.verify_primitive_removed(primitive, results)
151153
browser.test('test_add_clone', results, clone)

e2e_test/hawk_test_driver.py

Lines changed: 139 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class Error:
2525
MAINT_TOGGLE_ERR = "Could not find Switch to Maintenance toggle button for node"
2626
PRIMITIVE_TARGET_ROLE_ERR = "Couldn't find value [Started] for primitive target-role"
2727
STONITH_ERR = "Couldn't find stonith-sbd menu to place it in maintenance mode"
28+
COOL_PRIMITIVE_ERR = "Couldn't find cool_primitive menu to edit"
29+
HOT_PRIMITIVE_ERR = "Couldn't find hot_primitive menu to edit"
30+
DUMMY_PRIMITIVE_ERR = "Couldn't find hot_primitive menu to edit"
2831
STONITH_ERR_OFF = "Could not find Disable Maintenance Mode button for stonith-sbd"
2932
CRM_CONFIG_ADVANCED_ATTRIBUTES = "crm_config dropdown box shows the advanced attributes, but shouldn't"
3033

@@ -37,6 +40,7 @@ class Xpath:
3740
CLONE_DATA_HELP_FILTER = '//a[contains(@data-help-filter, ".clone")]'
3841
COMMIT_BTN_DANGER = '//button[contains(@class, "btn-danger") and contains(@class, "commit")]'
3942
DISMISS_MODAL = '//*[@id="modal"]/div/div/div[3]/button'
43+
STOP_PRIMITIVE_FORMAT = '//*[@id="resources"]/div[1]/div[2]/div[2]/table/tbody/tr[{}]/td[6]/div/a[1]'
4044
DROP_DOWN_FORMAT = '//*[@id="resources"]/div[1]/div[2]/div[2]/table/tbody/tr[{}]/td[6]/div/div'
4145
EDIT_MONITOR_TIMEOUT = '//*[@id="oplist"]/fieldset/div/div[1]/div[3]/div[2]/div/div/a[1]'
4246
EDIT_START_TIMEOUT = '//*[@id="oplist"]/fieldset/div/div[1]/div[1]/div[2]/div/div/a[1]'
@@ -74,6 +78,9 @@ class Xpath:
7478
STONITH_CHKBOX = '//input[contains(@type, "checkbox") and contains(@value, "stonith-sbd")]'
7579
STONITH_MAINT_OFF = '//a[contains(@href, "stonith-sbd") and contains(@title, "Disable Maintenance Mode")]'
7680
STONITH_MAINT_ON = '//a[contains(@href, "stonith-sbd/maintenance_on")]'
81+
COOL_PRIMITIVE_EDIT = '//a[contains(@href, "cool_primitive/edit")]'
82+
HOT_PRIMITIVE_EDIT = '//a[contains(@href, "hot_primitive/edit")]'
83+
DUMMY_PRIMITIVE_EDIT = '//a[contains(@href, "dummy_primitive/edit")]'
7784
TARGET_ROLE_FORMAT = '//select[contains(@class, "form-control") and contains(@name, "{}[meta][target-role]")]'
7885
TARGET_ROLE_STARTED = '//option[contains(@value, "tarted")]'
7986
WIZARDS_BASIC = '//span[contains(@href, "basic")]'
@@ -294,12 +301,12 @@ def check_and_click_by_xpath(self, errmsg, xpath_exps):
294301
None
295302
'''
296303
for xpath in xpath_exps:
304+
time.sleep(1)
297305
elem = self.find_element(By.XPATH, xpath)
298306
if not elem:
299307
print(f"ERROR: Couldn't find element by xpath [{xpath}] {errmsg}")
300308
self.test_status = False
301309
return
302-
time.sleep(5)
303310
try:
304311
elem.click()
305312
except ElementNotInteractableException:
@@ -562,15 +569,6 @@ def test_click_on_command_log(self):
562569
return False
563570
return self.click_on('Command Log')
564571

565-
def test_click_on_status(self):
566-
'''
567-
Click on status
568-
Returns:
569-
boolean: True for successful and False for failure
570-
'''
571-
print("TEST: test_click_on_status")
572-
return self.click_on('Status')
573-
574572
def test_add_primitive(self, primitive):
575573
'''
576574
Add primitive resources
@@ -642,6 +640,137 @@ def test_add_primitive(self, primitive):
642640
print(f"ERROR: Could not create primitive [{primitive}]")
643641
return status
644642

643+
def test_copy_primitive(self):
644+
'''
645+
Copy the cool_primitive as hot_primitive. Assumes cool_primitive resource is the first one listed on the
646+
resources table
647+
Returns:
648+
boolean: True if successful or False if failed
649+
'''
650+
if self.find_element(By.XPATH, Xpath.RSC_ROWS):
651+
print("TEST: test_copy_primitive: cool_primitive --> cool_primitive + hot_primitive")
652+
resource_number_from_top = 1 # 1. cool_primitive, 2. stonith-sbd
653+
# First, click on Edit
654+
time.sleep(2)
655+
self.check_and_click_by_xpath(Error.COOL_PRIMITIVE_ERR, [Xpath.DROP_DOWN_FORMAT.format(resource_number_from_top),
656+
Xpath.COOL_PRIMITIVE_EDIT])
657+
658+
# Second, rename the cool_primitive to hot_primitive
659+
time.sleep(2) # to redirect
660+
# try to find '<a>Copy</a>' for 10 seconds (Ruby hawk),
661+
# if none --> look for '<button name="copy"> (Go hawk)
662+
copy_btn = self.find_element(By.LINK_TEXT, "Copy", 10) or self.find_element(By.NAME, "copy")
663+
if not copy_btn:
664+
print("ERROR: Couldn't find Copy button")
665+
return False
666+
copy_btn.click()
667+
668+
time.sleep(7) # to fetch meta attributes
669+
self.fill_value("primitive[id]", "hot_primitive")
670+
671+
submit_btn = self.find_element(By.NAME, "submit")
672+
if not submit_btn:
673+
print("ERROR: Couldn't find Submit button")
674+
return False
675+
submit_btn.click()
676+
677+
if self.verify_success():
678+
print("INFO: cool_primitive successfully renamed copied as hot_primitive")
679+
return True
680+
print("ERROR: failed to copy cool_primitive as hot_primitive")
681+
return False
682+
683+
def test_rename_primitive(self):
684+
'''
685+
Rename the hot_primitive to dummy_primitive. Assumes hot_primitive resource is the second one listed on the
686+
resources table
687+
Returns:
688+
boolean: True if successful or False if failed
689+
'''
690+
if self.find_element(By.XPATH, Xpath.RSC_ROWS):
691+
print("TEST: test_rename_primitive: hot_primitive --> dummy_primitive")
692+
resource_number_from_top = 2 # 1. cool_primitive, 2. hot_primitive, 3. stonith-sbd
693+
694+
# First, stop the cool_primitive
695+
time.sleep(2)
696+
self.check_and_click_by_xpath(Error.HOT_PRIMITIVE_ERR,[Xpath.STOP_PRIMITIVE_FORMAT.format(resource_number_from_top),
697+
Xpath.COMMIT_BTN_DANGER])
698+
699+
# Second, click on Edit
700+
time.sleep(2)
701+
self.check_and_click_by_xpath(Error.HOT_PRIMITIVE_ERR, [Xpath.DROP_DOWN_FORMAT.format(resource_number_from_top),
702+
Xpath.HOT_PRIMITIVE_EDIT])
703+
704+
# Third, rename the cool_primitive to hot_primitive
705+
time.sleep(2) # wait the redirect finishes
706+
# try to find '<a>Rename</a>' for 10 seconds (Ruby hawk),
707+
# if none --> look for '<button name="rename"> (Go hawk)
708+
rename_btn = self.find_element(By.LINK_TEXT, "Rename", 10) or self.find_element(By.NAME, "rename")
709+
if not rename_btn:
710+
print("ERROR: Couldn't find Rename button")
711+
return False
712+
rename_btn.click()
713+
714+
# try to find '<input id="to">' for 10 seconds (Ruby hawk),
715+
# if none --> look for '<input name="renamePopupInputTo"> (Go hawk)
716+
input_elem = self.find_element(By.ID, "to", 5) or self.find_element(By.NAME, "renamePopupInputTo", 5)
717+
if not input_elem:
718+
print("ERROR: Couldn't find rename input field (id='to' or name='renamePopupInputTo')")
719+
return False
720+
input_elem.clear()
721+
input_elem.send_keys("dummy_primitive")
722+
723+
# There are 2 submit buttons, one on the main page and another on the popup (the one we need)
724+
submit_btn = self.find_element(By.XPATH, '//button[@type="submit" and .//i[contains(@class, "fa-save")]]', 10)
725+
if not submit_btn:
726+
print("ERROR: Couldn't find Rename-Submit button")
727+
return False
728+
submit_btn.click()
729+
730+
if self.verify_success():
731+
print("INFO: hot_primitive successfully renamed into dummy_primitive")
732+
return True
733+
print("ERROR: failed to rename hot_primitive into dummy_primitive")
734+
return False
735+
736+
def test_delete_primitive(self):
737+
'''
738+
Delete the dummy_primitive. Assumes dummy_primitive resource is the second one listed on the
739+
resources table
740+
Returns:
741+
boolean: True if successful or False if failed
742+
'''
743+
if self.find_element(By.XPATH, Xpath.RSC_ROWS):
744+
print("TEST: test_delete_primitive: Delete the dummy_primitive")
745+
resource_number_from_top = 2 # 1. cool_primitive, 2. dummy_primitive, 3. stonith-sbd
746+
747+
# First, click on edit
748+
time.sleep(2)
749+
self.check_and_click_by_xpath(Error.DUMMY_PRIMITIVE_ERR, [
750+
Xpath.DROP_DOWN_FORMAT.format(resource_number_from_top),
751+
Xpath.DUMMY_PRIMITIVE_EDIT])
752+
753+
# Second, click on Delete
754+
time.sleep(2) # wait the redirect finishes
755+
delete_btn = self.find_element(By.XPATH, '//button[.//i[contains(@class, "fa-trash")]] | //a[.//i[contains(@class, "fa-trash")]]', 10)
756+
if not delete_btn:
757+
print("ERROR: Couldn't find Delete button")
758+
return False
759+
delete_btn.click()
760+
761+
# Third, confirm deleting
762+
commit_btn = self.find_element(By.CLASS_NAME, "commit")
763+
if not commit_btn:
764+
print("ERROR: Couldn't find OK-Commit button")
765+
return False
766+
commit_btn.click()
767+
768+
if self.verify_success():
769+
print("INFO: dummy_primitive was successfully deleted")
770+
return True
771+
print("ERROR: failed to delete dummy_primitive")
772+
return False
773+
645774
def remove_rsc(self, name):
646775
'''
647776
Remove resources

0 commit comments

Comments
 (0)