From ce3eb320768e8f960708ca8aab28d304bed33f50 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 22 Oct 2023 13:35:01 +0300 Subject: [PATCH] un-mock test, use SELENIUM_IMAGE --- .gitlab-ci.yml | 6 ++-- tests/integration/selenium_test.py | 47 ++++++++++++++++++++++++++++++ tests/selenium/test.py | 25 ---------------- 3 files changed, 50 insertions(+), 28 deletions(-) create mode 100644 tests/integration/selenium_test.py delete mode 100644 tests/selenium/test.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0c9bd93a6..cee85ba28 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -60,13 +60,13 @@ phpdoc: - rsync -av -e 'ssh -o StrictHostKeyChecking=no' phpdoc/ ${PHPDOC_DEPLOY_HOST}:phpdoc/ integration-test: + image: ${SELENIUM_IMAGE} variables: TEST_HELM_REPO: https://gitlab.tt-rss.org/tt-rss/helm-charts/tt-rss + SELENIUM_GRID_ENDPOINT: http://selenium-hub.selenium-grid.svc.cluster.local:4444/wd/hub extends: .integration-test script: - - apk add py3-pip - - pip3 install selenium - - python3 tests/selenium/test.py + - python3 tests/integration/selenium_test.py rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH diff --git a/tests/integration/selenium_test.py b/tests/integration/selenium_test.py new file mode 100644 index 000000000..8aef738c2 --- /dev/null +++ b/tests/integration/selenium_test.py @@ -0,0 +1,47 @@ +#!/usr/bin/python3 + +import os +import traceback +import time + +from selenium import webdriver +from selenium.webdriver.common.by import By + +CI_COMMIT_SHORT_SHA = os.getenv("CI_COMMIT_SHORT_SHA") +SELENIUM_GRID_ENDPOINT = os.getenv("SELENIUM_GRID_ENDPOINT") + +if not CI_COMMIT_SHORT_SHA or not SELENIUM_GRID_ENDPOINT: + print("both CI_COMMIT_SHORT_SHA snd SELENIUM_GRID_ENDPOINT env vars should be defined") + exit(1) + +driver = webdriver.Remote(command_executor=SELENIUM_GRID_ENDPOINT, options=webdriver.ChromeOptions()) + +app_url = f"http://tt-rss-{CI_COMMIT_SHORT_SHA}-app.gitlab-fakecake.svc.cluster.local/tt-rss" + +print(f"requesting base url: {app_url}") + +try: + driver.get(app_url) + + print("filling in login information...") + + for name in ["login", "password"]: + field = driver.find_element(by=By.CSS_SELECTOR, value=f"input[name='{name}']") + field.clear() + field.send_keys("test") + + print("logging in...") + + login_button = driver.find_element(by=By.CSS_SELECTOR, value="#dijit_form_Button_0_label") + login_button.click() + + print("checking for feedTree...") + + assert driver.find_element(by=By.CSS_SELECTOR, value="#feedTree") + + print("all done.") + +except Exception: + traceback.print_exc() +finally: + driver.quit() diff --git a/tests/selenium/test.py b/tests/selenium/test.py deleted file mode 100644 index 6280b58b8..000000000 --- a/tests/selenium/test.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/python3 - -import os -from selenium import webdriver - -CI_COMMIT_SHORT_SHA = os.getenv("CI_COMMIT_SHORT_SHA") - -if not CI_COMMIT_SHORT_SHA: - print("CI_COMMIT_SHORT_SHA env var should be defined") - exit(1) - -options = webdriver.ChromeOptions() - -driver = webdriver.Remote( - command_executor='http://selenium-hub.selenium-grid.svc.cluster.local:4444/wd/hub', - options=options -) - -app_url = f"http://tt-rss-{CI_COMMIT_SHORT_SHA}-app.gitlab-fakecake.svc.cluster.local/tt-rss" - -print(f"base url = {app_url}") - -driver.get(app_url) -print(driver.page_source) -driver.quit()