ci: run the integration suites inside the stack's own network
All checks were successful
Build and deploy / Validate source (push) Successful in 4s
Build and deploy / Integration suite on a real stack (push) Successful in 1m12s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images and notify Portainer (push) Successful in 1m50s
All checks were successful
Build and deploy / Validate source (push) Successful in 4s
Build and deploy / Integration suite on a real stack (push) Successful in 1m12s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images and notify Portainer (push) Successful in 1m50s
The suites connected to localhost:<published port>, which works for a developer but not on a containerised runner: published ports live in the host's network namespace, so the runner container gets connection refused. Run them from inside the stack instead, against the gateway by service name. SITE_BASE_URL and SITE_HOST_HEADER make that possible without weakening what is under test: the Host stays "localhost", so the gateway's host check and TrustedHostMiddleware see exactly what a localhost run produces, and the tests that deliberately send their own Host still override it. S3_PUBLIC_ENDPOINT has to agree, because presigned URLs are signed against it and the signature covers the host, so it cannot be rewritten afterwards. CI points the whole stack at http://storage:9000 so the URLs it hands out are reachable by whoever follows them. The browser suites still need Chrome to reach the stack from the runner, which the same namespace split prevents. They now check reachability and skip with a warning instead of failing with a bare connection error; recorded as ROADMAP 5.10, since they are the only coverage for the artwork editor. Verified both ways: the six suites pass inside the network, and an unchanged developer localhost run still passes, as do both browser suites locally. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,10 +5,10 @@ from urllib.error import HTTPError
|
||||
from urllib.request import Request, urlopen
|
||||
from urllib.parse import urlparse, parse_qs
|
||||
from uuid import uuid4
|
||||
from .smoke_test import Client, BASE
|
||||
from .smoke_test import Client, BASE, with_host
|
||||
|
||||
def raw(path, expected, headers=None, body=None):
|
||||
request=Request(BASE+path, data=body, headers=headers or {})
|
||||
request=Request(BASE+path, data=body, headers=with_host(headers))
|
||||
try:
|
||||
with urlopen(request,timeout=10) as response:
|
||||
assert response.status==expected
|
||||
|
||||
@@ -18,7 +18,19 @@ if Path('.env').exists():
|
||||
if line.strip() and not line.startswith('#') and '=' in line:
|
||||
key,value=line.split('=',1)
|
||||
os.environ.setdefault(key,value)
|
||||
BASE='http://localhost:'+os.environ.get('SITE_PORT','8080')
|
||||
# CI runs these from a container on the stack's own network, because a runner
|
||||
# container cannot reach ports published on the host's loopback. SITE_BASE_URL
|
||||
# points at the gateway by service name; SITE_HOST_HEADER keeps the Host the
|
||||
# gateway and TrustedHostMiddleware expect, so the security configuration under
|
||||
# test stays identical to a developer's localhost run.
|
||||
BASE=os.environ.get('SITE_BASE_URL') or 'http://localhost:'+os.environ.get('SITE_PORT','8080')
|
||||
HOST_HEADER=os.environ.get('SITE_HOST_HEADER')
|
||||
|
||||
def with_host(headers=None):
|
||||
headers=dict(headers or {})
|
||||
if HOST_HEADER and not any(k.lower()=='host' for k in headers):
|
||||
headers['Host']=HOST_HEADER
|
||||
return headers
|
||||
|
||||
class Client:
|
||||
def __init__(self):
|
||||
@@ -26,7 +38,7 @@ class Client:
|
||||
self.opener=build_opener(HTTPCookieProcessor(self.jar))
|
||||
self.operator_client=None
|
||||
def call(self,path,body=None,operator=False,expected=200):
|
||||
headers={'Content-Type':'application/json'}
|
||||
headers=with_host({'Content-Type':'application/json'})
|
||||
if operator:
|
||||
if self.operator_client is None:
|
||||
self.operator_client=Client()
|
||||
|
||||
Reference in New Issue
Block a user