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_tests_alpha): Support non-TypeScript tests #21169

Open
tomeszmh opened this issue Jul 15, 2022 · 8 comments
Open

(integ_tests_alpha): Support non-TypeScript tests #21169

tomeszmh opened this issue Jul 15, 2022 · 8 comments
Labels
cli Issues related to the CDK CLI effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md p1 package/tools Related to AWS CDK Tools or CLI

Comments

@tomeszmh
Copy link

Describe the bug

I have written a simple integration test case to my stack in Python, but I am not able to run it. I used integ-runner and tried with cdk deploy --app "python integration_test.py" but it seems none of them are working. Is this feature available only with ts library?

Many thanks

Expected Behavior

Able to run my tests.

Current Behavior

yarn's integ-runner cli uses *ts files to run tests, so with my python code it will not compile

with cdk deploy --app "python integ_tests.py" the stack deployed, but nothing happened

Reproduction Steps

app = App()

stack = Stack(app, "stack",env=default_env)
integ = IntegTest(app, "Integ", test_cases=[stack])

invoke = integ.assertions.invoke_function(
    function_name=stack.writer_lambda.function_name
)
invoke.expect(ExpectedResult.object_like({
    "Payload": "200"
}))

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.28.0 (build ba233f0)

Framework Version

No response

Node.js Version

16.15.1

OS

Mac OS 12.3.1

Language

Python

Language Version

3.9.4

Other information

No response

@tomeszmh tomeszmh added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 15, 2022
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Jul 15, 2022
@rix0rrr rix0rrr changed the title (integ_tests_alpha): (Unable to run tests) (integ_tests_alpha): Only supports TypeScript files Jul 25, 2022
@rix0rrr rix0rrr added effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p1 and removed needs-triage This issue or PR still needs to be triaged. labels Jul 25, 2022
@rix0rrr rix0rrr removed their assignment Jul 25, 2022
@rix0rrr
Copy link
Contributor

rix0rrr commented Jul 25, 2022

This might be true. It probably wouldn't be too hard to add support for this, although it might get complex for other languages as we don't necessarily know the CDK app's interpreter (as the integ tests are lacking a cdk.json).

@rix0rrr rix0rrr added feature-request A feature should be added or improved. and removed bug This issue is a bug. labels Jul 25, 2022
@rix0rrr rix0rrr changed the title (integ_tests_alpha): Only supports TypeScript files (integ_tests_alpha): Support non-TypeScript tests Jul 25, 2022
@GroovyDan
Copy link

+1 for python support

@tomeszmh
Copy link
Author

Any news on this one?

@mrgrain
Copy link
Contributor

mrgrain commented Nov 29, 2022

Support for --app and --test-regex already landed. As well as support for config files so you don't have to type these all the time. With that, it's already possible to run any language integration test. We are still working on ready-to-use presets.

@tomeszmh
Copy link
Author

Thanks a lot!

And is it possible to change the generated SingletonFunctionRole's Path attribute, or add another execution role for the lambda?

I have created an AwsApiCall, but I cannot see any possibility to parameterize the resources created inside the AwsApiCall object.

@mrgrain
Copy link
Contributor

mrgrain commented Nov 30, 2022

Thanks a lot!

And is it possible to change the generated SingletonFunctionRole's Path attribute, or add another execution role for the lambda?

I have created an AwsApiCall, but I cannot see any possibility to parameterize the resources created inside the AwsApiCall object.

Sounds possible. Please open a new issue for this so we can track it. Pull Requests are also welcome!

@mrgrain
Copy link
Contributor

mrgrain commented Jan 5, 2023

#22058 will soon introduce language presets for js, ts and python.

These languages will still be unsupported due to lack of testing, but should be added asap:

{     
      // works but it's a bit ugly to need to have a project per test case - is there a better solution?
      csharp: ['dotnet run --project {filePath}', ['^Integ.*\\.csproj$']],
      fsharp: ['dotnet run --project {filePath}', ['^Integ.*\\.fsproj$']],
      // this doesn't work. See previous PR attempts for ideas
      java: ['mvn -e -q compile exec:java', ['^Integ.*\\.java$']],
}

mergify bot pushed a commit that referenced this issue Jan 5, 2023
…Script, Python and Go (#22058)

It was already possible to run tests in any language by providing `--app` and `--test-regex` directly.
This change introduces the concept of language presets that can be selected.
By default all supported languages will be detected.

Users can run integration tests for multiple languages at the same time, using the default preset configuration. 
To further customize anything, only a single language can be selected. However it's always possible to call the `integ-runner` multiple times:

```console
integ-runner --language typescript
integ-runner --language python --app="python3.2"
integ-runner --language go --test-regex=".*\.integ\.go"
```

Resolves part of #21169

----

### All Submissions:

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

### Adding new Unconventional Dependencies:

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

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn 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*
@mrgrain
Copy link
Contributor

mrgrain commented Jan 9, 2023

Language preset for javascript typescript python and go have landed.

My experience with .NET and Java projects is limited so I'm looking for good ideas how these projects would expect integration tests to be structured.

Particularly for .NET it appears we need a different project per test because each integ tests needs to be in a Main. 🤔

@pahud pahud added the cli Issues related to the CDK CLI label Apr 11, 2024
@mrgrain mrgrain removed their assignment Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Issues related to the CDK CLI effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md p1 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants