Skip to content

Commit 76257bd

Browse files
Merge deployed browser identity fix (#110)
2 parents 9b2629a + 3584c30 commit 76257bd

3 files changed

Lines changed: 49 additions & 1 deletion

File tree

_docs/compatibility/development-terminology-allowlist.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188
},
189189
{
190190
"path": "core/tests/test_web_runtime_coherence.py",
191-
"sha256": "86df3fa207903358007ca37a4278dda0daea5c632bc7142da1550e46c72095a7",
191+
"sha256": "323e7093630ecfa0109d6a605328f5f4497a49203b408983ff69fd9d9c9eee81",
192192
"class": "legacy_contract_test",
193193
"reason": "Web runtime coherence tests exercise the exact development service, task, target, and repository identifiers.",
194194
"follow_up": "#94",

core/tests/test_web_runtime_coherence.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from django.test import SimpleTestCase
1212

13+
from core.runtime_identity import read_runtime_identity
1314
from deploy.aws_gateway import AwsReleaseConfig, AwsReleaseGateway
1415
from deploy.contracts import (
1516
ReleaseContractError,
@@ -292,6 +293,50 @@ def observed_binding() -> WebRuntimeBinding:
292293

293294

294295
class WebRuntimeCoherenceTests(SimpleTestCase):
296+
def test_deployed_browser_smoke_receives_complete_runtime_identity(self) -> None:
297+
gateway = AwsReleaseGateway.__new__(AwsReleaseGateway)
298+
gateway.config = config()
299+
observed: dict[str, Any] = {}
300+
301+
def collect_subprocess(
302+
command: list[str],
303+
*,
304+
check: bool,
305+
env: dict[str, str],
306+
timeout: int,
307+
) -> None:
308+
observed.update(
309+
command=command,
310+
check=check,
311+
env=env,
312+
timeout=timeout,
313+
runtime_identity=read_runtime_identity(env),
314+
)
315+
316+
workflow_environment = {
317+
"VERSION": VERSION,
318+
"IMAGE_DIGEST": IMAGE_DIGEST,
319+
"RELEASE_SHA": SOURCE_SHA,
320+
}
321+
with (
322+
patch.dict("os.environ", workflow_environment, clear=True),
323+
patch("deploy.aws_gateway.run_http_smoke"),
324+
patch("deploy.aws_gateway.subprocess.run", side_effect=collect_subprocess),
325+
):
326+
gateway.run_deployed_smoke(identity())
327+
328+
runtime_identity = observed["runtime_identity"]
329+
self.assertEqual(runtime_identity.version, VERSION)
330+
self.assertEqual(runtime_identity.source_sha, SOURCE_SHA)
331+
self.assertEqual(runtime_identity.image_digest, IMAGE_DIGEST)
332+
environment = cast(dict[str, str], observed["env"])
333+
self.assertEqual(environment["VERSION"], VERSION)
334+
self.assertEqual(environment["SOURCE_SHA"], SOURCE_SHA)
335+
self.assertEqual(environment["IMAGE_DIGEST"], IMAGE_DIGEST)
336+
self.assertEqual(environment["DTC_EXPECTED_VERSION"], VERSION)
337+
self.assertEqual(environment["DTC_EXPECTED_SOURCE_SHA"], SOURCE_SHA)
338+
self.assertEqual(environment["DTC_EXPECTED_IMAGE_DIGEST"], IMAGE_DIGEST)
339+
295340
def test_eventual_visibility_freezes_two_samples_around_public_health(self) -> None:
296341
events: list[str] = []
297342
clock = FakeClock()

deploy/aws_gateway.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2543,6 +2543,9 @@ def run_deployed_smoke(self, identity: ReleaseIdentity) -> None:
25432543
check=True,
25442544
env={
25452545
**os.environ,
2546+
"VERSION": identity.version,
2547+
"SOURCE_SHA": identity.source_sha,
2548+
"IMAGE_DIGEST": identity.image_digest,
25462549
"DTC_TEST_BASE_URL": self.config.base_url,
25472550
"DTC_EXPECTED_VERSION": identity.version,
25482551
"DTC_EXPECTED_SOURCE_SHA": identity.source_sha,

0 commit comments

Comments
 (0)