mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
tests - fix misc ready check when using https and add ready checks for linux ui
This commit is contained in:
parent
d4a2ba5fc8
commit
86875f4863
4 changed files with 186 additions and 132 deletions
|
|
@ -8,12 +8,16 @@ from time import sleep
|
|||
from traceback import format_exc
|
||||
|
||||
try:
|
||||
ssl_generated = getenv("GENERATE_SELF_SIGNED_SSL", "no") == "yes"
|
||||
disabled_default_server = getenv("DISABLE_DEFAULT_SERVER", "no") == "yes"
|
||||
deny_http_status = getenv("DENY_HTTP_STATUS", "403")
|
||||
listen_http = getenv("LISTEN_HTTP", "yes") == "yes"
|
||||
|
||||
ready = False
|
||||
retries = 0
|
||||
while not ready:
|
||||
with suppress(RequestException):
|
||||
resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"})
|
||||
resp = get(f"http{'s' if ssl_generated else ''}://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False)
|
||||
status_code = resp.status_code
|
||||
text = resp.text
|
||||
|
||||
|
|
@ -31,11 +35,6 @@ try:
|
|||
print("⚠️ Waiting for the service to be ready, retrying in 5s ...", flush=True)
|
||||
sleep(5)
|
||||
|
||||
ssl_generated = getenv("GENERATE_SELF_SIGNED_SSL", "no") == "yes"
|
||||
disabled_default_server = getenv("DISABLE_DEFAULT_SERVER", "no") == "yes"
|
||||
deny_http_status = getenv("DENY_HTTP_STATUS", "403")
|
||||
listen_http = getenv("LISTEN_HTTP", "yes") == "yes"
|
||||
|
||||
error = False
|
||||
|
||||
print(
|
||||
|
|
|
|||
297
tests/ui/main.py
297
tests/ui/main.py
|
|
@ -297,22 +297,27 @@ with webdriver.Firefox(options=firefox_options) as driver:
|
|||
print("WARNING: message list doesn't contain the expected message or is empty, retrying...")
|
||||
|
||||
if TEST_TYPE == "linux":
|
||||
ready = False
|
||||
retries = 0
|
||||
while (
|
||||
b"BunkerWeb is ready"
|
||||
not in run(
|
||||
["sudo", "tail", "-n", "1", "/var/log/bunkerweb/error.log"],
|
||||
stdout=PIPE,
|
||||
check=True,
|
||||
).stdout
|
||||
) and retries < 10:
|
||||
retries += 1
|
||||
print("Waiting for BunkerWeb to be ready, retrying in 5s ...")
|
||||
sleep(5)
|
||||
while not ready:
|
||||
with suppress(RequestException):
|
||||
resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False)
|
||||
status_code = resp.status_code
|
||||
text = resp.text
|
||||
|
||||
if retries >= 10:
|
||||
print("BunkerWeb took too long to be ready, exiting ...", flush=True)
|
||||
exit(1)
|
||||
if resp.status_code >= 500:
|
||||
print("❌ An error occurred with the server, exiting ...", flush=True)
|
||||
exit(1)
|
||||
|
||||
ready = status_code < 400 and text == "ready"
|
||||
|
||||
if retries > 10:
|
||||
print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True)
|
||||
exit(1)
|
||||
elif not ready:
|
||||
retries += 1
|
||||
print("⚠️ Waiting for BunkerWeb to be ready, retrying in 5s ...", flush=True)
|
||||
sleep(5)
|
||||
|
||||
print("Trying global config page ...")
|
||||
|
||||
|
|
@ -413,22 +418,27 @@ with webdriver.Firefox(options=firefox_options) as driver:
|
|||
)
|
||||
|
||||
if TEST_TYPE == "linux":
|
||||
ready = False
|
||||
retries = 0
|
||||
while (
|
||||
b"BunkerWeb is ready"
|
||||
not in run(
|
||||
["sudo", "tail", "-n", "1", "/var/log/bunkerweb/error.log"],
|
||||
stdout=PIPE,
|
||||
check=True,
|
||||
).stdout
|
||||
) and retries < 10:
|
||||
retries += 1
|
||||
print("Waiting for BunkerWeb to be ready, retrying in 5s ...")
|
||||
sleep(5)
|
||||
while not ready:
|
||||
with suppress(RequestException):
|
||||
resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False)
|
||||
status_code = resp.status_code
|
||||
text = resp.text
|
||||
|
||||
if retries >= 10:
|
||||
print("BunkerWeb took too long to be ready, exiting ...", flush=True)
|
||||
exit(1)
|
||||
if resp.status_code >= 500:
|
||||
print("❌ An error occurred with the server, exiting ...", flush=True)
|
||||
exit(1)
|
||||
|
||||
ready = status_code < 400 and text == "ready"
|
||||
|
||||
if retries > 10:
|
||||
print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True)
|
||||
exit(1)
|
||||
elif not ready:
|
||||
retries += 1
|
||||
print("⚠️ Waiting for BunkerWeb to be ready, retrying in 5s ...", flush=True)
|
||||
sleep(5)
|
||||
|
||||
input_worker = safe_get_element(driver, By.ID, "WORKER_RLIMIT_NOFILE")
|
||||
|
||||
|
|
@ -577,22 +587,27 @@ with webdriver.Firefox(options=firefox_options) as driver:
|
|||
)
|
||||
|
||||
if TEST_TYPE == "linux":
|
||||
ready = False
|
||||
retries = 0
|
||||
while (
|
||||
b"BunkerWeb is ready"
|
||||
not in run(
|
||||
["sudo", "tail", "-n", "1", "/var/log/bunkerweb/error.log"],
|
||||
stdout=PIPE,
|
||||
check=True,
|
||||
).stdout
|
||||
) and retries < 10:
|
||||
retries += 1
|
||||
print("Waiting for BunkerWeb to be ready, retrying in 5s ...")
|
||||
sleep(5)
|
||||
while not ready:
|
||||
with suppress(RequestException):
|
||||
resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False)
|
||||
status_code = resp.status_code
|
||||
text = resp.text
|
||||
|
||||
if retries >= 10:
|
||||
print("BunkerWeb took too long to be ready, exiting ...", flush=True)
|
||||
exit(1)
|
||||
if resp.status_code >= 500:
|
||||
print("❌ An error occurred with the server, exiting ...", flush=True)
|
||||
exit(1)
|
||||
|
||||
ready = status_code < 400 and text == "ready"
|
||||
|
||||
if retries > 10:
|
||||
print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True)
|
||||
exit(1)
|
||||
elif not ready:
|
||||
retries += 1
|
||||
print("⚠️ Waiting for BunkerWeb to be ready, retrying in 5s ...", flush=True)
|
||||
sleep(5)
|
||||
|
||||
print(
|
||||
"The page reloaded successfully, checking if the setting has been updated ...",
|
||||
|
|
@ -656,22 +671,27 @@ with webdriver.Firefox(options=firefox_options) as driver:
|
|||
)
|
||||
|
||||
if TEST_TYPE == "linux":
|
||||
ready = False
|
||||
retries = 0
|
||||
while (
|
||||
b"BunkerWeb is ready"
|
||||
not in run(
|
||||
["sudo", "tail", "-n", "1", "/var/log/bunkerweb/error.log"],
|
||||
stdout=PIPE,
|
||||
check=True,
|
||||
).stdout
|
||||
) and retries < 10:
|
||||
retries += 1
|
||||
print("Waiting for BunkerWeb to be ready, retrying in 5s ...")
|
||||
sleep(5)
|
||||
while not ready:
|
||||
with suppress(RequestException):
|
||||
resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False)
|
||||
status_code = resp.status_code
|
||||
text = resp.text
|
||||
|
||||
if retries >= 10:
|
||||
print("BunkerWeb took too long to be ready, exiting ...", flush=True)
|
||||
exit(1)
|
||||
if resp.status_code >= 500:
|
||||
print("❌ An error occurred with the server, exiting ...", flush=True)
|
||||
exit(1)
|
||||
|
||||
ready = status_code < 400 and text == "ready"
|
||||
|
||||
if retries > 10:
|
||||
print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True)
|
||||
exit(1)
|
||||
elif not ready:
|
||||
retries += 1
|
||||
print("⚠️ Waiting for BunkerWeb to be ready, retrying in 5s ...", flush=True)
|
||||
sleep(5)
|
||||
|
||||
try:
|
||||
services = safe_get_element(
|
||||
|
|
@ -773,22 +793,27 @@ with webdriver.Firefox(options=firefox_options) as driver:
|
|||
)
|
||||
|
||||
if TEST_TYPE == "linux":
|
||||
ready = False
|
||||
retries = 0
|
||||
while (
|
||||
b"BunkerWeb is ready"
|
||||
not in run(
|
||||
["sudo", "tail", "-n", "1", "/var/log/bunkerweb/error.log"],
|
||||
stdout=PIPE,
|
||||
check=True,
|
||||
).stdout
|
||||
) and retries < 10:
|
||||
retries += 1
|
||||
print("Waiting for BunkerWeb to be ready, retrying in 5s ...")
|
||||
sleep(5)
|
||||
while not ready:
|
||||
with suppress(RequestException):
|
||||
resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False)
|
||||
status_code = resp.status_code
|
||||
text = resp.text
|
||||
|
||||
if retries >= 10:
|
||||
print("BunkerWeb took too long to be ready, exiting ...", flush=True)
|
||||
exit(1)
|
||||
if resp.status_code >= 500:
|
||||
print("❌ An error occurred with the server, exiting ...", flush=True)
|
||||
exit(1)
|
||||
|
||||
ready = status_code < 400 and text == "ready"
|
||||
|
||||
if retries > 10:
|
||||
print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True)
|
||||
exit(1)
|
||||
elif not ready:
|
||||
retries += 1
|
||||
print("⚠️ Waiting for BunkerWeb to be ready, retrying in 5s ...", flush=True)
|
||||
sleep(5)
|
||||
|
||||
assert_alert_message(driver, "has been deleted.")
|
||||
|
||||
|
|
@ -856,22 +881,27 @@ location /hello {
|
|||
)
|
||||
|
||||
if TEST_TYPE == "linux":
|
||||
ready = False
|
||||
retries = 0
|
||||
while (
|
||||
b"BunkerWeb is ready"
|
||||
not in run(
|
||||
["sudo", "tail", "-n", "1", "/var/log/bunkerweb/error.log"],
|
||||
stdout=PIPE,
|
||||
check=True,
|
||||
).stdout
|
||||
) and retries < 10:
|
||||
retries += 1
|
||||
print("Waiting for BunkerWeb to be ready, retrying in 5s ...")
|
||||
sleep(5)
|
||||
while not ready:
|
||||
with suppress(RequestException):
|
||||
resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False)
|
||||
status_code = resp.status_code
|
||||
text = resp.text
|
||||
|
||||
if retries >= 10:
|
||||
print("BunkerWeb took too long to be ready, exiting ...", flush=True)
|
||||
exit(1)
|
||||
if resp.status_code >= 500:
|
||||
print("❌ An error occurred with the server, exiting ...", flush=True)
|
||||
exit(1)
|
||||
|
||||
ready = status_code < 400 and text == "ready"
|
||||
|
||||
if retries > 10:
|
||||
print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True)
|
||||
exit(1)
|
||||
elif not ready:
|
||||
retries += 1
|
||||
print("⚠️ Waiting for BunkerWeb to be ready, retrying in 5s ...", flush=True)
|
||||
sleep(5)
|
||||
|
||||
assert_alert_message(driver, "was successfully created")
|
||||
|
||||
|
|
@ -916,22 +946,27 @@ location /hello {
|
|||
)
|
||||
|
||||
if TEST_TYPE == "linux":
|
||||
ready = False
|
||||
retries = 0
|
||||
while (
|
||||
b"BunkerWeb is ready"
|
||||
not in run(
|
||||
["sudo", "tail", "-n", "1", "/var/log/bunkerweb/error.log"],
|
||||
stdout=PIPE,
|
||||
check=True,
|
||||
).stdout
|
||||
) and retries < 10:
|
||||
retries += 1
|
||||
print("Waiting for BunkerWeb to be ready, retrying in 5s ...")
|
||||
sleep(5)
|
||||
while not ready:
|
||||
with suppress(RequestException):
|
||||
resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False)
|
||||
status_code = resp.status_code
|
||||
text = resp.text
|
||||
|
||||
if retries >= 10:
|
||||
print("BunkerWeb took too long to be ready, exiting ...", flush=True)
|
||||
exit(1)
|
||||
if resp.status_code >= 500:
|
||||
print("❌ An error occurred with the server, exiting ...", flush=True)
|
||||
exit(1)
|
||||
|
||||
ready = status_code < 400 and text == "ready"
|
||||
|
||||
if retries > 10:
|
||||
print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True)
|
||||
exit(1)
|
||||
elif not ready:
|
||||
retries += 1
|
||||
print("⚠️ Waiting for BunkerWeb to be ready, retrying in 5s ...", flush=True)
|
||||
sleep(5)
|
||||
|
||||
assert_alert_message(driver, "was successfully deleted")
|
||||
|
||||
|
|
@ -996,22 +1031,27 @@ location /hello {
|
|||
)
|
||||
|
||||
if TEST_TYPE == "linux":
|
||||
ready = False
|
||||
retries = 0
|
||||
while (
|
||||
b"BunkerWeb is ready"
|
||||
not in run(
|
||||
["sudo", "tail", "-n", "1", "/var/log/bunkerweb/error.log"],
|
||||
stdout=PIPE,
|
||||
check=True,
|
||||
).stdout
|
||||
) and retries < 10:
|
||||
retries += 1
|
||||
print("Waiting for BunkerWeb to be ready, retrying in 5s ...")
|
||||
sleep(5)
|
||||
while not ready:
|
||||
with suppress(RequestException):
|
||||
resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False)
|
||||
status_code = resp.status_code
|
||||
text = resp.text
|
||||
|
||||
if retries >= 10:
|
||||
print("BunkerWeb took too long to be ready, exiting ...", flush=True)
|
||||
exit(1)
|
||||
if resp.status_code >= 500:
|
||||
print("❌ An error occurred with the server, exiting ...", flush=True)
|
||||
exit(1)
|
||||
|
||||
ready = status_code < 400 and text == "ready"
|
||||
|
||||
if retries > 10:
|
||||
print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True)
|
||||
exit(1)
|
||||
elif not ready:
|
||||
retries += 1
|
||||
print("⚠️ Waiting for BunkerWeb to be ready, retrying in 5s ...", flush=True)
|
||||
sleep(5)
|
||||
|
||||
external_plugins = safe_get_element(
|
||||
driver,
|
||||
|
|
@ -1040,22 +1080,27 @@ location /hello {
|
|||
)
|
||||
|
||||
if TEST_TYPE == "linux":
|
||||
ready = False
|
||||
retries = 0
|
||||
while (
|
||||
b"BunkerWeb is ready"
|
||||
not in run(
|
||||
["sudo", "tail", "-n", "1", "/var/log/bunkerweb/error.log"],
|
||||
stdout=PIPE,
|
||||
check=True,
|
||||
).stdout
|
||||
) and retries < 10:
|
||||
retries += 1
|
||||
print("Waiting for BunkerWeb to be ready, retrying in 5s ...")
|
||||
sleep(5)
|
||||
while not ready:
|
||||
with suppress(RequestException):
|
||||
resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False)
|
||||
status_code = resp.status_code
|
||||
text = resp.text
|
||||
|
||||
if retries >= 10:
|
||||
print("BunkerWeb took too long to be ready, exiting ...", flush=True)
|
||||
exit(1)
|
||||
if resp.status_code >= 500:
|
||||
print("❌ An error occurred with the server, exiting ...", flush=True)
|
||||
exit(1)
|
||||
|
||||
ready = status_code < 400 and text == "ready"
|
||||
|
||||
if retries > 10:
|
||||
print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True)
|
||||
exit(1)
|
||||
elif not ready:
|
||||
retries += 1
|
||||
print("⚠️ Waiting for BunkerWeb to be ready, retrying in 5s ...", flush=True)
|
||||
sleep(5)
|
||||
|
||||
with suppress(TimeoutException):
|
||||
title = WebDriverWait(driver, 2).until(
|
||||
|
|
|
|||
8
tests/ui/ready.conf
Normal file
8
tests/ui/ready.conf
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
location /ready {
|
||||
default_type 'text/plain';
|
||||
rewrite_by_lua_block {
|
||||
ngx.print('ready')
|
||||
ngx.flush(true)
|
||||
ngx.exit(ngx.HTTP_OK)
|
||||
}
|
||||
}
|
||||
|
|
@ -66,6 +66,8 @@ else
|
|||
sudo sed -i "/--bind \"127.0.0.1:7000\" &/c\ --bind \"127.0.0.1:7000\" --log-level debug &" /usr/share/bunkerweb/scripts/bunkerweb-ui.sh
|
||||
sudo mkdir /var/www/html/app1.example.com
|
||||
sudo touch /var/www/html/app1.example.com/index.html
|
||||
sudo find /etc/bunkerweb/configs/ -type f -exec rm -f {} \;
|
||||
sudo cp ready.conf /etc/bunkerweb/configs/server-http
|
||||
export TEST_TYPE="linux"
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue