diff --git a/packages/aws-cdk/lib/init.ts b/packages/aws-cdk/lib/init.ts index faf323100bf56..9d2fb0b2c920d 100644 --- a/packages/aws-cdk/lib/init.ts +++ b/packages/aws-cdk/lib/init.ts @@ -296,7 +296,12 @@ async function initializeProject( await template.addMigrateContext(workDir); } if (await fs.pathExists('README.md')) { - print(chalk.green(await fs.readFile('README.md', { encoding: 'utf-8' }))); + const readme = await fs.readFile('README.md', { encoding: 'utf-8' }); + // Save the logs! + // Without this statement, the readme of the CLI is printed in every init test + if (!readme.startsWith('# AWS CDK Toolkit')) { + print(chalk.green(readme)); + } } if (!generateOnly) { diff --git a/packages/aws-cdk/test/api/hotswap/appsync-mapping-templates-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/appsync-mapping-templates-hotswap-deployments.test.ts index 9bc8e6a51f84e..ca45a75f031f1 100644 --- a/packages/aws-cdk/test/api/hotswap/appsync-mapping-templates-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/appsync-mapping-templates-hotswap-deployments.test.ts @@ -2,6 +2,7 @@ import { AppSync, S3 } from 'aws-sdk'; import * as setup from './hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; +import { silentTest } from '../../util/silent'; let hotswapMockSdkProvider: setup.HotswapMockSdkProvider; let mockUpdateResolver: (params: AppSync.UpdateResolverRequest) => AppSync.UpdateResolverResponse; @@ -22,11 +23,10 @@ beforeEach(() => { updateApiKey: mockUpdateApiKey, startSchemaCreation: mockStartSchemaCreation, }); - }); describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hotswapMode) => { - test(`A new Resolver being added to the Stack returns undefined in CLASSIC mode and + silentTest(`A new Resolver being added to the Stack returns undefined in CLASSIC mode and returns a noOp in HOTSWAP_ONLY mode`, async () => { // GIVEN @@ -56,7 +56,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('calls the updateResolver() API when it receives only a mapping template difference in a Unit Resolver', async () => { + silentTest('calls the updateResolver() API when it receives only a mapping template difference in a Unit Resolver', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -122,7 +122,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('calls the updateResolver() API when it receives only a mapping template difference s3 location in a Unit Resolver', async () => { + silentTest('calls the updateResolver() API when it receives only a mapping template difference s3 location in a Unit Resolver', async () => { // GIVEN mockS3GetObject = jest.fn().mockImplementation(async () => { return { Body: 'template defined in s3' }; @@ -196,7 +196,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('calls the updateResolver() API when it receives only a code s3 location in a Pipeline Resolver', async () => { + silentTest('calls the updateResolver() API when it receives only a code s3 location in a Pipeline Resolver', async () => { // GIVEN mockS3GetObject = jest.fn().mockImplementation(async () => { return { Body: 'code defined in s3' }; @@ -267,7 +267,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('calls the updateResolver() API when it receives only a code difference in a Pipeline Resolver', async () => { + silentTest('calls the updateResolver() API when it receives only a code difference in a Pipeline Resolver', async () => { // GIVEN hotswapMockSdkProvider.stubS3({ getObject: mockS3GetObject }); setup.setCurrentCfnStackTemplate({ @@ -331,7 +331,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('calls the updateResolver() API when it receives only a mapping template difference in a Pipeline Resolver', async () => { + silentTest('calls the updateResolver() API when it receives only a mapping template difference in a Pipeline Resolver', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -399,7 +399,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test(`when it receives a change that is not a mapping template difference in a Resolver, it does not call the updateResolver() API in CLASSIC mode + silentTest(`when it receives a change that is not a mapping template difference in a Resolver, it does not call the updateResolver() API in CLASSIC mode but does call the updateResolver() API in HOTSWAP_ONLY mode`, async () => { // GIVEN @@ -465,7 +465,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('does not call the updateResolver() API when a resource with type that is not AWS::AppSync::Resolver but has the same properties is changed', async () => { + silentTest('does not call the updateResolver() API when a resource with type that is not AWS::AppSync::Resolver but has the same properties is changed', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -511,7 +511,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('calls the updateFunction() API when it receives only a mapping template difference in a Function', async () => { + silentTest('calls the updateFunction() API when it receives only a mapping template difference in a Function', async () => { // GIVEN const mockListFunctions = jest.fn().mockReturnValue({ functions: [{ name: 'my-function', functionId: 'functionId' }] }); hotswapMockSdkProvider.stubAppSync({ listFunctions: mockListFunctions, updateFunction: mockUpdateFunction }); @@ -571,7 +571,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('calls the updateFunction() API with function version when it receives both function version and runtime with a mapping template in a Function', async () => { + silentTest('calls the updateFunction() API with function version when it receives both function version and runtime with a mapping template in a Function', async () => { // GIVEN const mockListFunctions = jest.fn().mockReturnValue({ functions: [{ name: 'my-function', functionId: 'functionId' }] }); hotswapMockSdkProvider.stubAppSync({ listFunctions: mockListFunctions, updateFunction: mockUpdateFunction }); @@ -633,7 +633,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('calls the updateFunction() API with runtime when it receives both function version and runtime with code in a Function', async () => { + silentTest('calls the updateFunction() API with runtime when it receives both function version and runtime with code in a Function', async () => { // GIVEN const mockListFunctions = jest.fn().mockReturnValue({ functions: [{ name: 'my-function', functionId: 'functionId' }] }); hotswapMockSdkProvider.stubAppSync({ listFunctions: mockListFunctions, updateFunction: mockUpdateFunction }); @@ -692,7 +692,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('calls the updateFunction() API when it receives only a mapping template s3 location difference in a Function', async () => { + silentTest('calls the updateFunction() API when it receives only a mapping template s3 location difference in a Function', async () => { // GIVEN mockS3GetObject = jest.fn().mockImplementation(async () => { return { Body: 'template defined in s3' }; @@ -760,7 +760,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test(`when it receives a change that is not a mapping template difference in a Function, it does not call the updateFunction() API in CLASSIC mode + silentTest(`when it receives a change that is not a mapping template difference in a Function, it does not call the updateFunction() API in CLASSIC mode but does in HOTSWAP_ONLY mode`, async () => { // GIVEN @@ -823,7 +823,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('does not call the updateFunction() API when a resource with type that is not AWS::AppSync::FunctionConfiguration but has the same properties is changed', async () => { + silentTest('does not call the updateFunction() API when a resource with type that is not AWS::AppSync::FunctionConfiguration but has the same properties is changed', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -871,7 +871,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('calls the startSchemaCreation() API when it receives only a definition difference in a graphql schema', async () => { + silentTest('calls the startSchemaCreation() API when it receives only a definition difference in a graphql schema', async () => { // GIVEN mockStartSchemaCreation = jest.fn().mockReturnValueOnce({ status: 'SUCCESS' }); hotswapMockSdkProvider.stubAppSync({ startSchemaCreation: mockStartSchemaCreation }); @@ -925,7 +925,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('calls the startSchemaCreation() API when it receives only a definition s3 location difference in a graphql schema', async () => { + silentTest('calls the startSchemaCreation() API when it receives only a definition s3 location difference in a graphql schema', async () => { // GIVEN mockS3GetObject = jest.fn().mockImplementation(async () => { return { Body: 'schema defined in s3' }; @@ -988,7 +988,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('does not call startSchemaCreation() API when a resource with type that is not AWS::AppSync::GraphQLSchema but has the same properties is change', async () => { + silentTest('does not call startSchemaCreation() API when a resource with type that is not AWS::AppSync::GraphQLSchema but has the same properties is change', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -1042,7 +1042,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('calls the startSchemaCreation() and waits for schema creation to stabilize before finishing', async () => { + silentTest('calls the startSchemaCreation() and waits for schema creation to stabilize before finishing', async () => { // GIVEN mockStartSchemaCreation = jest.fn().mockReturnValueOnce({ status: 'PROCESSING' }); const mockGetSchemaCreation = jest.fn().mockReturnValueOnce({ status: 'SUCCESS' }); @@ -1100,7 +1100,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('calls the startSchemaCreation() and throws if schema creation fails', async () => { + silentTest('calls the startSchemaCreation() and throws if schema creation fails', async () => { // GIVEN mockStartSchemaCreation = jest.fn().mockReturnValueOnce({ status: 'PROCESSING' }); const mockGetSchemaCreation = jest.fn().mockReturnValueOnce({ status: 'FAILED', details: 'invalid schema' }); @@ -1157,7 +1157,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('calls the updateApiKey() API when it receives only a expires property difference in an AppSync ApiKey', async () => { + silentTest('calls the updateApiKey() API when it receives only a expires property difference in an AppSync ApiKey', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -1211,7 +1211,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('calls the updateApiKey() API when it receives only a expires property difference and no api-key-id in an AppSync ApiKey', async () => { + silentTest('calls the updateApiKey() API when it receives only a expires property difference and no api-key-id in an AppSync ApiKey', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { diff --git a/packages/aws-cdk/test/api/hotswap/code-build-projects-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/code-build-projects-hotswap-deployments.test.ts index 7af2fc6addcc2..aafb28db07a7b 100644 --- a/packages/aws-cdk/test/api/hotswap/code-build-projects-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/code-build-projects-hotswap-deployments.test.ts @@ -1,7 +1,7 @@ -/* eslint-disable import/order */ import { CodeBuild } from 'aws-sdk'; import * as setup from './hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; +import { silentTest } from '../../util/silent'; let hotswapMockSdkProvider: setup.HotswapMockSdkProvider; let mockUpdateProject: (params: CodeBuild.UpdateProjectInput) => CodeBuild.UpdateProjectOutput; @@ -13,7 +13,7 @@ beforeEach(() => { }); describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hotswapMode) => { - test('returns undefined when a new CodeBuild Project is added to the Stack', async () => { + silentTest('returns undefined when a new CodeBuild Project is added to the Stack', async () => { // GIVEN const cdkStackArtifact = setup.cdkStackArtifactOf({ template: { @@ -43,7 +43,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('calls the updateProject() API when it receives only a source difference in a CodeBuild project', async () => { + silentTest('calls the updateProject() API when it receives only a source difference in a CodeBuild project', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -96,7 +96,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('calls the updateProject() API when it receives only a source version difference in a CodeBuild project', async () => { + silentTest('calls the updateProject() API when it receives only a source version difference in a CodeBuild project', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -148,7 +148,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('calls the updateProject() API when it receives only an environment difference in a CodeBuild project', async () => { + silentTest('calls the updateProject() API when it receives only an environment difference in a CodeBuild project', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -254,7 +254,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test("correctly evaluates the project's name when it references a different resource from the template", async () => { + silentTest("correctly evaluates the project's name when it references a different resource from the template", async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -324,7 +324,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test("correctly falls back to taking the project's name from the current stack if it can't evaluate it in the template", async () => { + silentTest("correctly falls back to taking the project's name from the current stack if it can't evaluate it in the template", async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Parameters: { @@ -386,7 +386,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test("will not perform a hotswap deployment if it cannot find a Ref target (outside the project's name)", async () => { + silentTest("will not perform a hotswap deployment if it cannot find a Ref target (outside the project's name)", async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Parameters: { @@ -436,7 +436,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot ).rejects.toThrow(/Parameter or resource 'Param1' could not be found for evaluation/); }); - test("will not perform a hotswap deployment if it doesn't know how to handle a specific attribute (outside the project's name)", async () => { + silentTest("will not perform a hotswap deployment if it doesn't know how to handle a specific attribute (outside the project's name)", async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -489,7 +489,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot ).rejects.toThrow("We don't support the 'UnknownAttribute' attribute of the 'AWS::S3::Bucket' resource. This is a CDK limitation. Please report it at https://github.com/aws/aws-cdk/issues/new/choose"); }); - test('calls the updateProject() API when it receives a difference in a CodeBuild project with no name', async () => { + silentTest('calls the updateProject() API when it receives a difference in a CodeBuild project with no name', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -541,7 +541,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('does not call the updateProject() API when it receives a change that is not Source, SourceVersion, or Environment difference in a CodeBuild project', async () => { + silentTest('does not call the updateProject() API when it receives a change that is not Source, SourceVersion, or Environment difference in a CodeBuild project', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -592,7 +592,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test(`when it receives a change that is not Source, SourceVersion, or Environment difference in a CodeBuild project alongside a hotswappable change, + silentTest(`when it receives a change that is not Source, SourceVersion, or Environment difference in a CodeBuild project alongside a hotswappable change, it does not call the updateProject() API in CLASSIC mode, but it does in HOTSWAP_ONLY mode`, async () => { // GIVEN @@ -650,7 +650,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); } }); - test('does not call the updateProject() API when a resource with type that is not AWS::CodeBuild::Project but has the same properties is changed', async () => { + silentTest('does not call the updateProject() API when a resource with type that is not AWS::CodeBuild::Project but has the same properties is changed', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { diff --git a/packages/aws-cdk/test/api/hotswap/ecs-services-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/ecs-services-hotswap-deployments.test.ts index e0267635a59d8..d1ef496819328 100644 --- a/packages/aws-cdk/test/api/hotswap/ecs-services-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/ecs-services-hotswap-deployments.test.ts @@ -1,7 +1,7 @@ -/* eslint-disable import/order */ import * as AWS from 'aws-sdk'; import * as setup from './hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; +import { silentTest } from '../../util/silent'; let hotswapMockSdkProvider: setup.HotswapMockSdkProvider; let mockRegisterTaskDef: jest.Mock; @@ -31,7 +31,7 @@ beforeEach(() => { }); describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hotswapMode) => { - test('should call registerTaskDefinition and updateService for a difference only in the TaskDefinition with a Family property', async () => { + silentTest('should call registerTaskDefinition and updateService for a difference only in the TaskDefinition with a Family property', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -105,7 +105,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('any other TaskDefinition property change besides ContainerDefinition cannot be hotswapped in CLASSIC mode but does not block HOTSWAP_ONLY mode deployments', async () => { + silentTest('any other TaskDefinition property change besides ContainerDefinition cannot be hotswapped in CLASSIC mode but does not block HOTSWAP_ONLY mode deployments', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -192,7 +192,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('deleting any other TaskDefinition property besides ContainerDefinition results in a full deployment in CLASSIC mode and a hotswap deployment in HOTSWAP_ONLY mode', async () => { + silentTest('deleting any other TaskDefinition property besides ContainerDefinition results in a full deployment in CLASSIC mode and a hotswap deployment in HOTSWAP_ONLY mode', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -278,7 +278,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('should call registerTaskDefinition and updateService for a difference only in the TaskDefinition without a Family property', async () => { + silentTest('should call registerTaskDefinition and updateService for a difference only in the TaskDefinition without a Family property', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -352,7 +352,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('a difference just in a TaskDefinition, without any services using it, is not hotswappable in FALL_BACK mode', async () => { + silentTest('a difference just in a TaskDefinition, without any services using it, is not hotswappable in FALL_BACK mode', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -415,7 +415,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('if anything besides an ECS Service references the changed TaskDefinition, hotswapping is not possible in CLASSIC mode but is possible in HOTSWAP_ONLY', async () => { + silentTest('if anything besides an ECS Service references the changed TaskDefinition, hotswapping is not possible in CLASSIC mode but is possible in HOTSWAP_ONLY', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -519,7 +519,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('should call registerTaskDefinition with certain properties not lowercased', async () => { + silentTest('should call registerTaskDefinition with certain properties not lowercased', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { diff --git a/packages/aws-cdk/test/api/hotswap/hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/hotswap-deployments.test.ts index c310c86d4b6b5..a2c7a65424712 100644 --- a/packages/aws-cdk/test/api/hotswap/hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/hotswap-deployments.test.ts @@ -1,8 +1,8 @@ -/* eslint-disable import/order */ import { Lambda, StepFunctions } from 'aws-sdk'; import * as setup from './hotswap-test-setup'; import { CfnEvaluationException } from '../../../lib/api/evaluate-cloudformation-template'; import { HotswapMode } from '../../../lib/api/hotswap/common'; +import { silentTest } from '../../util/silent'; let hotswapMockSdkProvider: setup.HotswapMockSdkProvider; let mockUpdateLambdaCode: (params: Lambda.Types.UpdateFunctionCodeRequest) => Lambda.Types.FunctionConfiguration; @@ -22,7 +22,7 @@ beforeEach(() => { }); describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hotswapMode) => { - test('returns a deployStackResult with noOp=true when it receives an empty set of changes', async () => { + silentTest('returns a deployStackResult with noOp=true when it receives an empty set of changes', async () => { // WHEN const deployStackResult = await hotswapMockSdkProvider.tryHotswapDeployment(hotswapMode, setup.cdkStackArtifactOf()); @@ -32,7 +32,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot expect(deployStackResult?.stackArn).toEqual(setup.STACK_ID); }); - test('A change to only a non-hotswappable resource results in a full deployment for HOTSWAP and a noOp for HOTSWAP_ONLY', async () => { + silentTest('A change to only a non-hotswappable resource results in a full deployment for HOTSWAP and a noOp for HOTSWAP_ONLY', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -77,7 +77,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('A change to both a hotswappable resource and a non-hotswappable resource results in a full deployment for HOTSWAP and a noOp for HOTSWAP_ONLY', async () => { + silentTest('A change to both a hotswappable resource and a non-hotswappable resource results in a full deployment for HOTSWAP and a noOp for HOTSWAP_ONLY', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -151,7 +151,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('changes only to CDK::Metadata result in a noOp', async () => { + silentTest('changes only to CDK::Metadata result in a noOp', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -186,7 +186,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot expect(mockUpdateLambdaCode).not.toHaveBeenCalled(); }); - test('resource deletions require full deployments for HOTSWAP and a noOp for HOTSWAP_ONLY', async () => { + silentTest('resource deletions require full deployments for HOTSWAP and a noOp for HOTSWAP_ONLY', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -217,7 +217,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('can correctly reference AWS::Partition in hotswappable changes', async () => { + silentTest('can correctly reference AWS::Partition in hotswappable changes', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -286,7 +286,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('can correctly reference AWS::URLSuffix in hotswappable changes', async () => { + silentTest('can correctly reference AWS::URLSuffix in hotswappable changes', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -358,7 +358,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot .toHaveBeenCalledWith('cdk-hotswap/success-lambda'); }); - test('changing the type of a deployed resource always results in a full deployment for HOTSWAP and a noOp for HOTSWAP_ONLY', async () => { + silentTest('changing the type of a deployed resource always results in a full deployment for HOTSWAP and a noOp for HOTSWAP_ONLY', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -408,7 +408,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('A change to both a hotswappable resource and a stack output results in a full deployment for HOTSWAP and a hotswap deployment for HOTSWAP_ONLY', async () => { + silentTest('A change to both a hotswappable resource and a stack output results in a full deployment for HOTSWAP and a hotswap deployment for HOTSWAP_ONLY', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -480,7 +480,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('Multiple CfnEvaluationException will not cause unhandled rejections', async () => { + silentTest('Multiple CfnEvaluationException will not cause unhandled rejections', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -566,7 +566,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot expect(mockUpdateLambdaCode).not.toHaveBeenCalled(); }); - test('deleting a resource and making a hotswappable change results in full deployments for HOTSWAP and a hotswap deployment for HOTSWAP_ONLY', async () => { + silentTest('deleting a resource and making a hotswappable change results in full deployments for HOTSWAP and a hotswap deployment for HOTSWAP_ONLY', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -631,7 +631,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('can correctly reference Fn::ImportValue in hotswappable changes', async () => { + silentTest('can correctly reference Fn::ImportValue in hotswappable changes', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { diff --git a/packages/aws-cdk/test/api/hotswap/hotswap-test-setup.ts b/packages/aws-cdk/test/api/hotswap/hotswap-test-setup.ts index 63bded36370f1..505f128a0dee2 100644 --- a/packages/aws-cdk/test/api/hotswap/hotswap-test-setup.ts +++ b/packages/aws-cdk/test/api/hotswap/hotswap-test-setup.ts @@ -1,4 +1,3 @@ -/* eslint-disable import/order */ import * as cxapi from '@aws-cdk/cx-api'; import * as AWS from 'aws-sdk'; import * as codebuild from 'aws-sdk/clients/codebuild'; diff --git a/packages/aws-cdk/test/api/hotswap/iam-policy-hotswap-deployment.test.ts b/packages/aws-cdk/test/api/hotswap/iam-policy-hotswap-deployment.test.ts index 0f36d8d09efff..4847ff6718bc2 100644 --- a/packages/aws-cdk/test/api/hotswap/iam-policy-hotswap-deployment.test.ts +++ b/packages/aws-cdk/test/api/hotswap/iam-policy-hotswap-deployment.test.ts @@ -1,6 +1,7 @@ /* eslint-disable import/order */ import * as setup from './hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; +import { silentTest } from '../../util/silent'; let hotswapMockSdkProvider: setup.HotswapMockSdkProvider; @@ -9,7 +10,7 @@ beforeEach(() => { }); describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hotswapMode) => { - test('A change to an IAM Policy results in a full deployment for HOTSWAP and a noOp for HOTSWAP_ONLY', async () => { + silentTest('A change to an IAM Policy results in a full deployment for HOTSWAP and a noOp for HOTSWAP_ONLY', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { diff --git a/packages/aws-cdk/test/api/hotswap/lambda-functions-docker-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/lambda-functions-docker-hotswap-deployments.test.ts index b599d41301dc0..adabd260cd1ff 100644 --- a/packages/aws-cdk/test/api/hotswap/lambda-functions-docker-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/lambda-functions-docker-hotswap-deployments.test.ts @@ -1,7 +1,7 @@ -/* eslint-disable import/order */ import { Lambda } from 'aws-sdk'; import * as setup from './hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; +import { silentTest } from '../../util/silent'; let mockUpdateLambdaCode: (params: Lambda.Types.UpdateFunctionCodeRequest) => Lambda.Types.FunctionConfiguration; let mockTagResource: (params: Lambda.Types.TagResourceRequest) => {}; @@ -31,7 +31,7 @@ beforeEach(() => { }); describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hotswapMode) => { - test('calls the updateLambdaCode() API when it receives only a code difference in a Lambda function', async () => { + silentTest('calls the updateLambdaCode() API when it receives only a code difference in a Lambda function', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -79,7 +79,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('calls the getFunction() API with a delay of 5', async () => { + silentTest('calls the getFunction() API with a delay of 5', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { diff --git a/packages/aws-cdk/test/api/hotswap/lambda-functions-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/lambda-functions-hotswap-deployments.test.ts index e4eff93a3d155..85c3601f73e68 100644 --- a/packages/aws-cdk/test/api/hotswap/lambda-functions-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/lambda-functions-hotswap-deployments.test.ts @@ -1,7 +1,7 @@ -/* eslint-disable import/order */ import { Lambda } from 'aws-sdk'; import * as setup from './hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; +import { silentTest } from '../../util/silent'; let mockUpdateLambdaCode: (params: Lambda.Types.UpdateFunctionCodeRequest) => Lambda.Types.FunctionConfiguration; let mockUpdateLambdaConfiguration: ( @@ -28,7 +28,7 @@ beforeEach(() => { }); describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hotswapMode) => { - test('returns undefined when a new Lambda function is added to the Stack', async () => { + silentTest('returns undefined when a new Lambda function is added to the Stack', async () => { // GIVEN const cdkStackArtifact = setup.cdkStackArtifactOf({ template: { @@ -57,7 +57,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('calls the updateLambdaCode() API when it receives only a code difference in a Lambda function', async () => { + silentTest('calls the updateLambdaCode() API when it receives only a code difference in a Lambda function', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -108,7 +108,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test("correctly evaluates the function's name when it references a different resource from the template", async () => { + silentTest("correctly evaluates the function's name when it references a different resource from the template", async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -178,7 +178,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test("correctly falls back to taking the function's name from the current stack if it can't evaluate it in the template", async () => { + silentTest("correctly falls back to taking the function's name from the current stack if it can't evaluate it in the template", async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Parameters: { @@ -238,7 +238,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test("will not perform a hotswap deployment if it cannot find a Ref target (outside the function's name)", async () => { + silentTest("will not perform a hotswap deployment if it cannot find a Ref target (outside the function's name)", async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Parameters: { @@ -288,7 +288,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot ).rejects.toThrow(/Parameter or resource 'Param1' could not be found for evaluation/); }); - test("will not perform a hotswap deployment if it doesn't know how to handle a specific attribute (outside the function's name)", async () => { + silentTest("will not perform a hotswap deployment if it doesn't know how to handle a specific attribute (outside the function's name)", async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -341,7 +341,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot ).rejects.toThrow("We don't support the 'UnknownAttribute' attribute of the 'AWS::S3::Bucket' resource. This is a CDK limitation. Please report it at https://github.com/aws/aws-cdk/issues/new/choose"); }); - test('calls the updateLambdaCode() API when it receives a code difference in a Lambda function with no name', async () => { + silentTest('calls the updateLambdaCode() API when it receives a code difference in a Lambda function with no name', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -391,7 +391,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('does not call the updateLambdaCode() API when it receives a change that is not a code difference in a Lambda function', async () => { + silentTest('does not call the updateLambdaCode() API when it receives a change that is not a code difference in a Lambda function', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -442,7 +442,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test(`when it receives a non-hotswappable change that includes a code difference in a Lambda function, it does not call the updateLambdaCode() + silentTest(`when it receives a non-hotswappable change that includes a code difference in a Lambda function, it does not call the updateLambdaCode() API in CLASSIC mode but does in HOTSWAP_ONLY mode`, async () => { // GIVEN @@ -500,7 +500,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('does not call the updateLambdaCode() API when a resource with type that is not AWS::Lambda::Function but has the same properties is changed', async () => { + silentTest('does not call the updateLambdaCode() API when a resource with type that is not AWS::Lambda::Function but has the same properties is changed', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -555,7 +555,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('calls getFunction() after function code is updated with delay 1', async () => { + silentTest('calls getFunction() after function code is updated with delay 1', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -607,7 +607,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot })); }); - test('calls getFunction() after function code is updated and VpcId is empty string with delay 1', async () => { + silentTest('calls getFunction() after function code is updated and VpcId is empty string with delay 1', async () => { // GIVEN mockUpdateLambdaCode = jest.fn().mockReturnValue({ VpcConfig: { @@ -666,7 +666,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot })); }); - test('calls getFunction() after function code is updated on a VPC function with delay 5', async () => { + silentTest('calls getFunction() after function code is updated on a VPC function with delay 5', async () => { // GIVEN mockUpdateLambdaCode = jest.fn().mockReturnValue({ VpcConfig: { @@ -725,7 +725,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot })); }); - test('calls the updateLambdaConfiguration() API when it receives difference in Description field of a Lambda function', async () => { + silentTest('calls the updateLambdaConfiguration() API when it receives difference in Description field of a Lambda function', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -777,7 +777,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('calls the updateLambdaConfiguration() API when it receives difference in Environment field of a Lambda function', async () => { + silentTest('calls the updateLambdaConfiguration() API when it receives difference in Environment field of a Lambda function', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -846,7 +846,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('calls both updateLambdaCode() and updateLambdaConfiguration() API when it receives both code and configuration change', async () => { + silentTest('calls both updateLambdaCode() and updateLambdaConfiguration() API when it receives both code and configuration change', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -903,7 +903,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('Lambda hotswap works properly with changes of environment variables and description with tokens', async () => { + silentTest('Lambda hotswap works properly with changes of environment variables and description with tokens', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -1000,7 +1000,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('S3ObjectVersion is hotswappable', async () => { + silentTest('S3ObjectVersion is hotswappable', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { diff --git a/packages/aws-cdk/test/api/hotswap/lambda-functions-inline-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/lambda-functions-inline-hotswap-deployments.test.ts index fcee93246edbf..fc3b78c8c5190 100644 --- a/packages/aws-cdk/test/api/hotswap/lambda-functions-inline-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/lambda-functions-inline-hotswap-deployments.test.ts @@ -1,8 +1,8 @@ -/* eslint-disable import/order */ +import { Runtime } from 'aws-cdk-lib/aws-lambda'; import { Lambda } from 'aws-sdk'; import * as setup from './hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; -import { Runtime } from 'aws-cdk-lib/aws-lambda'; +import { silentTest } from '../../util/silent'; let mockUpdateLambdaCode: (params: Lambda.Types.UpdateFunctionCodeRequest) => Lambda.Types.FunctionConfiguration; let mockTagResource: (params: Lambda.Types.TagResourceRequest) => {}; @@ -22,7 +22,7 @@ beforeEach(() => { }); describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('these tests do not depend on the hotswap type', (hotswapMode) => { - test('calls the updateLambdaCode() API when it receives only a code difference in a Lambda function (Inline Node.js code)', async () => { + silentTest('calls the updateLambdaCode() API when it receives only a code difference in a Lambda function (Inline Node.js code)', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -67,7 +67,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('these tests do }); }); - test('calls the updateLambdaCode() API when it receives only a code difference in a Lambda function (Inline Python code)', async () => { + silentTest('calls the updateLambdaCode() API when it receives only a code difference in a Lambda function (Inline Python code)', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -111,7 +111,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('these tests do }); }); - test('throw a CfnEvaluationException when it receives an unsupported function runtime', async () => { + silentTest('throw a CfnEvaluationException when it receives an unsupported function runtime', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { diff --git a/packages/aws-cdk/test/api/hotswap/lambda-versions-aliases-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/lambda-versions-aliases-hotswap-deployments.test.ts index 16f1db3851f98..7840227e255a7 100644 --- a/packages/aws-cdk/test/api/hotswap/lambda-versions-aliases-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/lambda-versions-aliases-hotswap-deployments.test.ts @@ -1,7 +1,7 @@ -/* eslint-disable import/order */ import { Lambda } from 'aws-sdk'; import * as setup from './hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; +import { silentTest } from '../../util/silent'; let mockUpdateLambdaCode: (params: Lambda.Types.UpdateFunctionCodeRequest) => Lambda.Types.FunctionConfiguration; let mockPublishVersion: jest.Mock; @@ -22,7 +22,7 @@ beforeEach(() => { }); describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hotswapMode) => { - test('hotswaps a Version if it points to a changed Function, even if it itself is unchanged', async () => { + silentTest('hotswaps a Version if it points to a changed Function, even if it itself is unchanged', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -77,7 +77,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('hotswaps a Version if it points to a changed Function, even if it itself is replaced', async () => { + silentTest('hotswaps a Version if it points to a changed Function, even if it itself is replaced', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -132,7 +132,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('hotswaps a Version and an Alias if the Function they point to changed', async () => { + silentTest('hotswaps a Version and an Alias if the Function they point to changed', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { diff --git a/packages/aws-cdk/test/api/hotswap/nested-stacks-hotswap.test.ts b/packages/aws-cdk/test/api/hotswap/nested-stacks-hotswap.test.ts index 318638b72000c..53d11b79d6db7 100644 --- a/packages/aws-cdk/test/api/hotswap/nested-stacks-hotswap.test.ts +++ b/packages/aws-cdk/test/api/hotswap/nested-stacks-hotswap.test.ts @@ -1,15 +1,15 @@ -/* eslint-disable import/order */ import { Lambda } from 'aws-sdk'; import * as setup from './hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; import { testStack } from '../../util'; +import { silentTest } from '../../util/silent'; let mockUpdateLambdaCode: (params: Lambda.Types.UpdateFunctionCodeRequest) => Lambda.Types.FunctionConfiguration; let mockPublishVersion: jest.Mock; let hotswapMockSdkProvider: setup.HotswapMockSdkProvider; describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hotswapMode) => { - test('can hotswap a lambda function in a 1-level nested stack', async () => { + silentTest('can hotswap a lambda function in a 1-level nested stack', async () => { // GIVEN hotswapMockSdkProvider = setup.setupHotswapNestedStackTests('LambdaRoot'); mockUpdateLambdaCode = jest.fn().mockReturnValue({}); @@ -76,7 +76,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('hotswappable changes do not override hotswappable changes in their ancestors', async () => { + silentTest('hotswappable changes do not override hotswappable changes in their ancestors', async () => { // GIVEN hotswapMockSdkProvider = setup.setupHotswapNestedStackTests('TwoLevelLambdaRoot'); mockUpdateLambdaCode = jest.fn().mockReturnValue({}); @@ -190,7 +190,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('hotswappable changes in nested stacks do not override hotswappable changes in their parent stack', async () => { + silentTest('hotswappable changes in nested stacks do not override hotswappable changes in their parent stack', async () => { // GIVEN hotswapMockSdkProvider = setup.setupHotswapNestedStackTests('SiblingLambdaRoot'); mockUpdateLambdaCode = jest.fn().mockReturnValue({}); @@ -277,7 +277,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test(`non-hotswappable changes in nested stacks result in a full deployment, even if their parent contains a hotswappable change in CLASSIC mode, + silentTest(`non-hotswappable changes in nested stacks result in a full deployment, even if their parent contains a hotswappable change in CLASSIC mode, but perform a hotswap deployment in HOTSWAP_ONLY`, async () => { // GIVEN @@ -372,7 +372,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test(`deleting a nested stack results in a full deployment in CLASSIC mode, even if their parent contains a hotswappable change, + silentTest(`deleting a nested stack results in a full deployment in CLASSIC mode, even if their parent contains a hotswappable change, but results in a hotswap deployment in HOTSWAP_ONLY mode`, async () => { // GIVEN @@ -465,7 +465,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test(`creating a nested stack results in a full deployment in CLASSIC mode, even if their parent contains a hotswappable change, + silentTest(`creating a nested stack results in a full deployment in CLASSIC mode, even if their parent contains a hotswappable change, but results in a hotswap deployment in HOTSWAP_ONLY mode`, async () => { // GIVEN @@ -533,7 +533,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test(`attempting to hotswap a newly created nested stack with the same logical ID as a resource with a different type results in a full deployment in CLASSIC mode + silentTest(`attempting to hotswap a newly created nested stack with the same logical ID as a resource with a different type results in a full deployment in CLASSIC mode and a hotswap deployment in HOTSWAP_ONLY mode`, async () => { // GIVEN @@ -614,7 +614,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('multi-sibling + 3-layer nested stack structure is hotswappable', async () => { + silentTest('multi-sibling + 3-layer nested stack structure is hotswappable', async () => { // GIVEN hotswapMockSdkProvider = setup.setupHotswapNestedStackTests('MultiLayerRoot'); mockUpdateLambdaCode = jest.fn().mockReturnValue({}); @@ -757,7 +757,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('can hotswap a lambda function in a 1-level nested stack with asset parameters', async () => { + silentTest('can hotswap a lambda function in a 1-level nested stack with asset parameters', async () => { // GIVEN hotswapMockSdkProvider = setup.setupHotswapNestedStackTests('LambdaRoot'); mockUpdateLambdaCode = jest.fn().mockReturnValue({}); @@ -845,7 +845,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('can hotswap a lambda function in a 2-level nested stack with dependency on an output of 2nd level sibling stack', async () => { + silentTest('can hotswap a lambda function in a 2-level nested stack with dependency on an output of 2nd level sibling stack', async () => { // GIVEN: RootStack has one child stack `FirstLevelNestedStack` which further has two child stacks // `NestedLambdaStack` and `NestedSiblingStack`. `NestedLambdaStack` takes two parameters s3Key // and s3Bucket and use them for a Lambda function. @@ -1000,7 +1000,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('can hotswap a lambda function in a 1-level nested stack and read default parameters value if not provided', async () => { + silentTest('can hotswap a lambda function in a 1-level nested stack and read default parameters value if not provided', async () => { // GIVEN: RootStack has one child stack `NestedStack`. `NestedStack` takes two // parameters s3Key and s3Bucket and use them for a Lambda function. // RootStack resolves both parameters from root template parameters. Current/old change @@ -1091,7 +1091,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('can hotswap a lambda function in a 2-level nested stack with asset parameters', async () => { + silentTest('can hotswap a lambda function in a 2-level nested stack with asset parameters', async () => { // GIVEN hotswapMockSdkProvider = setup.setupHotswapNestedStackTests('LambdaRoot'); mockUpdateLambdaCode = jest.fn().mockReturnValue({}); @@ -1238,7 +1238,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('looking up objects in nested stacks works', async () => { + silentTest('looking up objects in nested stacks works', async () => { hotswapMockSdkProvider = setup.setupHotswapNestedStackTests('LambdaRoot'); mockUpdateLambdaCode = jest.fn().mockReturnValue({}); mockPublishVersion = jest.fn(); diff --git a/packages/aws-cdk/test/api/hotswap/s3-bucket-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/s3-bucket-hotswap-deployments.test.ts index b0a9662b1d1ac..56432fcb6f603 100644 --- a/packages/aws-cdk/test/api/hotswap/s3-bucket-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/s3-bucket-hotswap-deployments.test.ts @@ -1,8 +1,8 @@ -/* eslint-disable import/order */ import { Lambda } from 'aws-sdk'; import * as setup from './hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; import { REQUIRED_BY_CFN } from '../../../lib/api/hotswap/s3-bucket-deployments'; +import { silentTest } from '../../util/silent'; let mockLambdaInvoke: (params: Lambda.Types.InvocationRequest) => Lambda.Types.InvocationResponse; let hotswapMockSdkProvider: setup.HotswapMockSdkProvider; @@ -23,7 +23,7 @@ beforeEach(() => { }); describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hotswapMode) => { - test('calls the lambdaInvoke() API when it receives only an asset difference in an S3 bucket deployment and evaluates CFN expressions in S3 Deployment Properties', async () => { + silentTest('calls the lambdaInvoke() API when it receives only an asset difference in an S3 bucket deployment and evaluates CFN expressions in S3 Deployment Properties', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -81,7 +81,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('does not call the invoke() API when a resource with type that is not Custom::CDKBucketDeployment but has the same properties is changed', async () => { + silentTest('does not call the invoke() API when a resource with type that is not Custom::CDKBucketDeployment but has the same properties is changed', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -124,7 +124,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('does not call the invokeLambda() api if the updated Policy has no Roles in CLASSIC mode but does in HOTSWAP_ONLY mode', async () => { + silentTest('does not call the invokeLambda() api if the updated Policy has no Roles in CLASSIC mode but does in HOTSWAP_ONLY mode', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Parameters: { @@ -224,7 +224,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('throws an error when the serviceToken fails evaluation in the template', async () => { + silentTest('throws an error when the serviceToken fails evaluation in the template', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -423,7 +423,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot ); }); - test('calls the lambdaInvoke() API when it receives an asset difference in an S3 bucket deployment and an IAM Policy difference using old-style synthesis', async () => { + silentTest('calls the lambdaInvoke() API when it receives an asset difference in an S3 bucket deployment and an IAM Policy difference using old-style synthesis', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -465,7 +465,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test(`does not call the lambdaInvoke() API when the difference in the S3 deployment is referred to in one IAM policy change but not another + silentTest(`does not call the lambdaInvoke() API when the difference in the S3 deployment is referred to in one IAM policy change but not another in CLASSIC mode but does in HOTSWAP_ONLY`, async () => { // GIVEN @@ -539,7 +539,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test(`does not call the lambdaInvoke() API when the lambda that references the role is referred to by something other than an S3 deployment + silentTest(`does not call the lambdaInvoke() API when the lambda that references the role is referred to by something other than an S3 deployment in CLASSIC mode but does in HOTSWAP_ONLY mode`, async () => { // GIVEN @@ -616,7 +616,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('calls the lambdaInvoke() API when it receives an asset difference in two S3 bucket deployments and IAM Policy differences using old-style synthesis', async () => { + silentTest('calls the lambdaInvoke() API when it receives an asset difference in two S3 bucket deployments and IAM Policy differences using old-style synthesis', async () => { // GIVEN const deploymentLambda2Old = { Type: 'AWS::Lambda::Function', @@ -736,7 +736,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test(`does not call the lambdaInvoke() API when it receives an asset difference in an S3 bucket deployment that references two different policies + silentTest(`does not call the lambdaInvoke() API when it receives an asset difference in an S3 bucket deployment that references two different policies in CLASSIC mode but does in HOTSWAP_ONLY mode`, async () => { // GIVEN @@ -809,7 +809,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test(`does not call the lambdaInvoke() API when a policy is referenced by a resource that is not an S3 deployment + silentTest(`does not call the lambdaInvoke() API when a policy is referenced by a resource that is not an S3 deployment in CLASSIC mode but does in HOTSWAP_ONLY mode`, async () => { // GIVEN diff --git a/packages/aws-cdk/test/api/hotswap/state-machine-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/state-machine-hotswap-deployments.test.ts index 053e490502412..f5c31bc2cee87 100644 --- a/packages/aws-cdk/test/api/hotswap/state-machine-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/state-machine-hotswap-deployments.test.ts @@ -1,7 +1,7 @@ -/* eslint-disable import/order */ import { StepFunctions } from 'aws-sdk'; import * as setup from './hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; +import { silentTest } from '../../util/silent'; let mockUpdateMachineDefinition: (params: StepFunctions.Types.UpdateStateMachineInput) => StepFunctions.Types.UpdateStateMachineOutput; let hotswapMockSdkProvider: setup.HotswapMockSdkProvider; @@ -13,7 +13,7 @@ beforeEach(() => { }); describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hotswapMode) => { - test('returns undefined when a new StateMachine is added to the Stack', async () => { + silentTest('returns undefined when a new StateMachine is added to the Stack', async () => { // GIVEN const cdkStackArtifact = setup.cdkStackArtifactOf({ template: { @@ -43,7 +43,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('calls the updateStateMachine() API when it receives only a definitionString change without Fn::Join in a state machine', async () => { + silentTest('calls the updateStateMachine() API when it receives only a definitionString change without Fn::Join in a state machine', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -81,7 +81,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('calls the updateStateMachine() API when it receives only a definitionString change with Fn::Join in a state machine', async () => { + silentTest('calls the updateStateMachine() API when it receives only a definitionString change with Fn::Join in a state machine', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -156,7 +156,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('calls the updateStateMachine() API when it receives a change to the definitionString in a state machine that has no name', async () => { + silentTest('calls the updateStateMachine() API when it receives a change to the definitionString in a state machine that has no name', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -193,7 +193,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test(`does not call the updateStateMachine() API when it receives a change to a property that is not the definitionString in a state machine + silentTest(`does not call the updateStateMachine() API when it receives a change to a property that is not the definitionString in a state machine alongside a hotswappable change in CLASSIC mode but does in HOTSWAP_ONLY mode`, async () => { // GIVEN @@ -247,7 +247,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('does not call the updateStateMachine() API when a resource has a DefinitionString property but is not an AWS::StepFunctions::StateMachine is changed', async () => { + silentTest('does not call the updateStateMachine() API when a resource has a DefinitionString property but is not an AWS::StepFunctions::StateMachine is changed', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -290,7 +290,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot } }); - test('can correctly hotswap old style synth changes', async () => { + silentTest('can correctly hotswap old style synth changes', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Parameters: { AssetParam1: { Type: 'String' } }, @@ -331,7 +331,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('calls the updateStateMachine() API when it receives a change to the definitionString that uses Attributes in a state machine', async () => { + silentTest('calls the updateStateMachine() API when it receives a change to the definitionString that uses Attributes in a state machine', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -401,7 +401,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test("will not perform a hotswap deployment if it cannot find a Ref target (outside the state machine's name)", async () => { + silentTest("will not perform a hotswap deployment if it cannot find a Ref target (outside the state machine's name)", async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Parameters: { @@ -459,7 +459,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot ).rejects.toThrow(/Parameter or resource 'Param1' could not be found for evaluation/); }); - test("will not perform a hotswap deployment if it doesn't know how to handle a specific attribute (outside the state machines's name)", async () => { + silentTest("will not perform a hotswap deployment if it doesn't know how to handle a specific attribute (outside the state machines's name)", async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -522,7 +522,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot ).rejects.toThrow("We don't support the 'UnknownAttribute' attribute of the 'AWS::S3::Bucket' resource. This is a CDK limitation. Please report it at https://github.com/aws/aws-cdk/issues/new/choose"); }); - test('knows how to handle attributes of the AWS::Events::EventBus resource', async () => { + silentTest('knows how to handle attributes of the AWS::Events::EventBus resource', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -598,7 +598,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('knows how to handle attributes of the AWS::DynamoDB::Table resource', async () => { + silentTest('knows how to handle attributes of the AWS::DynamoDB::Table resource', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -677,7 +677,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('knows how to handle attributes of the AWS::KMS::Key resource', async () => { + silentTest('knows how to handle attributes of the AWS::KMS::Key resource', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { @@ -740,7 +740,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); - test('does not explode if the DependsOn changes', async () => { + silentTest('does not explode if the DependsOn changes', async () => { // GIVEN setup.setCurrentCfnStackTemplate({ Resources: { diff --git a/packages/aws-cdk/test/util/silent.ts b/packages/aws-cdk/test/util/silent.ts new file mode 100644 index 0000000000000..127afde3d32b7 --- /dev/null +++ b/packages/aws-cdk/test/util/silent.ts @@ -0,0 +1,16 @@ +/* eslint-disable jest/no-export */ +import * as logging from '../../lib/logging'; + +export function silentTest(name: string, callback: () => void | Promise, timeout?: number): void { + const spy = jest.spyOn(logging, 'print'); + if (process.env.CLI_TEST_VERBOSE) { + spy.mockRestore(); + } + test( + name, + async () => { + return callback(); + }, + timeout, + ); +}