Skip to content

Commit 25fda51

Browse files
authored
2 parents b6f7f39 + 527dcbb commit 25fda51

File tree

274 files changed

+12965
-3363
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

274 files changed

+12965
-3363
lines changed

CHANGELOG.v2.alpha.md

+20
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [2.68.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.67.0-alpha.0...v2.68.0-alpha.0) (2023-03-08)
6+
7+
8+
### ⚠ BREAKING CHANGES TO EXPERIMENTAL FEATURES
9+
10+
* **servicecatalogappregistry:** This commit contains destructive changes to the RAM Share.
11+
Since the application RAM share name is calculated by the application construct, where one property is removed. Integration test detects a breaking change where RAM share will be created. Integration test snapshot is updated to cater this destructive change.
12+
13+
### Features
14+
15+
* **msk:** add Kafka version 3.3.2 ([#24440](https://github.com/aws/aws-cdk/issues/24440)) ([1b2014e](https://github.com/aws/aws-cdk/commit/1b2014eef9e3f2190b2cce79c55f635cc1f167e3)), closes [#24432](https://github.com/aws/aws-cdk/issues/24432)
16+
* **redshift:** column compression encodings and comments can now be customised ([#24177](https://github.com/aws/aws-cdk/issues/24177)) ([1ca3e00](https://github.com/aws/aws-cdk/commit/1ca3e0027323e84aacade4d9bd058bbc5687a7ab)), closes [#24165](https://github.com/aws/aws-cdk/issues/24165) [#23597](https://github.com/aws/aws-cdk/issues/23597) [#22506](https://github.com/aws/aws-cdk/issues/22506)
17+
* **redshift:** columns require an id attribute (under feature flag) ([#24272](https://github.com/aws/aws-cdk/issues/24272)) ([9a07ab0](https://github.com/aws/aws-cdk/commit/9a07ab008d1b6d23e9a302921f1a5165a21fb128)), closes [#24234](https://github.com/aws/aws-cdk/issues/24234)
18+
19+
20+
### Bug Fixes
21+
22+
* **servicecatalogappregistry:** allow disabling automatic CfnOutput ([#24483](https://github.com/aws/aws-cdk/issues/24483)) ([3db1a0d](https://github.com/aws/aws-cdk/commit/3db1a0d0bcf615871a225919eed235b78904e144)), closes [#23779](https://github.com/aws/aws-cdk/issues/23779)
23+
* **servicecatalogappregistry:** Associate an application with attribute group ([#24378](https://github.com/aws/aws-cdk/issues/24378)) ([d1264c1](https://github.com/aws/aws-cdk/commit/d1264c1c414257fb8dd5288fdc24cfe9605cdf90))
24+
525
## [2.67.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.66.1-alpha.0...v2.67.0-alpha.0) (2023-03-02)
626

727

CHANGELOG.v2.md

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [2.68.0](https://github.com/aws/aws-cdk/compare/v2.67.0...v2.68.0) (2023-03-08)
6+
7+
8+
### Bug Fixes
9+
10+
* **apprunner-alpha:** env vars and secrets can't solely be added via .add*() methods ([#24346](https://github.com/aws/aws-cdk/issues/24346)) ([45195b6](https://github.com/aws/aws-cdk/commit/45195b6f2e5162eaa795d3a412d89dd09680aa8b)), closes [#24345](https://github.com/aws/aws-cdk/issues/24345)
11+
* **cli:** cannot `cdk import` resources with multiple identifiers ([#24439](https://github.com/aws/aws-cdk/issues/24439)) ([a70ff1a](https://github.com/aws/aws-cdk/commit/a70ff1ad332af780c052e3117b73df060deee7ae)), closes [#20895](https://github.com/aws/aws-cdk/issues/20895)
12+
* **core:** Fix dotnet version check to allow .NET 7.0 ([#24467](https://github.com/aws/aws-cdk/issues/24467)) ([a4856e9](https://github.com/aws/aws-cdk/commit/a4856e997684f84476fe92e00afcd4da76a69b04)), closes [#24466](https://github.com/aws/aws-cdk/issues/24466)
13+
* **lambda-nodejs:** esbuild preCompilation tsconfig precedence is wrong ([#23871](https://github.com/aws/aws-cdk/issues/23871)) ([790a709](https://github.com/aws/aws-cdk/commit/790a709d758333f4622c5fb860d9bbb48dee7106))
14+
* **lambda-nodejs:** Required auto prefix of `handler` with `index.` breaks custom non-`index` handler settings used by layers ([#24406](https://github.com/aws/aws-cdk/issues/24406)) ([d7a1c34](https://github.com/aws/aws-cdk/commit/d7a1c34e540e12413319918a5d807060057a1a1b)), closes [#24403](https://github.com/aws/aws-cdk/issues/24403)
15+
* **rds:** add clusterResourceIdentifier property to database cluster ([#23605](https://github.com/aws/aws-cdk/issues/23605)) ([6bda4e5](https://github.com/aws/aws-cdk/commit/6bda4e5ae4205a917a00714433f136550c59e409))
16+
517
## [2.67.0](https://github.com/aws/aws-cdk/compare/v2.66.1...v2.67.0) (2023-03-02)
618

719

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
"@types/node": "18.11.19",
2020
"@types/prettier": "2.6.0",
2121
"@yarnpkg/lockfile": "^1.1.0",
22-
"cdk-generate-synthetic-examples": "^0.1.167",
22+
"cdk-generate-synthetic-examples": "^0.1.173",
2323
"conventional-changelog-cli": "^2.2.2",
2424
"fs-extra": "^9.1.0",
2525
"graceful-fs": "^4.2.10",
2626
"jest-junit": "^13.2.0",
27-
"jsii-diff": "1.76.0",
28-
"jsii-pacmak": "1.76.0",
29-
"jsii-reflect": "1.76.0",
27+
"jsii-diff": "1.77.0",
28+
"jsii-pacmak": "1.77.0",
29+
"jsii-reflect": "1.77.0",
3030
"jsii-rosetta": "v4.9-next",
3131
"lerna": "^4.0.0",
3232
"patch-package": "^6.5.1",

packages/@aws-cdk-testing/cli-integ/lib/integ-test.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ export interface TestContext {
1010
log(s: string): void;
1111
};
1212

13+
if (process.env.JEST_TEST_CONCURRENT === 'true') {
14+
process.stderr.write('ℹ️ JEST_TEST_CONCURRENT is true: tests will run concurrently and filters have no effect!');
15+
}
16+
1317
/**
1418
* A wrapper for jest's 'test' which takes regression-disabled tests into account and prints a banner
1519
*/
@@ -18,7 +22,6 @@ export function integTest(
1822
callback: (context: TestContext) => Promise<void>,
1923
timeoutMillis?: number,
2024
): void {
21-
2225
// Integ tests can run concurrently, and are responsible for blocking
2326
// themselves if they cannot. Because `test.concurrent` executes the test
2427
// code immediately, regardles of any `--testNamePattern`, this cannot be the
@@ -35,6 +38,8 @@ export function integTest(
3538
output.write(`${name}\n`);
3639
output.write('================================================================\n');
3740

41+
const now = Date.now();
42+
process.stderr.write(`[INTEG TEST::${name}] Starting (pid ${process.pid})...\n`);
3843
try {
3944
return await callback({
4045
output,
@@ -44,13 +49,17 @@ export function integTest(
4449
},
4550
});
4651
} catch (e) {
52+
process.stderr.write(`[INTEG TEST::${name}] Failed: ${e}\n`);
4753
output.write(e.message);
4854
output.write(e.stack);
4955
// Print output only if the test fails. Use 'console.log' so the output is buffered by
5056
// jest and prints without a stack trace (if verbose: false).
5157
// eslint-disable-next-line no-console
5258
console.log(output.buffer().toString());
5359
throw e;
60+
} finally {
61+
const duration = Date.now() - now;
62+
process.stderr.write(`[INTEG TEST::${name}] Done (${duration} ms).\n`);
5463
}
5564
}, timeoutMillis);
5665
}

packages/@aws-cdk-testing/cli-integ/lib/resource-pool.ts

+6-10
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ export class ResourcePool<A extends string=string> {
4444
while (true) {
4545
// Start a wait on the unlock now -- if the unlock signal comes after
4646
// we try to acquire but before we start the wait, we might miss it.
47-
const wait = this.pool.awaitUnlock(5000);
47+
//
48+
// (The timeout is in case the unlock signal doesn't come for whatever reason).
49+
const wait = this.pool.awaitUnlock(10_000);
4850

49-
for (const res of this.unlockedResources()) {
51+
// Try all mutexes, we might need to reacquire an expired lock
52+
for (const res of this.resources) {
5053
const lease = await this.tryObtainLease(res);
5154
if (lease) {
5255
// Ignore the wait (count as handled)
@@ -86,7 +89,7 @@ export class ResourcePool<A extends string=string> {
8689
let disposed = false;
8790
return {
8891
value,
89-
dispose: () => {
92+
dispose: async () => {
9093
if (disposed) {
9194
throw new Error('Calling dispose() on an already-disposed lease.');
9295
}
@@ -107,13 +110,6 @@ export class ResourcePool<A extends string=string> {
107110
delete this.locks[value];
108111
await lock?.release();
109112
}
110-
111-
/**
112-
* Return all resources that we definitely don't own the locks for
113-
*/
114-
private unlockedResources(): A[] {
115-
return this.resources.filter(res => !this.locks[res]);
116-
}
117113
}
118114

119115
/**

packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import { packageSourceInSubprocess } from './package-sources/subprocess';
99
import { RESOURCES_DIR } from './resources';
1010
import { shell, ShellOptions, ShellHelper, rimraf } from './shell';
1111
import { AwsContext, withAws } from './with-aws';
12+
import { withTimeout } from './with-timeout';
13+
14+
export const DEFAULT_TEST_TIMEOUT_S = 10 * 60;
1215

1316
/**
1417
* Higher order function to execute a block with a CDK app fixture
@@ -135,7 +138,7 @@ export function withMonolithicCfnIncludeCdkApp<A extends TestContext>(block: (co
135138
* test declaration but centralizing it is going to make it convenient to modify in the future.
136139
*/
137140
export function withDefaultFixture(block: (context: TestFixture) => Promise<void>) {
138-
return withAws(withCdkApp(block));
141+
return withAws(withTimeout(DEFAULT_TEST_TIMEOUT_S, withCdkApp(block)));
139142
}
140143

141144
export interface DisableBootstrapContext {

packages/@aws-cdk-testing/cli-integ/lib/with-sam.ts

+24-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import { TestContext } from './integ-test';
77
import { RESOURCES_DIR } from './resources';
88
import { ShellOptions, rimraf } from './shell';
99
import { AwsContext, withAws } from './with-aws';
10-
import { cloneDirectory, installNpmPackages, TestFixture } from './with-cdk-app';
10+
import { cloneDirectory, installNpmPackages, TestFixture, DEFAULT_TEST_TIMEOUT_S } from './with-cdk-app';
11+
import { withTimeout } from './with-timeout';
1112

1213

1314
export interface ActionOutput {
@@ -113,7 +114,7 @@ function errorCausedByGoPkg(error: string) {
113114
* SAM Integration test fixture for CDK - SAM integration test cases
114115
*/
115116
export function withSamIntegrationFixture(block: (context: SamIntegrationTestFixture) => Promise<void>) {
116-
return withAws(withSamIntegrationCdkApp(block));
117+
return withAws(withTimeout(DEFAULT_TEST_TIMEOUT_S, withSamIntegrationCdkApp(block)));
117118
}
118119

119120
export class SamIntegrationTestFixture extends TestFixture {
@@ -139,7 +140,7 @@ export class SamIntegrationTestFixture extends TestFixture {
139140
args.push('--port');
140141
args.push(port.toString());
141142

142-
return this.samShell(['sam', 'local', 'start-api', ...args], '(Press CTRL+C to quit)', ()=>{
143+
return this.samShell(['sam', 'local', 'start-api', ...args], 'Press CTRL+C to quit', ()=>{
143144
return new Promise<ActionOutput>((resolve, reject) => {
144145
axios.get(`http://127.0.0.1:${port}${apiPath}`).then( resp => {
145146
resolve(resp.data);
@@ -172,7 +173,12 @@ export function randomInteger(min: number, max: number) {
172173
* Is platform-aware, handles errors nicely.
173174
*/
174175
export async function shellWithAction(
175-
command: string[], filter?: string, action?: () => Promise<any>, options: ShellOptions = {}): Promise<ActionOutput> {
176+
command: string[],
177+
filter?: string,
178+
action?: () => Promise<any>,
179+
options: ShellOptions = {},
180+
actionTimeoutSeconds: number = 600,
181+
): Promise<ActionOutput> {
176182
if (options.modEnv && options.env) {
177183
throw new Error('Use either env or modEnv but not both');
178184
}
@@ -198,8 +204,8 @@ export async function shellWithAction(
198204
let actionExecuted = false;
199205

200206
function executeAction(chunk: any) {
201-
out.push(chunk);
202-
if (!actionExecuted && typeof filter === 'string' && out.toString().includes(filter) && typeof action === 'function') {
207+
out.push(Buffer.from(chunk));
208+
if (!actionExecuted && typeof filter === 'string' && Buffer.concat(out).toString('utf-8').includes(filter) && typeof action === 'function') {
203209
actionExecuted = true;
204210
options.output?.write('before executing action');
205211
action().then((output) => {
@@ -217,6 +223,18 @@ export async function shellWithAction(
217223
}
218224
}
219225

226+
if (typeof filter === 'string' && typeof action === 'function') {
227+
// Reject with an error if an action is configured, but the filter failed
228+
// to show up in the output before the timeout occurred.
229+
setTimeout(
230+
() => {
231+
if (!actionExecuted) {
232+
reject(new Error(`Timed out waiting for filter ${JSON.stringify(filter)} to appear in command output after ${actionTimeoutSeconds} seconds\nOutput so far:\n${Buffer.concat(out).toString('utf-8')}`));
233+
}
234+
}, actionTimeoutSeconds * 1_000,
235+
).unref();
236+
}
237+
220238
child.stdout!.on('data', chunk => {
221239
options.output?.write(chunk);
222240
stdout.push(chunk);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Run a block with a timeout
3+
*
4+
* We can't use the jest timeout feature:
5+
*
6+
* - `jest.concurrent()` does not do any concurrency management. It starts all
7+
* tests at the same time.
8+
* - Our tests use locking to make sure only one test is running at a time per
9+
* region.
10+
*
11+
* The wait time for the locks is included in the jest test timeout. We therefore
12+
* need to set it unreasonably high (as long as the last test may need to wait
13+
* if all tests are executed using only 1 region, and they effectively execute
14+
* sequentially), which makes it not useful to detect stuck tests.
15+
*
16+
* The `withTimeout()` modifier makes it possible to measure only a specific
17+
* block of code. In our case: the effective test code, excluding the wait time.
18+
*/
19+
export function withTimeout<A>(seconds: number, block: (x: A) => Promise<void>) {
20+
return (x: A) => {
21+
const timeOut = new Promise<void>((_ok, ko) => {
22+
const timerHandle = setTimeout(
23+
() => ko(new Error(`Timeout: test took more than ${seconds}s to complete`)),
24+
seconds * 1000);
25+
timerHandle.unref();
26+
});
27+
28+
return Promise.race([
29+
block(x),
30+
timeOut,
31+
]);
32+
};
33+
}

packages/@aws-cdk-testing/cli-integ/lib/xpmutex.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export class XpMutex {
141141
// signal due to unfortunate timing.
142142
const wait = this.pool.awaitUnlock(5000);
143143

144-
const lock = await this.acquire();
144+
const lock = await this.tryAcquire();
145145
if (lock) {
146146
// Ignore the wait (count as handled)
147147
wait.then(() => {}, () => {});

packages/@aws-cdk-testing/cli-integ/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
},
4040
"dependencies": {
4141
"@octokit/rest": "^18.12.0",
42-
"aws-sdk": "^2.1325.0",
42+
"aws-sdk": "^2.1329.0",
4343
"axios": "^0.27.2",
4444
"fs-extra": "^9.1.0",
4545
"glob": "^7.2.3",

packages/@aws-cdk-testing/cli-integ/test/resource-pool.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test('double dispose throws', async () => {
3232
const lease = await pool.take();
3333

3434
await lease.dispose();
35-
expect(() => lease.dispose()).toThrow();
35+
await expect(() => lease.dispose()).rejects.toThrow();
3636
});
3737

3838
test('somewhat balance', async () => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { XpMutexPool } from '../lib/xpmutex';
2+
3+
const POOL = XpMutexPool.fromName('test-pool');
4+
5+
test('acquire waits', async () => {
6+
const mux = POOL.mutex('testA');
7+
let secondLockAcquired = false;
8+
9+
// Current "process" acquires lock
10+
const lock = await mux.acquire();
11+
12+
// Start a second "process" that tries to acquire the lock
13+
const secondProcess = (async () => {
14+
const secondLock = await mux.acquire();
15+
try {
16+
secondLockAcquired = true;
17+
} finally {
18+
await secondLock.release();
19+
}
20+
})();
21+
22+
// Once we release the lock the second process is free to take it
23+
expect(secondLockAcquired).toBe(false);
24+
await lock.release();
25+
26+
// We expect the variable to become true
27+
await waitFor(() => secondLockAcquired);
28+
expect(secondLockAcquired).toBe(true);
29+
30+
await secondProcess;
31+
});
32+
33+
34+
/**
35+
* Poll for some condition every 10ms
36+
*/
37+
function waitFor(pred: () => boolean): Promise<void> {
38+
return new Promise((ok) => {
39+
const timerHandle = setInterval(() => {
40+
if (pred()) {
41+
clearInterval(timerHandle);
42+
ok();
43+
}
44+
}, 5);
45+
});
46+
}

packages/@aws-cdk-testing/cli-integ/tests/init-go/init-go.integtest.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { integTest, withTemporaryDirectory, ShellHelper, withPackages } from '..
88
await context.packages.makeCliAvailable();
99

1010
await shell.shell(['cdk', 'init', '-l', 'go', template]);
11-
await shell.shell(['go', 'mod', 'edit', '-replace', 'github.com/aws/aws-cdk-go/awscdk=$dist_root/go/awscdk']);
11+
await shell.shell(['go', 'mod', 'edit', '-replace', 'github.com/aws/aws-cdk-go/awscdk/v2=$CODEBUILD_SRC_DIR/go/awscdk']);
1212
await shell.shell(['go', 'mod', 'tidy']);
1313
await shell.shell(['go', 'test']);
1414
await shell.shell(['cdk', 'synth']);

packages/@aws-cdk/aws-amplify/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
"@aws-cdk/cfn2ts": "0.0.0",
8989
"@aws-cdk/pkglint": "0.0.0",
9090
"@types/jest": "^27.5.2",
91-
"aws-sdk": "^2.1325.0",
91+
"aws-sdk": "^2.1329.0",
9292
"jsii": "v4.9-next"
9393
},
9494
"dependencies": {

0 commit comments

Comments
 (0)