Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(cli): move integ tests to @aws-cdk-testing/cli-integ #23590

Merged
merged 5 commits into from
Jan 17, 2023

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Jan 6, 2023

Clean up the CLI integration tests a bit, by moving them to a separate TypeScript package. This has the following benefits:

  • More clearly isolates the tests and keeps them separate from the CLI package proper.
  • Allows normal specification of dependencies of the integration tests themselves, via a proper package.json and Yarn lockfile.
  • Makes it more clear what reusable files are part of the CLI, vs what reusable files are part of the integration tests.
  • Makes it more clear/easier to download an old copy of the tests.
  • Tests that used to be written in bash are now written in TypeScript+Jest, making them easier to maintain.

Also makes the following changes:

  • Publishes the test artifacts to CodeArtifact, so that we don't need to do crazy shell hijacking shenanigans in order to fake NPM/Maven/NuGet/PyPI repositories from a set of artifacts.
  • We needed to change how the alpha packages are numbered in a candidate build:
    • If the current build was 2.3.4, the candidate build versions would be 2.4.0-rc.0 and 2.4.0-alpha.0.
    • However, if the pipeline runs with 2.4.0 actually released, its alpha packages would also be numbered 2.4.0-alpha.0.
    • To unambiguously refer to the alpha packages of the candidate version (keeping in mind the naming restrictions of all package managers), we now call those 2.4.0-alpha.999.

This is not the final form of our testing infrastructure. Right now, a fresh CodeArtifact repo is created for every test with all packages in it. In an actual pipeline, we would be better off publishing to a CodeArtifact repo once and all tests pulling from that.

That will be forthcoming in the future.


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

Clean up the CLI integration tests a bit, by moving
them to a separate package. This has the following
benefits:

- More clearly isolates the tests and keeps them separate from the CLI
  package proper.
- Allows normal specification of dependencies of the integration tests
  themselves, via a proper `package.json` and Yarn lockfile.
- Makes it more clear what reusable files are part of the CLI, vs
  what reusable files are part of the integration tests.
- Makes it more clear/easier to download an old copy of the tests.

Also makes the following improvement:

- Publishes the test artifacts to CodeArtifact, so that we don't need to
  do crazy shell hijacking shenanigans in order to fake
  NPM/Maven/NuGet/PyPI repositories from a set of artifacts.

This is not the final form of our testing infrastructure. Right now,
a fresh CodeArtifact repo is created for every test with all packages
in it. In an actual pipeline, we would be better off publishing to a
CodeArtifact repo once and all tests pulling from that.

That will be forthcoming in the future.
@rix0rrr rix0rrr requested a review from a team January 6, 2023 12:35
@rix0rrr rix0rrr self-assigned this Jan 6, 2023
@gitpod-io
Copy link

gitpod-io bot commented Jan 6, 2023

@aws-cdk-automation aws-cdk-automation requested a review from a team January 6, 2023 12:36
@github-actions github-actions bot added the p2 label Jan 6, 2023
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jan 6, 2023
@rix0rrr rix0rrr changed the title chore(cli): move integ tests to separate package chore(cli): move integ tests to @aws-cdk-testing/cli-integ Jan 6, 2023
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

@rix0rrr rix0rrr added the pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested label Jan 6, 2023
@aws-cdk-automation aws-cdk-automation dismissed their stale review January 6, 2023 12:43

✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.

@Naumel
Copy link
Contributor

Naumel commented Jan 6, 2023

Started build 516cbb73-c36b-4826-9bee-f5e695df708d

@Naumel Naumel added the pr/do-not-merge This PR should not be merged at this time. label Jan 11, 2023
Copy link
Contributor

@Naumel Naumel left a comment

Choose a reason for hiding this comment

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

None of the questions or comments I have are blocking.
This is a non-trivial amount of files changed, for as far as I can tell, things look good.
Added do-not-merge label.

