(@aws-cdk/integ-tests-alpha): Verifying snapshot doesn't read values from cdk.context.json
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
When running an integration test with `integ-runner` the verification of the snapshot fails if the integration test contains a `VPC.fromLookup(...)`. The snapshot verification show a difference in the VpcId with the new value being the default VpcID dummy value of `vpc-12345`.
### Expected Behavior
The `integ-runner` would read the VpcId from the `cdk.context.json`.
### Current Behavior
```
#> integ-runner integ.bug.ts
Verifying integration test snapshots...
CHANGED integ.bug 5.097s
Resources
[~] AWS::EC2::SecurityGroup sgxxxxxxx replace
└─ [~] VpcId (requires replacement)
├─ [-] vpc-xxxxxxxxxxxxx
└─ [+] vpc-12345
Snapshot Results:
Tests: 1 failed, 1 total
```
As shown in the output above, the VpcId falls back to the default value of `vpc-12345`.
### Reproduction Steps
Define the following integration test:
1) run with `integ-runner --update-on-failed` -> this will create the `cdk.context.json` with the lookup values.
2) run with `integ-runner`
```typescript
import * as cdk from 'aws-cdk-lib';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as integ from '@aws-cdk/integ-tests-alpha';
const REGION = 'eu-central-2';
const ACCOUNT = 'SOME_ACCOUNT_ID';
const VPC_ID = 'some existing vpc id';
const app = new cdk.App({
context: {
'@aws-cdk/core:bootstrapQualifier': '',
},
});
const stack = new cdk.Stack(app, 'integBug', {
env: {
account: ACCOUNT,
region: REGION,
},
});
const vpc = ec2.Vpc.fromLookup(stack, 'vpc', {
vpcId: VPC_ID,
});
new ec2.SecurityGroup(stack, 'sg', {
vpc: vpc,
});
new integ.IntegTest(app, 'integTest', {
testCases: [stack],
});
```
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### CDK CLI Version
2.148.1 (build 283525d)
### Framework Version
_No response_
### Node.js Version
v20.15.0
### OS
Linux
### Language
TypeScript
### Language Version
Typescript (5.5.4)
### Other information
_No response_
Contributor guide
Research direction
Start with the integ.bug.ts reproduction and the integ-runner snapshot-verification path, then compare normal runs with --update-on-failed while checking how cdk.context.json is used. Done means the verification preserves the looked-up VPC ID instead of substituting vpc-12345 and the reproduction no longer reports a false snapshot difference.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100