Skip to content

Commit

Permalink
Fix problems with ui tests and the ui.env file for Linux and the IP a…
Browse files Browse the repository at this point in the history
…ddress of the container for DOcker
  • Loading branch information
TheophileDiot committed Jan 2, 2024
1 parent 9356509 commit 98b4c06
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests-ui-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 13 additions & 4 deletions tests/ui/main.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 98b4c06

Please sign in to comment.