mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
Fix instance stop functionality tests
This commit is contained in:
parent
a9d05552dd
commit
31f65bf67d
1 changed files with 10 additions and 24 deletions
|
|
@ -1,11 +1,11 @@
|
|||
from logging import info as log_info, exception as log_exception, warning as log_warning
|
||||
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.common.exceptions import TimeoutException
|
||||
from selenium.common.exceptions import TimeoutException, WebDriverException
|
||||
|
||||
from wizard import DRIVER
|
||||
from base import TEST_TYPE
|
||||
from utils import access_page, assert_alert_message, safe_get_element, wait_for_service
|
||||
from utils import access_page, assert_button_click, safe_get_element, wait_for_service
|
||||
|
||||
exit_code = 0
|
||||
|
||||
|
|
@ -40,30 +40,16 @@ try:
|
|||
|
||||
log_info("Trying to stop instance ...")
|
||||
|
||||
no_errors = True
|
||||
retries = 0
|
||||
action = "stop"
|
||||
while no_errors:
|
||||
log_info(f"Trying to {action} BunkerWeb instance ...")
|
||||
log_info(f"Trying to {action} BunkerWeb instance ...")
|
||||
|
||||
try:
|
||||
form = safe_get_element(DRIVER, By.XPATH, "//form[starts-with(@id, 'form-instance-')]")
|
||||
except TimeoutException:
|
||||
log_exception("No instance form found, exiting ...")
|
||||
exit(1)
|
||||
|
||||
try:
|
||||
access_page(DRIVER, f"//form[starts-with(@id, 'form-instance-')]//button[@value='{action}']", "instances", False)
|
||||
log_info(f"Instance was {action}ed successfully ...")
|
||||
no_errors = False
|
||||
except:
|
||||
if retries >= 3:
|
||||
exit(1)
|
||||
retries += 1
|
||||
log_warning("Error while stopping instance, retrying...")
|
||||
|
||||
if TEST_TYPE == "linux":
|
||||
wait_for_service()
|
||||
try:
|
||||
assert_button_click(DRIVER, f"//form[starts-with(@id, 'form-instance-')]//button[@value='{action}']")
|
||||
safe_get_element(DRIVER, By.XPATH, "//form[starts-with(@id, 'form-instance-')]")
|
||||
log_exception("Instance was not stopped successfully, exiting ...")
|
||||
exit(1)
|
||||
except (TimeoutException, WebDriverException):
|
||||
log_info(f"Instance was {action}ed successfully ...")
|
||||
|
||||
log_info("✅ Instances page tests finished successfully")
|
||||
except SystemExit as e:
|
||||
|
|
|
|||
Loading…
Reference in a new issue