@aws-cdk/integ-runner 2.200.1 → 2.200.2

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.
@@ -4,9 +4,9 @@ import type { IntegTest } from './integration-tests';
4
4
  import type { ICdk } from '../engines/cdk-interface';
5
5
  import type { DestructiveChange } from '../workers/common';
6
6
  /**
7
- * Options for creating an integration test runner
7
+ * Options for creating an integ helper
8
8
  */
9
- export interface IntegRunnerOptions {
9
+ export interface CdkIntegHelperOptions {
10
10
  /**
11
11
  * Information about the test to run
12
12
  */
@@ -62,16 +62,36 @@ export interface IntegRunnerOptions {
62
62
  readonly caBundlePath?: string;
63
63
  }
64
64
  /**
65
- * The different components of a test name
65
+ * Whether to synthesize the actual snapshot with lookups enabled or not.
66
+ *
67
+ * If either `true` or `false`, we send context in or not while synthesizing,
68
+ * and if the generated snapshot test definition requests a different value we
69
+ * will synth again.
70
+ *
71
+ * For `dont-care`, we do send in the context but we never resynth.
66
72
  */
73
+ export type LegacyEnableLookups = true | false | 'dont-care';
67
74
  /**
68
- * Represents an Integration test runner
75
+ * Class with some helper routines for running CDK snapshots and integration tests.
76
+ *
77
+ * A "golden snapshot" is the snapshot that is stored permanently in version
78
+ * control, that new runs are compared against (stored in a directory named
79
+ * `<test-name>.snapshot`).
80
+ *
81
+ * This is as opposed to other snapshots, which can be generated for example
82
+ * temporarily in a temporary directory, to compare agains the golden snapshot.
69
83
  */
70
- export declare abstract class IntegRunner {
84
+ export declare class CdkIntegHelper {
85
+ /**
86
+ * Factory method to create an instance of the CdkIntegHelper.
87
+ *
88
+ * Hiding the constructor to prevent inheritance.
89
+ */
90
+ static create(options: CdkIntegHelperOptions): CdkIntegHelper;
71
91
  /**
72
- * The directory where the snapshot will be stored
92
+ * The directory where the golden snapshot will be stored
73
93
  */
74
- readonly snapshotDir: string;
94
+ readonly goldenSnapshotDir: string;
75
95
  /**
76
96
  * An instance of the CDK CLI
77
97
  */
@@ -85,50 +105,54 @@ export declare abstract class IntegRunner {
85
105
  *
86
106
  * Path to the integ test source file, relative to `this.directory`.
87
107
  */
88
- protected readonly cdkApp: string;
108
+ readonly cdkApp: string;
89
109
  /**
90
110
  * The path where the `cdk.context.json` file
91
111
  * will be created
92
112
  */
93
- protected readonly cdkContextPath: string;
113
+ readonly cdkContextPath: string;
94
114
  /**
95
115
  * The working directory that the integration tests will be
96
116
  * executed from
97
117
  */
98
- protected readonly directory: string;
118
+ readonly directory: string;
99
119
  /**
100
120
  * The test to run
101
121
  */
102
- protected readonly test: IntegTest;
122
+ private readonly test;
103
123
  /**
104
124
  * Default options to pass to the CDK CLI
105
125
  */
106
- protected readonly defaultArgs: DefaultCdkOptions;
126
+ readonly defaultArgs: DefaultCdkOptions;
107
127
  /**
108
128
  * The directory where the CDK will be synthed to
109
129
  *
110
130
  * Relative to cwd.
111
131
  */
112
- protected readonly cdkOutDir: string;
132
+ readonly cdkOutDir: string;
113
133
  /**
114
134
  * The profile to use for the CDK CLI calls
115
135
  */
116
- protected readonly profile?: string;
136
+ readonly profile?: string;
117
137
  /**
118
138
  * Show output from the integ test run.
119
139
  */
120
- protected readonly showOutput: boolean;
121
- protected _destructiveChanges?: DestructiveChange[];
140
+ private readonly showOutput;
141
+ _destructiveChanges?: DestructiveChange[];
122
142
  private legacyContext?;
123
143
  private _expectedTestSuite?;
124
- private _actualTestSuite?;
125
- constructor(options: IntegRunnerOptions);
144
+ private _actualSnapshot?;
145
+ private _legacyEnableLookups?;
126
146
  /**
127
- * Return the list of expected (i.e. existing) test cases for this integration test
147
+ * Private constructor to prevent inheritance.
128
148
  */
129
- expectedTests(): Promise<{
130
- [testName: string]: TestCase;
131
- } | undefined>;
149
+ private constructor();
150
+ /**
151
+ * Configure the legacy enableLookups value to use when generating the actual snapshot.
152
+ *
153
+ * Must be set before using snapshot methods.
154
+ */
155
+ configureLegacyEnableLookups(enableLookups: LegacyEnableLookups): void;
132
156
  /**
133
157
  * Return the list of actual (i.e. new) test cases for this integration test
134
158
  */
@@ -140,7 +164,29 @@ export declare abstract class IntegRunner {
140
164
  * existing "expected" snapshot
141
165
  * This will synth and then load the integration test manifest
142
166
  */
143
- generateActualSnapshot(): Promise<IntegTestSuite | LegacyIntegTestSuite>;
167
+ private generateActualSnapshot;
168
+ /**
169
+ * Synth the actual application to the given directory, for purposes of generating/validating a snapshot
170
+ *
171
+ * `legacyEnableLookups` is to preserve historical behavior for a while:
172
+ * traditionally, the application would only be seeded with context if
173
+ * `enableLookups` was true, and this information would come from the test
174
+ * definition.
175
+ *
176
+ * - Since the test definition comes from inside the app, this requires a
177
+ * synth just to get the test definition, and then another synth to generate
178
+ * the actual snapshot with the correct context, which is time consuming.
179
+ * - Given that the context is fixed and fake, it could always have been passed.
180
+ *
181
+ * However, the snapshot contents themselves depend on the context flag, and changing
182
+ * this behavior now invalidates all snapshots everywhere, which is annoying for upgrading.
183
+ *
184
+ * So we will use the behavior from the GOLDEN SNAPSHOT's test definition to
185
+ * determine whether to pass the context, and if the new actual snapshot has a
186
+ * different value for `enableLookups`, we will throw away the old snapshot and synth again.
187
+ */
188
+ private synthActualSnapshot;
189
+ actualSynthReproCommand(): string[];
144
190
  /**
145
191
  * Returns true if a snapshot already exists for this test
146
192
  */
@@ -148,11 +194,12 @@ export declare abstract class IntegRunner {
148
194
  /**
149
195
  * The test suite from the existing snapshot
150
196
  */
151
- protected expectedTestSuite(): Promise<IntegTestSuite | LegacyIntegTestSuite | undefined>;
197
+ expectedTestSuite(): Promise<IntegTestSuite | LegacyIntegTestSuite | undefined>;
198
+ actualSnapshot(): Promise<SnapshotAndTestDefinition>;
152
199
  /**
153
200
  * The test suite from the new "actual" snapshot
154
201
  */
155
- protected actualTestSuite(): Promise<IntegTestSuite | LegacyIntegTestSuite>;
202
+ private actualTestSuite;
156
203
  /**
157
204
  * Load the integ manifest which contains information
158
205
  * on how to execute the tests
@@ -160,8 +207,8 @@ export declare abstract class IntegRunner {
160
207
  * from the cloud assembly. If it doesn't exist, then we fallback to the
161
208
  * "legacy mode" and create a manifest from pragma
162
209
  */
163
- protected loadManifest(dir?: string): Promise<IntegTestSuite | LegacyIntegTestSuite>;
164
- protected cleanup(): void;
210
+ loadManifest(dir?: string): Promise<IntegTestSuite | LegacyIntegTestSuite>;
211
+ cleanup(): void;
165
212
  /**
166
213
  * If there are any destructive changes to a stack then this will record
167
214
  * those in the manifest.json file
@@ -176,13 +223,13 @@ export declare abstract class IntegRunner {
176
223
  * disabled and then delete assets that relate to that stack. It does that
177
224
  * by reading the asset manifest for the stack and deleting the asset source
178
225
  */
179
- protected removeAssetsFromSnapshot(): Promise<void>;
226
+ private removeAssetsFromSnapshot;
180
227
  /**
181
228
  * Remove the asset cache (.cache/) files from the snapshot.
182
229
  * These are a cache of the asset zips, but we are fine with
183
230
  * re-zipping on deploy
184
231
  */
185
- protected removeAssetsCacheFromSnapshot(): void;
232
+ private removeAssetsCacheFromSnapshot;
186
233
  /**
187
234
  * Create the new snapshot.
188
235
  *
@@ -193,14 +240,14 @@ export declare abstract class IntegRunner {
193
240
  * If lookups are disabled (which means the stack is env agnostic) then just copy
194
241
  * the assembly that was output by the deployment
195
242
  */
196
- protected createSnapshot(): Promise<void>;
243
+ createSnapshot(): Promise<void>;
197
244
  /**
198
245
  * Perform some cleanup steps after the snapshot is created
199
246
  * Anytime the snapshot needs to be modified after creation
200
247
  * the logic should live here.
201
248
  */
202
- private cleanupSnapshot;
203
- protected getContext(additionalContext?: Record<string, any>): Record<string, any>;
249
+ private cleanupGoldenSnapshot;
250
+ getContext(additionalContext?: Record<string, any>): Record<string, any>;
204
251
  }
205
252
  export declare const DEFAULT_SYNTH_OPTIONS: {
206
253
  context: {
@@ -325,4 +372,8 @@ export declare function currentlyRecommendedAwsCdkLibFlags(): {
325
372
  "@aws-cdk/aws-batch:defaultToAL2023": boolean;
326
373
  "@aws-cdk/core:annotationsInValidationReport": boolean;
327
374
  };
328
- //# sourceMappingURL=runner-base.d.ts.map
375
+ export interface SnapshotAndTestDefinition {
376
+ readonly testDefinition: IntegTestSuite | LegacyIntegTestSuite;
377
+ readonly snapshotDirectory: string;
378
+ }
379
+ //# sourceMappingURL=cdk-integ-helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cdk-integ-helper.d.ts","sourceRoot":"","sources":["cdk-integ-helper.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAElF,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIrD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAIrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAK3D;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAE1C;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B;;;;OAIG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IAEpB;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAE9B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,mBAAmB,GAAG,IA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