Skip to content

Commit

Permalink
Merge branch 'main' into konokenj/passthrough-physical-resource-id
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Mar 8, 2023
2 parents 1880369 + c897f44 commit 7627dad
Show file tree
Hide file tree
Showing 204 changed files with 8,398 additions and 2,296 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.v2.alpha.md
Expand Up @@ -2,6 +2,26 @@

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.

## [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)


### ⚠ BREAKING CHANGES TO EXPERIMENTAL FEATURES

* **servicecatalogappregistry:** This commit contains destructive changes to the RAM Share.
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.

### Features

* **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)
* **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)
* **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)


### Bug Fixes

* **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)
* **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))

## [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)


Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.v2.md
Expand Up @@ -2,6 +2,18 @@

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.

## [2.68.0](https://github.com/aws/aws-cdk/compare/v2.67.0...v2.68.0) (2023-03-08)


### Bug Fixes

* **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)
* **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)
* **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)
* **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))
* **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)
* **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))

## [2.67.0](https://github.com/aws/aws-cdk/compare/v2.66.1...v2.67.0) (2023-03-02)


Expand Down
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -19,14 +19,14 @@
"@types/node": "18.11.19",
"@types/prettier": "2.6.0",
"@yarnpkg/lockfile": "^1.1.0",
"cdk-generate-synthetic-examples": "^0.1.167",
"cdk-generate-synthetic-examples": "^0.1.173",
"conventional-changelog-cli": "^2.2.2",
"fs-extra": "^9.1.0",
"graceful-fs": "^4.2.10",
"jest-junit": "^13.2.0",
"jsii-diff": "1.76.0",
"jsii-pacmak": "1.76.0",
"jsii-reflect": "1.76.0",
"jsii-diff": "1.77.0",
"jsii-pacmak": "1.77.0",
"jsii-reflect": "1.77.0",
"jsii-rosetta": "v4.9-next",
"lerna": "^4.0.0",
"patch-package": "^6.5.1",
Expand Down
11 changes: 10 additions & 1 deletion packages/@aws-cdk-testing/cli-integ/lib/integ-test.ts
Expand Up @@ -10,6 +10,10 @@ export interface TestContext {
log(s: string): void;
};

if (process.env.JEST_TEST_CONCURRENT === 'true') {
process.stderr.write('ℹ️ JEST_TEST_CONCURRENT is true: tests will run concurrently and filters have no effect!');
}

