From e325bd6bcb9402237b7361d14a87aa02a976782b Mon Sep 17 00:00:00 2001 From: "Ritchie, Frank (fr801x)" Date: Thu, 24 Aug 2023 14:59:28 -0400 Subject: [PATCH] Make selenium tests backwards compatible Make using pre-selenium v4 syntax an option. See: https: //review.opendev.org/c/openstack/openstack-helm-infra/+/883894/5/nagios/templates/bin/_selenium-tests.py.tpl Change-Id: I982029e620d944458ac0a4670189534023a6f972 --- nagios/Chart.yaml | 2 +- nagios/templates/bin/_selenium-tests.py.tpl | 10 ++++++++++ nagios/values.yaml | 3 +++ releasenotes/notes/nagios.yaml | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/nagios/Chart.yaml b/nagios/Chart.yaml index 05203bd6d..3da34708a 100644 --- a/nagios/Chart.yaml +++ b/nagios/Chart.yaml @@ -15,7 +15,7 @@ apiVersion: v1 appVersion: v1.0.0 description: OpenStack-Helm Nagios name: nagios -version: 0.1.8 +version: 0.1.9 home: https://www.nagios.org sources: - https://opendev.org/openstack/openstack-helm-addons diff --git a/nagios/templates/bin/_selenium-tests.py.tpl b/nagios/templates/bin/_selenium-tests.py.tpl index 2acd83fbf..105d2db2a 100644 --- a/nagios/templates/bin/_selenium-tests.py.tpl +++ b/nagios/templates/bin/_selenium-tests.py.tpl @@ -22,7 +22,9 @@ from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.chrome.options import Options +{{- if .Values.selenium_v4 }} from selenium.webdriver.chrome.service import Service +{{- end }} from selenium.common.exceptions import TimeoutException from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import ScreenshotException @@ -51,7 +53,11 @@ def get_variable(env_var): def click_link_by_name(link_name): try: logger.info("Clicking '{}' link".format(link_name)) +{{- if .Values.selenium_v4 }} link = browser.find_element(By.LINK_TEXT, link_name) +{{- else }} + link = browser.find_element_by_text_link(link_name) +{{- end }} link.click() except NoSuchElementException: logger.error("Failed clicking '{}' link".format(link_name)) @@ -80,8 +86,12 @@ options.add_argument('--headless') options.add_argument('--no-sandbox') options.add_argument('--window-size=1920x1080') +{{- if .Values.selenium_v4 }} service = Service(executable_path=chrome_driver) browser = webdriver.Chrome(service=service, options=options) +{{- else }} +browser = webdriver.Chrome(chrome_driver, chrome_options=options) +{{- end }} try: logger.info('Attempting to connect to Nagios') diff --git a/nagios/values.yaml b/nagios/values.yaml index 5aa4de9c1..c79ca9ffc 100644 --- a/nagios/values.yaml +++ b/nagios/values.yaml @@ -29,6 +29,9 @@ images: - dep_check - image_repo_sync +# Use selenium v4 syntax +selenium_v4: true + labels: nagios: node_selector_key: openstack-control-plane diff --git a/releasenotes/notes/nagios.yaml b/releasenotes/notes/nagios.yaml index d6b6b8dc7..2bb86d921 100644 --- a/releasenotes/notes/nagios.yaml +++ b/releasenotes/notes/nagios.yaml @@ -9,4 +9,5 @@ nagios: - 0.1.6 Added OCI registry authentication - 0.1.7 Upgrade osh-selenium image to latest-ubuntu_focal - 0.1.8 Use helm toolkit for readiness probes + - 0.1.9 Make using selenium v4 syntax optional ...