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

integ-runner: randomly named integration test stacks? #27437

Closed
2 tasks
diranged opened this issue Oct 6, 2023 · 5 comments
Closed
2 tasks

integ-runner: randomly named integration test stacks? #27437

diranged opened this issue Oct 6, 2023 · 5 comments
Labels
@aws-cdk/integ-runner feature-request A feature should be added or improved.

Comments

@diranged
Copy link

diranged commented Oct 6, 2023

Describe the feature

By default, it seems that Integration Test stack names are static and consistent.. which makes it hard to run multiple tests at once. We would like to have the integration test runner add a randomly generated string to stacks (within some set of bounds ... like 4-5 charactars, alphanumeric, etc) so that we can run multiple sets of tests at once across a larger development team.

Use Case

It's tough to develop a CDK project when only one integration test can run at once.. also failed stacks then block further integration testing.

Proposed Solution

Allow dynamically naming or appending strings to the integration test stack names.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.93.0

Environment details (OS name and version, etc.)

N/A

@diranged diranged added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Oct 6, 2023
@indrora
Copy link
Contributor

indrora commented Oct 10, 2023

You can create a stack with a defined name (e.g. someprefix-[randbase36]) by defining the stackName property of the Stack itself. This can be overridden during the Stack constructor: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Stack.html#stackname-1

@indrora indrora closed this as not planned Won't fix, can't repro, duplicate, stale Oct 10, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@diranged
Copy link
Author

You can create a stack with a defined name (e.g. someprefix-[randbase36]) by defining the stackName property of the Stack itself. This can be overridden during the Stack constructor: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Stack.html#stackname-1

Aren't the snapshots currently based on the stack name though? So if we change the stack name on each build, won't we get a unique snapshot each time?

@indrora
Copy link
Contributor

indrora commented Oct 12, 2023

Yes.

You're also free to come up with some other method of generating pseudorandom names. However you generate your stack names, you can specify the underlying name that CloudFormation will use by setting the stackName property of the stack during creation.

@indrora indrora removed the needs-triage This issue or PR still needs to be triaged. label Oct 12, 2023
@diranged
Copy link
Author

@indrora,
I tried this .. but it ultimately means that the generated snapshots/manifests also bear the names of these custom artifacts:

import { Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';

export class DynamicIntegStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    const uuid = Math.random().toString(36).slice(2, 7);

    super(scope, id, {
      stackName: `${props?.stackName ?? id}-${uuid}`,
    });
  }
}
diff --git ...snapshot/manifest.json ...snapshot/manifest.json
index 89dbed7..b122dc6 100644
--- ...snapshot/manifest.json
+++ ...snapshot/manifest.json
@@ -28,7 +28,8 @@
           "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
           "requiresBootstrapStackVersion": 8,
           "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
-        }
+        },
+        "stackName": "VpcTestStack-jrcdh"
       },
       "dependencies": [
         "INFRA-CDK-K8S-VpcTestStack.assets"
@@ -292,7 +293,8 @@
           "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
           "requiresBootstrapStackVersion": 8,
           "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
-        }
+        },
+        "stackName": "...TestStack-3wdfe"
       },
       "dependencies": [
         "INFRA-CDK-K8S-CidrReservationTestStack.assets"
@@ -442,7 +444,8 @@
           "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
           "requiresBootstrapStackVersion": 8,
           "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
-        }
+        },
+        "stackName": "...TestStack-jjges"
       },

This makes it pretty impossible to store these manifests and use them to determine if new tests are necessary or not .. Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/integ-runner feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

2 participants