/**
* A wrapper for jest's 'test' which takes regression-disabled tests into account and prints a banner
*/
Expand All @@ -18,7 +22,6 @@ export function integTest(
callback: (context: TestContext) => Promise<void>,
timeoutMillis?: number,
): void {

// Integ tests can run concurrently, and are responsible for blocking
// themselves if they cannot. Because `test.concurrent` executes the test
// code immediately, regardles of any `--testNamePattern`, this cannot be the
Expand All @@ -35,6 +38,8 @@ export function integTest(
output.write(`${name}\n`);
output.write('================================================================\n');

const now = Date.now();
process.stderr.write(`[INTEG TEST::${name}] Starting (pid ${process.pid})...\n`);
try {
return await callback({
output,
Expand All @@ -44,13 +49,17 @@ export function integTest(
},
});
} catch (e) {
process.stderr.write(`[INTEG TEST::${name}] Failed: ${e}\n`);
output.write(e.message);
output.write(e.stack);
// Print output only if the test fails. Use 'console.log' so the output is buffered by
// jest and prints without a stack trace (if verbose: false).
// eslint-disable-next-line no-console
console.log(output.buffer().toString());
throw e;
} finally {
const duration = Date.now() - now;
process.stderr.write(`[INTEG TEST::${name}] Done (${duration} ms).\n`);
}
}, timeoutMillis);
}
Expand Down
16 changes: 6 additions & 10 deletions packages/@aws-cdk-testing/cli-integ/lib/resource-pool.ts
Expand Up @@ -44,9 +44,12 @@ export class ResourcePool<A extends string=string> {
while (true) {
// Start a wait on the unlock now -- if the unlock signal comes after
// we try to acquire but before we start the wait, we might miss it.
const wait = this.pool.awaitUnlock(5000);
//
// (The timeout is in case the unlock signal doesn't come for whatever reason).
const wait = this.pool.awaitUnlock(10_000);

for (const res of this.unlockedResources()) {
// Try all mutexes, we might need to reacquire an expired lock
for (const res of this.resources) {
const lease = await this.tryObtainLease(res);
if (lease) {
// Ignore the wait (count as handled)
Expand Down Expand Up @@ -86,7 +89,7 @@ export class ResourcePool<A extends string=string> {
let disposed = false;
return {
value,
dispose: () => {
dispose: async () => {
if (disposed) {
throw new Error('Calling dispose() on an already-disposed lease.');
}
Expand All @@ -107,13 +110,6 @@ export class ResourcePool<A extends string=string> {
delete this.locks[value];
await lock?.release();
}

/**
* Return all resources that we definitely don't own the locks for
*/
private unlockedResources(): A[] {
return this.resources.filter(res => !this.locks[res]);
}
}

/**
Expand Down
5 changes: 4 additions & 1 deletion packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts
Expand Up @@ -9,6 +9,9 @@ import { packageSourceInSubprocess } from './package-sources/subprocess';
import { RESOURCES_DIR } from './resources';
import { shell, ShellOptions, ShellHelper, rimraf } from './shell';
import { AwsContext, withAws } from './with-aws';
import { withTimeout } from './with-timeout';

export const DEFAULT_TEST_TIMEOUT_S = 10 * 60;

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

export interface DisableBootstrapContext {
Expand Down
30 changes: 24 additions & 6 deletions packages/@aws-cdk-testing/cli-integ/lib/with-sam.ts
Expand Up @@ -7,7 +7,8 @@ import { TestContext } from './integ-test';
import { RESOURCES_DIR } from './resources';
import { ShellOptions, rimraf } from './shell';
import { AwsContext, withAws } from './with-aws';
import { cloneDirectory, installNpmPackages, TestFixture } from './with-cdk-app';
import { cloneDirectory, installNpmPackages, TestFixture, DEFAULT_TEST_TIMEOUT_S } from './with-cdk-app';
import { withTimeout } from './with-timeout';


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

export class SamIntegrationTestFixture extends TestFixture {
Expand All @@ -139,7 +140,7 @@ export class SamIntegrationTestFixture extends TestFixture {
args.push('--port');
args.push(port.toString());

return this.samShell(['sam', 'local', 'start-api', ...args], '(Press CTRL+C to quit)', ()=>{
return this.samShell(['sam', 'local', 'start-api', ...args], 'Press CTRL+C to quit', ()=>{
return new Promise<ActionOutput>((resolve, reject) => {
axios.get(`http://127.0.0.1:${port}${apiPath}`).then( resp => {
resolve(resp.data);
Expand Down Expand Up @@ -172,7 +173,12 @@ export function randomInteger(min: number, max: number) {
* Is platform-aware, handles errors nicely.
*/
export async function shellWithAction(
command: string[], filter?: string, action?: () => Promise<any>, options: ShellOptions = {}): Promise<ActionOutput> {
command: string[],
filter?: string,
action?: () => Promise<any>,
options: ShellOptions = {},
actionTimeoutSeconds: number = 600,
): Promise<ActionOutput> {
if (options.modEnv && options.env) {
throw new Error('Use either env or modEnv but not both');
}
Expand All @@ -198,8 +204,8 @@ export async function shellWithAction(
let actionExecuted = false;

function executeAction(chunk: any) {
out.push(chunk);
if (!actionExecuted && typeof filter === 'string' && out.toString().includes(filter) && typeof action === 'function') {
out.push(Buffer.from(chunk));
if (!actionExecuted && typeof filter === 'string' && Buffer.concat(out).toString('utf-8').includes(filter) && typeof action === 'function') {
actionExecuted = true;
options.output?.write('before executing action');
action().then((output) => {
Expand All @@ -217,6 +223,18 @@ export async function shellWithAction(
}
}

if (typeof filter === 'string' && typeof action === 'function') {
// Reject with an error if an action is configured, but the filter failed
// to show up in the output before the timeout occurred.
setTimeout(
() => {
if (!actionExecuted) {
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')}`));
}
}, actionTimeoutSeconds * 1_000,
).unref();
}

child.stdout!.on('data', chunk => {
options.output?.write(chunk);
stdout.push(chunk);
Expand Down
33 changes: 33 additions & 0 deletions packages/@aws-cdk-testing/cli-integ/lib/with-timeout.ts
@@ -0,0 +1,33 @@
/**
* Run a block with a timeout
*
* We can't use the jest timeout feature:
*
* - `jest.concurrent()` does not do any concurrency management. It starts all
* tests at the same time.
* - Our tests use locking to make sure only one test is running at a time per
* region.
*
* The wait time for the locks is included in the jest test timeout. We therefore
* need to set it unreasonably high (as long as the last test may need to wait
* if all tests are executed using only 1 region, and they effectively execute
* sequentially), which makes it not useful to detect stuck tests.
*
* The `withTimeout()` modifier makes it possible to measure only a specific
* block of code. In our case: the effective test code, excluding the wait time.
*/
export function withTimeout<A>(seconds: number, block: (x: A) => Promise<void>) {
return (x: A) => {
const timeOut = new Promise<void>((_ok, ko) => {
const timerHandle = setTimeout(
() => ko(new Error(`Timeout: test took more than ${seconds}s to complete`)),
seconds * 1000);
timerHandle.unref();
});

return Promise.race([
block(x),
timeOut,
]);
};
}
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/lib/xpmutex.ts
Expand Up @@ -141,7 +141,7 @@ export class XpMutex {
// signal due to unfortunate timing.
const wait = this.pool.awaitUnlock(5000);

const lock = await this.acquire();
const lock = await this.tryAcquire();
if (lock) {
// Ignore the wait (count as handled)
wait.then(() => {}, () => {});
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/package.json
Expand Up @@ -39,7 +39,7 @@
},
"dependencies": {
"@octokit/rest": "^18.12.0",
"aws-sdk": "^2.1325.0",
"aws-sdk": "^2.1329.0",
"axios": "^0.27.2",
"fs-extra": "^9.1.0",
"glob": "^7.2.3",
Expand Down
Expand Up @@ -32,7 +32,7 @@ test('double dispose throws', async () => {
const lease = await pool.take();

await lease.dispose();
expect(() => lease.dispose()).toThrow();
await expect(() => lease.dispose()).rejects.toThrow();
});

test('somewhat balance', async () => {
Expand Down
46 changes: 46 additions & 0 deletions packages/@aws-cdk-testing/cli-integ/test/xpmutex.test.ts
@@ -0,0 +1,46 @@
import { XpMutexPool } from '../lib/xpmutex';

const POOL = XpMutexPool.fromName('test-pool');

test('acquire waits', async () => {
const mux = POOL.mutex('testA');
let secondLockAcquired = false;

// Current "process" acquires lock
const lock = await mux.acquire();

// Start a second "process" that tries to acquire the lock
const secondProcess = (async () => {
const secondLock = await mux.acquire();
try {
secondLockAcquired = true;
} finally {
await secondLock.release();
}
})();

// Once we release the lock the second process is free to take it
expect(secondLockAcquired).toBe(false);
await lock.release();

// We expect the variable to become true
await waitFor(() => secondLockAcquired);
expect(secondLockAcquired).toBe(true);

await secondProcess;
});


/**
* Poll for some condition every 10ms
*/
function waitFor(pred: () => boolean): Promise<void> {
return new Promise((ok) => {
const timerHandle = setInterval(() => {
if (pred()) {
clearInterval(timerHandle);
ok();
}
}, 5);
});
}
Expand Up @@ -8,7 +8,7 @@ import { integTest, withTemporaryDirectory, ShellHelper, withPackages } from '..
await context.packages.makeCliAvailable();

await shell.shell(['cdk', 'init', '-l', 'go', template]);
await shell.shell(['go', 'mod', 'edit', '-replace', 'github.com/aws/aws-cdk-go/awscdk=$dist_root/go/awscdk']);
await shell.shell(['go', 'mod', 'edit', '-replace', 'github.com/aws/aws-cdk-go/awscdk/v2=$CODEBUILD_SRC_DIR/go/awscdk']);
await shell.shell(['go', 'mod', 'tidy']);
await shell.shell(['go', 'test']);
await shell.shell(['cdk', 'synth']);
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-amplify/package.json
Expand Up @@ -88,7 +88,7 @@
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2",
"aws-sdk": "^2.1325.0",
"aws-sdk": "^2.1329.0",
"jsii": "v4.9-next"
},
"dependencies": {
Expand Down
Expand Up @@ -32,7 +32,7 @@
"@types/aws-lambda": "^8.10.111",
"@types/sinon": "^9.0.11",
"@aws-cdk/cdk-build-tools": "0.0.0",
"aws-sdk": "^2.1325.0",
"aws-sdk": "^2.1329.0",
"aws-sdk-mock": "5.6.0",
"eslint": "^7.32.0",
"eslint-config-standard": "^14.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudfront-origins/package.json
Expand Up @@ -85,7 +85,7 @@
"@aws-cdk/integ-tests": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2",
"aws-sdk": "^2.1325.0"
"aws-sdk": "^2.1329.0"
},
"dependencies": {
"@aws-cdk/aws-apigateway": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudfront/package.json
Expand Up @@ -88,7 +88,7 @@
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2",
"aws-sdk": "^2.1325.0",
"aws-sdk": "^2.1329.0",
"jest": "^27.5.1"
},
"dependencies": {
Expand Down

0 comments on commit 7627dad

Please sign in to comment.