From 98b4c06314ebde6ec22d2d9d0c98ef12d691cd5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Diot?= Date: Tue, 2 Jan 2024 11:22:08 +0000 Subject: [PATCH] Fix problems with ui tests and the ui.env file for Linux and the IP address of the container for DOcker --- .github/workflows/tests-ui-linux.yml | 4 ++-- tests/ui/main.py | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests-ui-linux.yml b/.github/workflows/tests-ui-linux.yml index d1fa6dfee9..3d1b16a620 100644 --- a/.github/workflows/tests-ui-linux.yml +++ b/.github/workflows/tests-ui-linux.yml @@ -87,8 +87,8 @@ jobs: echo "DATASTORE_MEMORY_SIZE=384m" | sudo tee -a /etc/bunkerweb/variables.env echo "UI_HOST=http://127.0.0.1:7000" | sudo tee -a /etc/bunkerweb/variables.env - sudo chown nginx:nginx /etc/bunkerweb/variables.env /etc/bunkerweb/ui.env - sudo chmod 777 /etc/bunkerweb/variables.env /etc/bunkerweb/ui.env + sudo chown nginx:nginx /etc/bunkerweb/variables.env + sudo chmod 777 /etc/bunkerweb/variables.env - name: Run tests run: | cd ./tests/ui diff --git a/tests/ui/main.py b/tests/ui/main.py index 48fc8a9b44..2dfd6dddb2 100644 --- a/tests/ui/main.py +++ b/tests/ui/main.py @@ -1,7 +1,7 @@ from contextlib import suppress from datetime import datetime, timedelta from functools import partial -from os import getenv, listdir +from os import getenv, listdir, sep from os.path import join from pathlib import Path from time import sleep @@ -20,11 +20,20 @@ from selenium.webdriver.support import expected_conditions as EC from selenium.common.exceptions import ElementClickInterceptedException, TimeoutException, WebDriverException +default_server = "127.0.0.1" + +integration_path = Path(sep, "usr", "share", "bunkerweb", "INTEGRATION") +os_release_path = Path(sep, "etc", "os-release") +if getenv("KUBERNETES_MODE", "no").lower() == "yes" or getenv("SWARM_MODE", "no").lower() == "yes" or getenv("AUTOCONF_MODE", "no").lower() == "yes": + default_server = "192.168.0.2" +elif os_release_path.is_file() and "Alpine" in os_release_path.read_text(encoding="utf-8"): + default_server = "192.168.0.2" + ready = False retries = 0 while not ready: with suppress(RequestException): - status_code = get("http://127.0.0.1/setup").status_code + status_code = get(f"http://{default_server}/setup").status_code if status_code > 500 and status_code != 502: print("An error occurred with the server, exiting ...", flush=True) @@ -179,9 +188,9 @@ def access_page( driver.maximize_window() driver_wait = WebDriverWait(driver, 60) - print("Navigating to http://127.0.0.1/setup ...", flush=True) + print(f"Navigating to http://{default_server}/setup ...", flush=True) - driver.get("http://127.0.0.1/setup") + driver.get(f"http://{default_server}/setup") ### WIZARD PAGE