Skip to content

Commit 4be7d70

Browse files
committed
Merge branch 'main' into otaviom/early-validation
# Conflicts: # packages/@aws-cdk/integ-runner/THIRD_PARTY_LICENSES # packages/aws-cdk/THIRD_PARTY_LICENSES # packages/aws-cdk/test/commands/init.test.ts # packages/cdk-assets/THIRD_PARTY_LICENSES
2 parents dd12d3b + 2a6f8d3 commit 4be7d70

25 files changed

+558
-760
lines changed

.github/workflows/integ.yml

Lines changed: 91 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ export interface CdkCliOptions extends ShellOptions {
218218
options?: string[];
219219
neverRequireApproval?: boolean;
220220
verbose?: boolean;
221+
verboseLevel?: number;
221222
telemetryFile?: string;
222223
}
223224

@@ -579,9 +580,19 @@ export class TestFixture extends ShellHelper {
579580
public async cdk(args: string[], options: CdkCliOptions = {}) {
580581
const verbose = options.verbose ?? true;
581582

583+
if (!verbose && options.verboseLevel) {
584+
throw new Error(`Invalid verbose state: verbose is false and verboseLevel is ${options.verboseLevel}`);
585+
}
586+
587+
const verboseLevel = options.verboseLevel ?? 1;
588+
582589
await this.cli.makeCliAvailable();
583590

584-
return this.shell(['cdk', ...(verbose ? ['-v'] : []), ...args], {
591+
return this.shell([
592+
'cdk',
593+
...(verbose ? [`-${'v'.repeat(verboseLevel)}`] : []),
594+
...args,
595+
], {
585596
...options,
586597
modEnv: {
587598
...this.cdkShellEnv(),
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { TELEMETRY_ENDPOINT } from './constants';
2+
import { integTest, withDefaultFixture } from '../../lib';
3+
4+
jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime
5+
6+
integTest(
7+
'CLI Telemetry --disable does not send to endpoint',
8+
withDefaultFixture(async (fixture) => {
9+
const output = await fixture.cdk(['cli-telemetry', '--disable'], { verboseLevel: 3, modEnv: { TELEMETRY_ENDPOINT: TELEMETRY_ENDPOINT } });
10+
11+
// Check the trace that telemetry was not executed successfully
12+
expect(output).not.toContain('Telemetry Sent Successfully');
13+
14+
// Check the trace that endpoint telemetry was never connected
15+
expect(output).toContain('Endpoint Telemetry NOT connected');
16+
}),
17+
);

packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/deploy/cdk-deploy-telemetry.integtest.ts renamed to packages/@aws-cdk-testing/cli-integ/tests/telemetry-integ-tests/cdk-deploy-telemetry.integtest.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as path from 'path';
22
import * as fs from 'fs-extra';
3-
import { integTest, withDefaultFixture } from '../../../lib';
3+
import { TELEMETRY_ENDPOINT } from './constants';
4+
import { integTest, withDefaultFixture } from '../../lib';
45

56
jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime
67

@@ -10,9 +11,15 @@ integTest(
1011
const telemetryFile = path.join(fixture.integTestDir, 'telemetry.json');
1112

1213
// Deploy stack while collecting telemetry
13-
await fixture.cdkDeploy('test-1', {
14+
const deployOutput = await fixture.cdkDeploy('test-1', {
1415
telemetryFile,
16+
verboseLevel: 3, // trace mode
17+
modEnv: { TELEMETRY_ENDPOINT: TELEMETRY_ENDPOINT },
1518
});
19+
20+
// Check the trace that telemetry was executed successfully
21+
expect(deployOutput).toContain('Telemetry Sent Successfully');
22+
1623
const json = fs.readJSONSync(telemetryFile);
1724
expect(json).toEqual([
1825
expect.objectContaining({

packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/synth/cdk-synth-telemetry-with-errors.integtest.ts renamed to packages/@aws-cdk-testing/cli-integ/tests/telemetry-integ-tests/cdk-synth-telemetry-with-errors.integtest.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as path from 'path';
22
import * as fs from 'fs-extra';
3-
import { integTest, withDefaultFixture } from '../../../lib';
3+
import { TELEMETRY_ENDPOINT } from './constants';
4+
import { integTest, withDefaultFixture } from '../../lib';
45

56
jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime
67

@@ -12,19 +13,23 @@ integTest(
1213
allowErrExit: true,
1314
modEnv: {
1415
INTEG_STACK_SET: 'stage-with-errors',
16+
TELEMETRY_ENDPOINT: TELEMETRY_ENDPOINT,
1517
},
18+
verboseLevel: 3, // trace mode
1619
});
1720

1821
expect(output).toContain('This is an error');
1922

23+
// Check the trace that telemetry was executed successfully despite error in synth
24+
expect(output).toContain('Telemetry Sent Successfully');
25+
2026
const json = fs.readJSONSync(telemetryFile);
2127
expect(json).toEqual([
2228
expect.objectContaining({
2329
event: expect.objectContaining({
2430
command: expect.objectContaining({
2531
path: ['synth'],
26-
parameters: {
27-
verbose: 1,
32+
parameters: expect.objectContaining({
2833
unstable: '<redacted>',
2934
['telemetry-file']: '<redacted>',
3035
lookups: true,
@@ -37,7 +42,7 @@ integTest(
3742
validation: true,
3843
quiet: false,
3944
yes: false,
40-
},
45+
}),
4146
config: {
4247
context: {},
4348
},
@@ -72,8 +77,7 @@ integTest(
7277
event: expect.objectContaining({
7378
command: expect.objectContaining({
7479
path: ['synth'],
75-
parameters: {
76-
verbose: 1,
80+
parameters: expect.objectContaining({
7781
unstable: '<redacted>',
7882
['telemetry-file']: '<redacted>',
7983
lookups: true,
@@ -86,7 +90,7 @@ integTest(
8690
validation: true,
8791
quiet: false,
8892
yes: false,
89-
},
93+
}),
9094
config: {
9195
context: {},
9296
},

packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/synth/cdk-synth-telemetry.integtest.ts renamed to packages/@aws-cdk-testing/cli-integ/tests/telemetry-integ-tests/cdk-synth-telemetry.integtest.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
import * as path from 'path';
22
import * as fs from 'fs-extra';
3-
import { integTest, withDefaultFixture } from '../../../lib';
3+
import { TELEMETRY_ENDPOINT } from './constants';
4+
import { integTest, withDefaultFixture } from '../../lib';
45

56
jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime
67

78
integTest(
89
'cdk synth with telemetry data',
910
withDefaultFixture(async (fixture) => {
1011
const telemetryFile = path.join(fixture.integTestDir, `telemetry-${Date.now()}.json`);
11-
await fixture.cdk(['synth', fixture.fullStackName('test-1'), '--unstable=telemetry', `--telemetry-file=${telemetryFile}`]);
12+
13+
const synthOutput = await fixture.cdk(
14+
['synth', fixture.fullStackName('test-1'), '--unstable=telemetry', `--telemetry-file=${telemetryFile}`],
15+
{ modEnv: { TELEMETRY_ENDPOINT: TELEMETRY_ENDPOINT }, verboseLevel: 3 }, // trace mode
16+
);
17+
18+
// Check the trace that telemetry was executed successfully
19+
expect(synthOutput).toContain('Telemetry Sent Successfully');
20+
1221
const json = fs.readJSONSync(telemetryFile);
1322
expect(json).toEqual([
1423
expect.objectContaining({
1524
event: expect.objectContaining({
1625
command: expect.objectContaining({
1726
path: ['synth', '$STACKS_1'],
18-
parameters: {
19-
verbose: 1,
27+
parameters: expect.objectContaining({
2028
unstable: '<redacted>',
2129
['telemetry-file']: '<redacted>',
2230
lookups: true,
@@ -29,7 +37,7 @@ integTest(
2937
validation: true,
3038
quiet: false,
3139
yes: false,
32-
},
40+
}),
3341
config: {
3442
context: {},
3543
},
@@ -65,8 +73,7 @@ integTest(
6573
event: expect.objectContaining({
6674
command: expect.objectContaining({
6775
path: ['synth', '$STACKS_1'],
68-
parameters: {
69-
verbose: 1,
76+
parameters: expect.objectContaining({
7077
unstable: '<redacted>',
7178
['telemetry-file']: '<redacted>',
7279
lookups: true,
@@ -79,7 +86,7 @@ integTest(
7986
validation: true,
8087
quiet: false,
8188
yes: false,
82-
},
89+
}),
8390
config: {
8491
context: {},
8592
},
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const TELEMETRY_ENDPOINT = 'https://cdk-cli-telemetry.us-east-1.api.aws/metrics';

packages/@aws-cdk/cloud-assembly-schema/schema/cloud-assembly.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@
10951095
},
10961096
"propertyMatch": {
10971097
"description": "Returns any resources matching these properties, using `ListResources`.\n\nBy default, specifying propertyMatch will successfully return 0 or more\nresults. To throw an error if the number of results is unexpected (and\nprevent the query results from being committed to context), specify\n`expectedMatchCount`.\n\n## Notes on property completeness\n\nCloudControl API's `ListResources` may return fewer properties than\n`GetResource` would, depending on the resource implementation.\n\nThe resources that `propertyMatch` matches against will *only ever* be the\nproperties returned by the `ListResources` call. (Default - Either exactIdentifier or propertyMatch should be specified.)",
1098-
"$ref": "#/definitions/Record<string,unknown>"
1098+
"$ref": "#/definitions/Record%3Cstring%2Cunknown%3E"
10991099
},
11001100
"propertiesToReturn": {
11011101
"description": "This is a set of properties returned from CC API that we want to return from ContextQuery.\n\nIf any properties listed here are absent from the target resource, an error will be thrown.\n\nThe returned object will always include the key `Identifier` with the CC-API returned\nfield `Identifier`.\n\n## Notes on property completeness\n\nCloudControl API's `ListResources` may return fewer properties than\n`GetResource` would, depending on the resource implementation.\n\nThe returned properties here are *currently* selected from the response\nobject that CloudControl API returns to the CDK CLI.\n\nHowever, if we find there is need to do so, we may decide to change this\nbehavior in the future: we might change it to perform an additional\n`GetResource` call for resources matched by `propertyMatch`.",

packages/@aws-cdk/integ-runner/THIRD_PARTY_LICENSES

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9269,10 +9269,6 @@ Apache License
92699269
limitations under the License.
92709270

92719271

9272-
----------------
9273-
9274-
** @aws-sdk/[email protected] - https://www.npmjs.com/package/@aws-sdk/nested-clients/v/3.893.0 | Apache-2.0
9275-
92769272
----------------
92779273

92789274
** @aws-sdk/[email protected] - https://www.npmjs.com/package/@aws-sdk/nested-clients/v/3.940.0 | Apache-2.0

packages/aws-cdk/THIRD_PARTY_LICENSES

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9269,10 +9269,6 @@ Apache License
92699269
limitations under the License.
92709270

92719271

9272-
----------------
9273-
9274-
** @aws-sdk/[email protected] - https://www.npmjs.com/package/@aws-sdk/nested-clients/v/3.893.0 | Apache-2.0
9275-
92769272
----------------
92779273

92789274
** @aws-sdk/[email protected] - https://www.npmjs.com/package/@aws-sdk/nested-clients/v/3.940.0 | Apache-2.0

0 commit comments

Comments
 (0)