Comment on lines +123 to +127
* Download the current `@aws-cdk-testing/cli-integ` artifact at `V1`.
* Determine the previous version `V0` (use `query-github` for this).
* Download the previous `@aws-cdk-testing/cli-integ` artifact at `V0`.
* From the `V1` artifact, apply the `V0` patch set.
* Run the `V0` tests with the `--framework-version` option:
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] Perhaps prev/ old or current/new could be more explicit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about it and I prefer this because it puts you in mind of version numbers.

packages/@aws-cdk-testing/cli-integ/bin/run-suite.ts Outdated Show resolved Hide resolved
Comment on lines +14 to +16
// this returns a list in descending order, newest releases first
// opts for same major version where possible, falling back otherwise
// to previous major versions.
Copy link
Contributor

Choose a reason for hiding this comment

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

[non-blocking] Is there any chance of a release timing forking up functionality?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably.

packages/@aws-cdk-testing/cli-integ/lib/integ-test.ts Outdated Show resolved Hide resolved
*
* If no such value is currently available, wait until it is.
*/
public async take(): Promise<ILease<A>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

[non-blocking] Does this have to be public?
Will a consumer ever try to acquire a lease with any other purpose than executing a block?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like the dual API.

});
}

export async function writeMavenSettingsFile(filename: string, login: LoginInformation) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[high number of file changes, I might just have scrolled past] The "filename" (usageDir) should be removed in a cleanup(), right/ does it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

usageDir is (may be) cleaned up in a separate invocation. The CLI also has two possible APIs:

  • publish + clean; or
  • run <cmd>

packages/@aws-cdk-testing/cli-integ/lib/with-aws.ts Outdated Show resolved Hide resolved
return XpMutexPool.fromDirectory(path.join(os.tmpdir(), name));
}

private readonly queuedResolvers = new Set<() => void>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why a Set and not a Queue (based on name and the FIFO comment from a previous file)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm. There are definitely no FIFO guarantees. Where did you read that?


jest.setTimeout(600_000);
jest.setTimeout(60 * 60_000); // Includes the time to acquire locks
Copy link
Contributor

Choose a reason for hiding this comment

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

[non-blocking] If something starts to edge-case, how can we quickly tell we're hitting that scenario?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'll see timeouts

@@ -1,5 +1,4 @@
import { withMonolithicCfnIncludeCdkApp } from '../helpers/cdk';
import { integTest } from '../helpers/test-helpers';
import { integTest, withMonolithicCfnIncludeCdkApp } from '../../lib';

jest.setTimeout(600_000);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need updating too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nah, it's only 1 test here

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 4c5f96d
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@rix0rrr rix0rrr removed the pr/do-not-merge This PR should not be merged at this time. label Jan 17, 2023
@mergify
Copy link
Contributor

mergify bot commented Jan 17, 2023

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

@mergify mergify bot merged commit 1fefc88 into main Jan 17, 2023
@mergify mergify bot deleted the huijbers/integ-test-package branch January 17, 2023 13:13
mergify bot pushed a commit that referenced this pull request Aug 27, 2024
#31131)

### Reason for this change

The cli integration tests cannot use your local version of `aws-cdk-lib`. This can be verified by making your `Stack` construct throw an error upon creation, and watching no CLI integration tests fail, even with `-a`.

### Description of changes

Fixed the CLI integration test framework to correctly link the local packages, like it [used to](#23590).

### Description of how you validated changes

Manual testing. This isn't something we can add automated tests for. 

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
xazhao pushed a commit to xazhao/aws-cdk that referenced this pull request Sep 12, 2024
aws#31131)

### Reason for this change

The cli integration tests cannot use your local version of `aws-cdk-lib`. This can be verified by making your `Stack` construct throw an error upon creation, and watching no CLI integration tests fail, even with `-a`.

### Description of changes

Fixed the CLI integration test framework to correctly link the local packages, like it [used to](aws#23590).

### Description of how you validated changes

Manual testing. This isn't something we can add automated tests for. 

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*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 pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants