Skip to content

feat: add new integration test runner#19529

Merged
mergify[bot] merged 22 commits intoaws:masterfrom
corymhall:corymhall/integ-test-runner
Mar 30, 2022
Merged

feat: add new integration test runner#19529
mergify[bot] merged 22 commits intoaws:masterfrom
corymhall:corymhall/integ-test-runner

Conversation

@corymhall
Copy link
Copy Markdown
Contributor

@corymhall corymhall commented Mar 23, 2022

Creating this PR so that we can iterate on the design of the integration
test runner.

We will create two packages (names up for debate)

  1. @aws-cdk/integ-runner (this PR)
    CLI tool that will execute integration tests

  2. @aws-cdk/integ-tests (future PR)
    Library that is used to create integration test cases. This library will
    synthesize an assembly file that will be consumed by the runner.

This PR does not yet implement running new style integration tests (generated from the @aws-cdk/integ-tests library).
The initial implementation of the runner will only work on the legacy (i.e. existing) integration tests.


All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • Did you use cdk-integ to deploy the infrastructure and generate the snapshot (i.e. cdk-integ without --dry-run)?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license


This will search for integration tests recursively from the current directory and then execute them in parallel across `us-east-1`, `us-east-2`, & `us-west-2`.

### integ.json schema
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be added as a new schema in @aws-cdk/cloud-assembly-schema

You would then use the `IntegTest` construct to create your test cases

```ts
new IntegTeset(app, 'ArmTest', {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a Construct that uses attachCustomSynthesis to synthesize the manifest.

@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented Mar 23, 2022

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Mar 23, 2022
corymhall and others added 2 commits March 23, 2022 19:27
Creating this PR so that we can iterate on the design of the integration
test runner.

We will create two packages (names up for debate)

1. `@aws-cdk/integ-runner` (this package)
CLI tool that will execute integration tests

2. `@aws-cdk/integ-tests`
Library that is used to create integration test cases. This library will
synthesize an assembly file that will be consumed by the runner.
Co-authored-by: Jonathan Goldwasser <jogold@users.noreply.github.com>
interface MyIntegTestProps extends StackOptions {
functionProps?: FunctionOptions;
}
class MyIntegTest extends Stack {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the stack under test?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially. But maybe only if we add it to a "test case"? That would allow us to do things like only verify certain stacks within a snapshot (not sure if there is an actual need for this)


1. Check if a snapshot file exists (i.e. `/integ.*.expected.snapshot$/`)
2. If the snapshot does not exist
2a. Synth the integ app which will produce the `integ.json` file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand it correctly, for each integ.*.ts, it will generate an integ.json file plus as many snapshots as there are tests (instances of IntegTest) in the integ.*.ts file. Is this correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that there would be a 1:1 between integ.*.ts and snapshots. Maybe we change the name of the construct to something like IntegTestCase?

An integ.*.ts file contains an "Integration Test" which corresponds to a single CDK application (i.e. one snapshot). Within that application we can create any number of Stacks which we then use in "test cases".

We could also model it differently where you create a single IntegTest and then register any test cases to it integTest.addTestCase()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it.

*
* @default true
*/
readonly update?: boolean;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This update property has a different meaning than the --update command line arg, right? I wonder if this may cause some confusion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, what about stackUpdateWorkflow?

@github-actions github-actions bot added the p2 label Mar 28, 2022
@corymhall
Copy link
Copy Markdown
Contributor Author

Current experience.

render1648496530553

@corymhall corymhall changed the title feat: integ-runner [WIP] feat: add new integration test runner Mar 28, 2022
@corymhall corymhall marked this pull request as ready for review March 28, 2022 19:47
@corymhall corymhall requested a review from otaviomacedo March 28, 2022 19:47
@@ -0,0 +1,20 @@
import { Writable } from 'stream';
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took this file from packages/aws-cdk. It might be better if we had a shared library we could put stuff like this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything in core that we could reuse?

"type": "aws:cdk:logicalId",
"data": "MyFunction1ServiceRole9852B06B",
"trace": [
"new Role (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-iam/lib/role.js:50:22)",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not diffing this trace, but should we find a way to remove this?


const diagnostics = new Array<Diagnostic>();
if (!argv.force) {
const requests = batchTests(testsFromArgs);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(minor) there are two responsibilities in this method: manage the execution of snapshot tests (lines 97 to 116) and manage the execution of integration tests (119 to 148). I suggest you extract them to two different methods.

- Moving commands back to `cdk-cli-wrapper`
- Adding parameter for enabling lookups
@corymhall corymhall added the pr/do-not-merge This PR should not be merged at this time. label Mar 29, 2022

async function runTest(): Promise<void> {
do {
const region = queue.nextAvailableRegion;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the advantage of doing this versus fixing a region per execution?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good point, i'll do that instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Don't need that queue anymore! Much simpler.

@corymhall corymhall removed the pr/do-not-merge This PR should not be merged at this time. label Mar 30, 2022
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Mar 30, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Mar 30, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 5a62055
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit e7f43d1 into aws:master Mar 30, 2022
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Mar 30, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

madeline-k added a commit that referenced this pull request Mar 31, 2022
mergify bot pushed a commit that referenced this pull request Mar 31, 2022
This reverts commit e7f43d1.


----

### All Submissions:

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
StevePotter pushed a commit to StevePotter/aws-cdk that referenced this pull request Apr 27, 2022
Creating this PR so that we can iterate on the design of the integration
test runner.

We will create two packages (names up for debate)

1. `@aws-cdk/integ-runner` (this PR)
CLI tool that will execute integration tests

2. `@aws-cdk/integ-tests` (future PR)
Library that is used to create integration test cases. This library will
synthesize an assembly file that will be consumed by the runner.

This PR does not yet implement running new style integration tests (generated from the `@aws-cdk/integ-tests` library).
The initial implementation of the runner will only work on the legacy (i.e. existing) integration tests. 


----

### All Submissions:

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
StevePotter pushed a commit to StevePotter/aws-cdk that referenced this pull request Apr 27, 2022
…s#19651)

This reverts commit e7f43d1.


----

### All Submissions:

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS. p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants