stabilize dry-run playwright integration
Agent-Logs-Url: https://github.com/rudolf1/brencher/sessions/d019d010-3ca0-4a73-8826-620eef58edab Co-authored-by: rudolf1 <5525769+rudolf1@users.noreply.github.com>
This commit is contained in:
co-authored by
rudolf1
parent
b2782ee220
commit
ab01fca841
+3
-9
@@ -1,14 +1,10 @@
|
||||
FROM nginx:1.27-alpine
|
||||
|
||||
COPY .git /tmp/repo/.git
|
||||
|
||||
# Configure nginx to listen on 5001 to match container port expectations.
|
||||
RUN sed -i 's/listen 80;/listen 5001;/' /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Build a custom landing page directly in the image and inject git revision.
|
||||
# Build a custom landing page directly in the image.
|
||||
RUN set -eux; \
|
||||
apk add --no-cache --virtual .git-deps git; \
|
||||
GIT_REVISION="$(git --git-dir=/tmp/repo/.git rev-parse --short HEAD 2>/dev/null || echo unknown)"; \
|
||||
{ \
|
||||
echo '<!doctype html>'; \
|
||||
echo '<html lang="en">'; \
|
||||
@@ -21,11 +17,9 @@ RUN set -eux; \
|
||||
echo ' <h1>Nginx Is Running</h1>'; \
|
||||
echo ' <p>Custom landing page for the Brencher test app container.</p>'; \
|
||||
echo ' <p>Port: 5001</p>'; \
|
||||
echo " <p>Git revision: ${GIT_REVISION}</p>"; \
|
||||
echo ' <p>Git revision: unknown</p>'; \
|
||||
echo '</body>'; \
|
||||
echo '</html>'; \
|
||||
} > /usr/share/nginx/html/index.html; \
|
||||
rm -rf /tmp/repo/.git; \
|
||||
apk del .git-deps
|
||||
} > /usr/share/nginx/html/index.html
|
||||
|
||||
EXPOSE 5001
|
||||
|
||||
@@ -1,8 +1,21 @@
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
from enironment import Environment
|
||||
from steps.docker_plain import DockerImageBuild, DockerContainerCheck, DockerContainerDeploy
|
||||
from steps.git import GitClone, CheckoutMerged, GitUnmerge
|
||||
from steps.shared_state import SharedStateHolderInMemory
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[2]
|
||||
CURRENT_BRANCH = subprocess.check_output(
|
||||
["git", "-C", str(REPO_ROOT), "rev-parse", "--abbrev-ref", "HEAD"],
|
||||
text=True,
|
||||
).strip()
|
||||
CURRENT_COMMIT = subprocess.check_output(
|
||||
["git", "-C", str(REPO_ROOT), "rev-parse", "HEAD"],
|
||||
text=True,
|
||||
).strip()
|
||||
|
||||
clone = GitClone(url="https://github.com/rudolf1/brencher.git")
|
||||
|
||||
container_check = DockerContainerCheck(
|
||||
|
||||
@@ -38,7 +38,7 @@ class TestDryRunPlaywright:
|
||||
def test_dry_run_prevents_deploy_until_disabled(self, eventually: EventuallyFn) -> None:
|
||||
# Start app with nginx_local1 with main branch pre-selected and dry mode on.
|
||||
env = nginx.test_local1
|
||||
env.state.set_branches([("test/main", "HEAD")])
|
||||
env.state.set_branches([(nginx.CURRENT_BRANCH, nginx.CURRENT_COMMIT)])
|
||||
env.state.set_dry(True)
|
||||
app = App({env.id: env})
|
||||
server_thread = threading.Thread(target=lambda: app.runWeb(APP_PORT), daemon=True)
|
||||
@@ -69,7 +69,6 @@ class TestDryRunPlaywright:
|
||||
page.verify_dry_run_on()
|
||||
page.set_dry_run_off()
|
||||
page.verify_dry_run_off()
|
||||
page.click_refresh() # TODO Remove it
|
||||
|
||||
# Wait for pipeline to re-run and actually deploy the container
|
||||
eventually(
|
||||
@@ -77,11 +76,16 @@ class TestDryRunPlaywright:
|
||||
p for p in s[env.id]["pipeline"] if p["name"] =="SharedStateHolderInMemory"
|
||||
)["status"]['dry'], False, "Pipeline step status is not 'running'")),
|
||||
)
|
||||
# Wait for pipeline to re-run and actually deploy the container
|
||||
|
||||
# Wait for the real container to be created and started.
|
||||
eventually(
|
||||
lambda: check_state(APP_URL, lambda s: assert_equal({p["name"] for p in s[env.id]["pipeline"] if bool(p['is_running'])}, set(), "Pipeline still running")),
|
||||
timeout=20,
|
||||
interval=1.0,
|
||||
lambda: assert_equal(
|
||||
{container.status for container in docker_client.containers.list(filters={"name": CONTAINER_NAME}, all=True)},
|
||||
{"running"},
|
||||
"Container should exist and be running after deploy",
|
||||
),
|
||||
timeout=180,
|
||||
interval=5.0,
|
||||
)
|
||||
# page.verify_pipeline_step_status("DockerContainerDeploy", "running")
|
||||
logger.info("Container deployed and running after dry run disabled")
|
||||
@@ -92,4 +96,6 @@ class TestDryRunPlaywright:
|
||||
assert containers[0].status == "running"
|
||||
finally:
|
||||
app.stop()
|
||||
server_thread.join(timeout=10)
|
||||
server_thread.join(timeout=30)
|
||||
if server_thread.is_alive():
|
||||
logger.warning("App server thread did not stop within 30 seconds")
|
||||
|
||||
Reference in New Issue
Block a user