Repository navigation
test: give the real Toolkit loading test 30s - #2900
Conversation
Since verify moved to GitHub-hosted runners, the cold import of @aws-cdk/toolkit-lib in this test exceeds bun's 5s default on Windows (5015ms), failing verify / Windows on every PR.
|
Claude Security Review: no high-confidence findings. (run) |
Package TarballHow to installgh release download pr-2900-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-1.2.0.tgz |
There was a problem hiding this comment.
AgentCore Harness Review
Verdict: Changes requested
The timeout bump itself is harmless and per-test timeouts are already an established convention in this repo (src/handlers/eval/**/*.fixture.test.tsx). My concern is the diagnosis the new comment records, because it looks contradicted by the test file itself and points away from the real (and still nondeterministic) cost.
src/core/project/backends/cdk/toolkit.test.ts:264 — the comment attributes the 5 s to something that cannot be happening inside this test
// The cold import of @aws-cdk/toolkit-lib takes over 5 s on GitHub-hosted Windows runners.
test("constructs the real Toolkit without resolving credentials", async () => {toolkit.test.ts:5 is a value import of @aws-cdk/toolkit-lib (toolkitLib.StackSelectionStrategy at lines 190/230, lib: toolkitLib at line 86), and toolkit-lib's lib/index.js is a plain CJS barrel with eager __exportStar(require(...)) calls over the whole API tree (including api/aws-auth). So the package is fully evaluated while the test module loads, before any test body runs, and the await import("@aws-cdk/toolkit-lib") inside resolveCdkCredentials/loadCdkToolkit is a registry cache hit. Module-eval time is not charged to a test's 5 s timeout, and there is no mock.module in this file that would change resolution.
What is actually charged to this test body is resolveCdkCredentials → BaseCredentials.awsCliCompatible({ defaultRegion }).sdkBaseConfig(...). In toolkit-lib 1.38.2, credentialChainBuilder computes parentClientConfig.region via this.region(profile) before it sets AWS_EC2_METADATA_DISABLED, and with no AWS_REGION/AWS_DEFAULT_REGION and no ~/.aws/config on the runner that falls through to regionFromMetadataService(). That is gated on isEc2Instance(), whose Windows branch is execSync('reg query "HKLM\\SYSTEM\\HardwareConfig\\Current" /v BaseBoardAssetTag 2>nul') — if that value is absent, reg exits non-zero, execSync throws, and detectEc2()'s catch assumes EC2, so the test then does fetchMetadataToken() + an instance-identity request against 169.254.169.254 with a 1 s HTTP timeout and SDK retries. That is Windows-only (Linux reads /sys and returns false fast, macOS returns false), which matches the observed failure exactly, and it fits the reported 5015 ms far better than a warm import does.
Why this matters: the latency is an ambient network/subprocess probe, not a fixed cost, so 30 s papers over a flake rather than removing it, and the comment will send the next person looking at import time.
Options:
- Make it deterministic instead: set
process.env.AWS_EC2_METADATA_DISABLED ??= "true"(optionally also a dummyAWS_REGION) insrc/testing/setup.ts, alongside the other env pins there. The chain stays lazy so the test's "without resolving credentials" assertions are unchanged, the IMDS probe disappears on every platform, and the 5 s default timeout should hold. - Keep the 30 s timeout but correct the comment to name the real cause (EC2 detection + IMDS region lookup inside
resolveCdkCredentialson Windows runners) rather than the cold import. - If you have evidence from the failing Windows run (e.g. the debug line
Looking up AWS region in the EC2 Instance Metadata Service (IMDS)., or a timing that really does land in module load) that contradicts the above, say so in the comment — my analysis is from readingtoolkit-lib@1.38.2locally, not from the runner.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v1.x #2900 +/- ##
=======================================
Coverage 96.57% 96.57%
=======================================
Files 734 734
Lines 60950 60950
=======================================
Hits 58863 58863
Misses 2087 2087 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
* feat(build): add ContainerLocal build mode (re-land #2814) (#2855) Adds a ContainerLocal build type for runtimes and harnesses: images are built locally with Docker, Finch, or Podman and published through CDK. - --build-config <JSON> (Advanced: group) on add runtime / add harness - agentcore build builds (does not push) ContainerLocal images from the synthesized assembly - deploy rejects switching a deployed workload between Container and ContainerLocal; without CloudFormation read access it warns, or fails when a workload uses ContainerLocal - deploy checks that the detected builder can build Linux ARM64 images and passes it to CDK as CDK_DOCKER - deploy telemetry counts runtimes and harnesses by build type Co-authored-by: gitikavj <gitikavj@amazon.com> * fix(build): address ContainerLocal bug bash findings (#2856) - K08/K09: the deploy guard rejects any change into or out of ContainerLocal for a deployed workload (CodeZip, Managed, Container <-> ContainerLocal). The service rejects artifact-type changes in place ("Agent artifact type cannot be updated"), so only a new workload may use ContainerLocal. A pre-feature (legacy) template's workload is never ContainerLocal, so it is rejected too. ContainerUri transitions are unchanged. - Item 3 (#2856): the guard also rejects a deployed Runtime changing between CodeZip and Container, both ways. The CLI flips a CodeZip Runtime to Container itself when a Dockerfile appears; on a deployed Runtime that ran a full CodeBuild, then the service failed the update ("Agent artifact type cannot be updated", UPDATE_ROLLBACK_COMPLETE) and agentcore.json stayed flipped, so every later deploy failed the same way. A pre-feature template's Runtime counts as CodeZip without a ContainerConfiguration, otherwise as Container. The error says to add a Runtime with a new name or keep the deployed build. Harness Managed <-> Container is unchanged. - A04/A06: the rejection says to keep the deployed build mode or add a workload with a new name, and, after a remove + re-add under the same name, to deploy the removal first, then add it again. The CodeZip -> Container auto-flip message says ContainerLocal can only be chosen when adding a workload. - I21/I22: the ARM64 execution probe always runs on a non-ARM64 daemon, even when `buildx inspect` lists linux/arm64; native ARM64 daemons still skip it. The error says when the builder lists linux/arm64 but cannot run ARM64 code. - I23: deploy chooses the builder first. When the executable is Docker and the active buildx builder's driver is not `docker`, the target is the docker-driver builder of the active Docker context (`docker context show`; each context has one under its own name). `default` would select the `default` context's builder, a different daemon on Docker Desktop, Colima, Rancher Desktop, or an ssh context. The buildx inspect and ARM64 probe run with that BUILDX_BUILDER, and the CDK operation gets the same value (set and restored like CDK_DOCKER). If `docker context show` fails, nothing is redirected and the warning says so. - I24: a relative CDK_DOCKER (one with a path separator) resolves against the current directory, like --build-config paths, before the builder check and before it reaches CDK. - K06: deploy warns when a ContainerLocal runtime or harness uses its own executionRoleArn: the role needs ecr:GetAuthorizationToken on * and ecr:BatchGetImage / ecr:GetDownloadUrlForLayer on cdk-<qualifier>-container-assets-<account>-<region>, otherwise the service fails at first invoke. - A01/A02: a failed `agentcore build` image build names the build context and Dockerfile it uses; add says it copied the Dockerfile to app/<name>/Dockerfile and that later edits to the original are not used. - A08: add runtime refuses when app/<name>/Dockerfile (or its .dockerignore) already exists and differs from the requested file; identical files proceed. - A07: --build-config rejects an absolute buildContextPath; dev resolves the build context instead of joining it, so it never double-prefixes. - A14: --build-config errors are reported against --build-config at parse time: dockerfile must be relative to buildContextPath, and the runtime and harness "requires a Dockerfile" rules. - A15: --build-config help states how dockerfile resolves with and without buildContextPath. - A13: the CodeBuild reserved build-arg rule (AWS_*, CODEBUILD_*, ...) no longer applies to ContainerLocal in the CLI schemas or --build-config; it stays for Container. The @aws/agentcore-cdk (L3) schema must match; that change is in a separate L3 PR. - H11: a ContainerLocal harness.yaml no longer suggests networkConfig.vpcId. Review follow-ups (#2855, #2856): - An invalid harness.yaml fails with InputValidationError naming the file (z.prettifyError), not a raw ZodError. - Harness builds are keyed by the agentcore.json entry name, as L3 keys its metadata, not by the name inside harness.yaml. - Local image tags trim separators from both ends of the name, so a name ending in `_` gives a valid reference. - harness.yaml: dockerfile with containerUri is reported once. - projectRoot is required by the harness and runtime docs templates; the runtime "is required" guards are gone. - The ContainerLocal capability check reports only a missing package as "update the dependency"; other load errors surface with their message. - Tests: Windows-safe CDK_DOCKER paths, a missing build context in the asset manifest, and an invalid harness.yaml in resolveWorkloads. I23 local evidence (x86_64, Docker 25.0.18, buildx 0.12.2; builder multiarch-builder uses the docker-container driver; restored to default after): $ BUILDX_BUILDER=multiarch-builder docker build --platform linux/arm64 -t i23-c . WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. ... $ docker image inspect i23-c Error response from daemon: No such image: i23-c:latest $ BUILDX_BUILDER=default docker build --platform linux/arm64 -t i23-d . #3 naming to docker.io/library/i23-d done $ docker image inspect i23-d --format '{{.Id}}' sha256:3bb32867... This is the plain `docker build` cdk-assets runs (no --load), with the builder selected the way docker/setup-buildx-action selects it (BUILDX_BUILDER). On this host `docker buildx use multiarch-builder` alone did not redirect plain `docker build` (only `docker buildx build`, which then hit the same "No such image"), so the env var is the case that matters, and BUILDX_BUILDER=default overrides it. This host's active Docker context is `default`, so `default` is the context builder the deploy now selects. Co-authored-by: gitikavj <gitikavj@amazon.com> * feat(project): sync vended CDK dependencies on build and deploy (#2861) * feat(project): sync vended CDK dependencies on build and deploy agentcore create is the only writer of agentcore/cdk/package.json, so a project kept the @aws/agentcore-cdk it was created with across CLI upgrades. Fields a newer CLI writes to agentcore.json that the old library does not know were dropped at synth without an error. Before synth, build and deploy now rewrite every dependency the vended package.json names to the specifier this CLI vends and run npm install, leaving dependencies the user added alone. A pin newer than this CLI fails with an upgrade hint, non-version specifiers are skipped with a warning, and a failed install restores package.json. A deploy that removes the stack only warns. Opt out with 'agentcore config disableDependencyManagement true'. Ports the v0 behavior from #1777. * feat(project): install CDK dependencies when node_modules is missing When agentcore/cdk/node_modules is missing, build and deploy now run npm install in agentcore/cdk before synth (and before any AWS mutation on deploy), even when the pins already match, instead of failing with "Run 'npm install'". A failed install raises a ProjectStateError that names the directory and carries npm's error; a teardown only warns. With disableDependencyManagement set, the existing error is kept. * fix(project): explain that CLI-managed CDK dependencies can't be upgraded A newer @aws/agentcore-cdk now points at 'agentcore update'. A newer toolchain pin lists every CDK dependency the CLI manages, read from the vended package.json, and says to set it back or opt out with disableDependencyManagement. Blocking behavior is unchanged. * refactor(project): reuse declaresNothingDeployable and tidy CDK dependency sync Move declaresNothingDeployable to src/core/project/spec.ts so the CDK backend uses it to decide whether a dependency problem only warns, in place of its own inline check. Warn when package.json cannot be restored after a failed install, run npm install with --no-audit --no-fund as migrate does, correct the writers named in the sync's doc comment, and stop exporting types nothing else uses. Add tests that the build and deploy handlers and screens pass disableDependencyManagement to the backend. * refactor(project): simplify CDK dependency sync types and test setup parseSpecifier returns the base version and isNewer takes whether the vended pin is exact, since only that distinction was ever read. BuildBackendInput duplicated BuildProjectInput and is removed. The build and deploy handler tests seed the global config with applyOverrides. * test(project): drop CDK dependency sync tests covered by the backend suite * fix(project): decide CDK dependency installs from what is installed Address review feedback on the CDK dependency sync: - Install when the installed @aws/agentcore-cdk is missing or does not satisfy the declared pin, so a pulled manifest or an interrupted install no longer leaves a stale library. The restore-on-failure path is gone and npm's ProcessFailedError propagates unwrapped. - Leave a tilde or caret pin alone when major.minor match and its patch is at or above the vended one, so two CLI releases do not flip it. - With dependency management disabled, skip the newer-pin warning and warn about an older L3 pin instead. - Compare against the version this CLI vends, name both 'agentcore update' and the opt-out, give one sentence per newer pin, and show only the L3 pin when it is newer. - Validate the manifest with zod through ReadWriteJson so a malformed shape is a ProjectStateError, share the specifier parse with declaredCdkDependency, and keep the file's indent and line endings. * docs(readme): explain CDK dependency management on build and deploy --------- Co-authored-by: jariy17 <tjariy+jariy17@users.noreply.github.com> * chore(release): v1.2.0 (#2881) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * ci: bump open-PR digest workflow pin to list every open PR (#2891) Picks up aws/agentcore-devx-devtools#24, which paginates the open-PR list instead of stopping at GitHub's default first page of 30. Co-authored-by: jariy17 <tjariy+jariy17@users.noreply.github.com> * ci: run non-E2E jobs on GitHub-hosted runners (#2896) * ci: run E2E and canaries on GitHub-hosted runners (#2901) The agentcore-e2e CodeBuild runner can't register with GitHub (its credential lacks runner-registration permission since 2026-11-23), so E2E and canary jobs never start. Run them on GitHub-hosted runners until the CodeBuild runner is fixed. Co-authored-by: jariy17 <tjariy+jariy17@users.noreply.github.com> * test: give the real Toolkit loading test 30s (#2900) Since verify moved to GitHub-hosted runners, the cold import of @aws-cdk/toolkit-lib in this test exceeds bun's 5s default on Windows (5015ms), failing verify / Windows on every PR. Co-authored-by: jariy17 <tjariy+jariy17@users.noreply.github.com> --------- Co-authored-by: Gitika <53349492+notgitika@users.noreply.github.com> Co-authored-by: gitikavj <gitikavj@amazon.com> Co-authored-by: Trirmadura J Ariyawansa <tjariy@amazon.com> Co-authored-by: jariy17 <tjariy+jariy17@users.noreply.github.com> Co-authored-by: agentcore-devx-automation[bot] <282717993+agentcore-devx-automation[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
On GitHub-hosted Windows runners, "on a terminal, asks first and applies on yes" took 5258 ms and failed verify / Windows at bun's 5 s default; "--yes never applies a plan that isn't ready" took 3975 ms. As #2900 did for the Toolkit loading test, give each 30 s.
Since #2896 moved
verifyto GitHub-hosted runners,verify / Windowsfails on one test: "Toolkit loading > constructs the real Toolkit without resolving credentials" times out at 5015 ms. Its cold import of@aws-cdk/toolkit-libis slower on the GitHub Windows runner than on CodeBuild. A re-run failed the same way.This gives that one test a 30 s timeout. The other 5,100 tests are unchanged.