@specific.dev/spectest 0.34.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/aws.d.ts +7 -0
- package/dist/components/aws.js +54 -7
- package/package.json +1 -1
package/dist/components/aws.d.ts
CHANGED
|
@@ -101,7 +101,14 @@ export declare function aws(opts?: AwsOptions): {
|
|
|
101
101
|
};
|
|
102
102
|
env: {
|
|
103
103
|
AWS_DEFAULT_REGION: string;
|
|
104
|
+
LAMBDA_EXECUTOR: string;
|
|
105
|
+
LAMBDA_STRICT: string;
|
|
106
|
+
LAMBDA_DOCKER_NETWORK: string;
|
|
104
107
|
};
|
|
108
|
+
volumes: {
|
|
109
|
+
source: string;
|
|
110
|
+
target: string;
|
|
111
|
+
}[];
|
|
105
112
|
ports: number[];
|
|
106
113
|
readyCheck: {
|
|
107
114
|
type: "http";
|
package/dist/components/aws.js
CHANGED
|
@@ -19,9 +19,37 @@
|
|
|
19
19
|
// pinned rather than floated. It replaced LocalStack, which folded its
|
|
20
20
|
// Apache-2.0 Community edition into one paid product in March 2026 (current
|
|
21
21
|
// images demand a LOCALSTACK_AUTH_TOKEN). MiniStack also suits fork-per-test
|
|
22
|
-
// far better: ~270 MB against ~1 GB
|
|
23
|
-
//
|
|
24
|
-
//
|
|
22
|
+
// far better: ~270 MB against ~1 GB and a ~2 s boot.
|
|
23
|
+
//
|
|
24
|
+
// Lambda runs in MiniStack's **docker** executor, never its default `local`
|
|
25
|
+
// one, because `local` has no runtime fidelity at all: it maps `python*` to
|
|
26
|
+
// its own `sys.executable` and `nodejs*` to its own `node`, so the declared
|
|
27
|
+
// `Runtime` selects only the language. A function declared `python3.11` runs
|
|
28
|
+
// on the emulator image's CPython 3.13/musl, and one declared `nodejs20.x`
|
|
29
|
+
// runs on Node 24 — which is why a native wheel built for the real target
|
|
30
|
+
// fails to import ("No module named 'pydantic_core._pydantic_core'"). The
|
|
31
|
+
// docker executor runs the handler under AWS's own Runtime Interface
|
|
32
|
+
// Emulator in `public.ecr.aws/lambda/<runtime>`, giving the real
|
|
33
|
+
// interpreter, glibc, `/var/task` and `AWS_EXECUTION_ENV`. Measured on
|
|
34
|
+
// aarch64: it is also ~7x FASTER per warm invoke (7 ms against 53 ms) at
|
|
35
|
+
// ~25-40 MiB per function container.
|
|
36
|
+
//
|
|
37
|
+
// None of this is configurable, on purpose — a knob here is a knob between
|
|
38
|
+
// "behaves like AWS" and "does not".
|
|
39
|
+
//
|
|
40
|
+
// The cost is a bind-mount of the VM's own docker socket, which the daemon
|
|
41
|
+
// already supports (`ensureVolumes` treats an existing non-directory source
|
|
42
|
+
// as a thing to mount as-is). The RIE containers are ordinary VM containers
|
|
43
|
+
// on `spectest-net`, so they ride snapshots and forks like any service: a
|
|
44
|
+
// per-test fork inherits its parent's already-warm function.
|
|
45
|
+
//
|
|
46
|
+
// Landmine: the runtime images are pulled from `public.ecr.aws`, which the
|
|
47
|
+
// in-VM dockerd reaches DIRECTLY. Its `registry-mirrors` only ever applies
|
|
48
|
+
// to Docker Hub, so the zot mirror (which does carry public.ecr.aws, on
|
|
49
|
+
// :5004) is NOT consulted. MiniStack's own `MINISTACK_IMAGE_PREFIX` cannot
|
|
50
|
+
// close that gap either: it prepends rather than replacing the registry
|
|
51
|
+
// host. Routing these pulls through zot needs a pre-pull of
|
|
52
|
+
// `spectest-host:5004/lambda/<rt>` retagged to the `public.ecr.aws` name.
|
|
25
53
|
//
|
|
26
54
|
// Like `email()`'s mail server, the product name stays out of every
|
|
27
55
|
// user-facing surface (docs, examples, error messages). Users get "the AWS
|
|
@@ -73,6 +101,13 @@ const AWS_HOST_PATTERNS = [
|
|
|
73
101
|
"*.amazonaws.com.cn",
|
|
74
102
|
...AWS_CN_REGIONS.map((r) => `*.${r}.amazonaws.com.cn`),
|
|
75
103
|
];
|
|
104
|
+
/** The VM's own docker socket, bind-mounted so the emulator can start the
|
|
105
|
+
* official AWS runtime containers. This is the VM's dockerd, inside the
|
|
106
|
+
* hermetic environment — the same daemon that runs the services. */
|
|
107
|
+
const DOCKER_SOCKET = "/var/run/docker.sock";
|
|
108
|
+
/** The network the function containers join, so a handler reaches the other
|
|
109
|
+
* services and the AWS endpoints by the same names a test uses. */
|
|
110
|
+
const SPECTEST_NETWORK = "spectest-net";
|
|
76
111
|
/** Region the emulator's own tools default to — the AWS CLI refuses to run
|
|
77
112
|
* without one. Only the *container's* default; it constrains nothing about
|
|
78
113
|
* the app, and every region is served regardless. A `setup` hook that drives
|
|
@@ -144,7 +179,18 @@ export function aws(opts = {}) {
|
|
|
144
179
|
const lambdas = opts.lambdas ?? {};
|
|
145
180
|
const service = {
|
|
146
181
|
image: { type: "registry", reference: AWS_IMAGE },
|
|
147
|
-
env: {
|
|
182
|
+
env: {
|
|
183
|
+
AWS_DEFAULT_REGION: CONTAINER_DEFAULT_REGION,
|
|
184
|
+
// Run every function in the official AWS runtime image rather than in
|
|
185
|
+
// the emulator's own interpreter — see the note at the top of the file.
|
|
186
|
+
LAMBDA_EXECUTOR: "docker",
|
|
187
|
+
// No silent fall-back to the low-fidelity executor. If the runtime
|
|
188
|
+
// container cannot start, say so instead of running the handler on the
|
|
189
|
+
// wrong interpreter and failing later, somewhere else.
|
|
190
|
+
LAMBDA_STRICT: "1",
|
|
191
|
+
LAMBDA_DOCKER_NETWORK: SPECTEST_NETWORK,
|
|
192
|
+
},
|
|
193
|
+
volumes: [{ source: DOCKER_SOCKET, target: DOCKER_SOCKET }],
|
|
148
194
|
ports: [AWS_PORT],
|
|
149
195
|
readyCheck: {
|
|
150
196
|
type: "http",
|
|
@@ -226,9 +272,10 @@ async function deployLambda(service, projectRoot, name, spec) {
|
|
|
226
272
|
Handler: spec.handler ?? "index.handler",
|
|
227
273
|
Role: spec.role ?? DEFAULT_ROLE_ARN,
|
|
228
274
|
Timeout: spec.timeoutSecs ?? 30,
|
|
229
|
-
// Fixed, and not an option: the emulated cloud
|
|
230
|
-
//
|
|
231
|
-
// nothing about how a function
|
|
275
|
+
// Fixed, and not an option: the emulated cloud reports this number back
|
|
276
|
+
// as `AWS_LAMBDA_FUNCTION_MEMORY_SIZE` but never caps the runtime
|
|
277
|
+
// container at it, so the number changes nothing about how a function
|
|
278
|
+
// behaves here.
|
|
232
279
|
MemorySize: MEMORY_MB,
|
|
233
280
|
...(spec.env ? { Environment: { Variables: spec.env } } : {}),
|
|
234
281
|
};
|