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

feat(aws stream): provisioned concurrency support for aws stream event #8342

Conversation

pgrzesik
Copy link
Contributor

@pgrzesik pgrzesik commented Oct 5, 2020

Ensures that EventSourceMapping for stream events has proper alias attached if one exists, It also ensures that the mapping resource will depend on that alias. This PR also adds a corresponding integration test case for provisionedConcurrency.test.js.

Note: The average time it takes to run the test now is pretty much the same, around 7-8 minutes.

Closes: #7802

@codecov-commenter
Copy link

Codecov Report

Merging #8342 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #8342   +/-   ##
=======================================
  Coverage   88.01%   88.02%           
=======================================
  Files         249      249           
  Lines        9306     9312    +6     
=======================================
+ Hits         8191     8197    +6     
  Misses       1115     1115           
Impacted Files Coverage Δ
...plugins/aws/package/compile/events/stream/index.js 98.11% <100.00%> (+0.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fc34140...de6bc65. Read the comment docs.

Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

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

@pgrzesik That looks really good! Thank you. I have just one question towards integration testing. Let me know

@@ -22,3 +22,18 @@ functions:
- Ref: AWS::Region
- Ref: AWS::AccountId
- ${self:service.name}-provisioned
provisionedKinesis:
Copy link
Contributor

Choose a reason for hiding this comment

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

How about using same function for testing both?

That'll probably ensure that we do not prolong integration test time.

It feels a bit quirky, but I think it still tests well setup (or do I miss something?)

confirmCloudWatchLogs has checkIsComplete option, through which we may ensure that second test waits for right logs to confirm that trigger worked

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks about the suggestion to use checkIsComplete 👍 I've migrated to one function that handles both integration test cases

expect(
awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources
.FirstEventSourceMappingDynamodbFoo.DependsOn
).to.have.lengthOf(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't touch those tests (Ideally all such tests should be refactored to rely on runServelress, but ofc that's not in a scope of this PR).

They're pain to work with on any refactors, so adding to them increases maintenance burden

Copy link
Contributor Author

@pgrzesik pgrzesik Oct 7, 2020

Choose a reason for hiding this comment

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

It's a slight adjustment to them as to make the things a bit easier I defaulted to have dependsOn as an array instead of a string if it's depending on just one resource. What would you suggest here then?

As for refactoring to rely on runServerless - I was thinking about it, but given the fact that there's an issue that I would like to tackle in the coming days (#8137) I felt like refactoring these tests is not worth it at the moment

Copy link
Contributor

@medikoo medikoo Oct 8, 2020

Choose a reason for hiding this comment

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

It's a slight adjustment to them as to make the things a bit easier I defaulted to have dependsOn as an array instead of a string if it's depending on just one resource. What would you suggest here then?

Update existing tests, that started to fail and need to be updated cause of that change, but do not introduce a new ones

I felt like refactoring these tests is not worth it at the moment

Yes, it could be time taking. At some point it'll be good if we do it though, as it'll allow to do greater internal rerfactors without a need of doing full test rewrite.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adjusted 💯

Yes, it could be time taking. At some point it'll be good if we do it though, as it'll allow to > do greater internal rerfactors without a need of doing full test rewrite.

I totally agree with that approach, I just had in mind this specific test suite, as if #8137 will be implemented, stream will be eventually removed

@codecov-io
Copy link

codecov-io commented Oct 7, 2020

Codecov Report

Merging #8342 into master will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8342      +/-   ##
==========================================
+ Coverage   88.01%   88.05%   +0.03%     
==========================================
  Files         249      249              
  Lines        9306     9293      -13     
==========================================
- Hits         8191     8183       -8     
+ Misses       1115     1110       -5     
Impacted Files Coverage Δ
...plugins/aws/package/compile/events/stream/index.js 98.11% <100.00%> (+0.11%) ⬆️
...ws/package/compile/events/cloudWatchEvent/index.js 97.67% <0.00%> (-2.33%) ⬇️
...ns/aws/package/compile/events/eventBridge/index.js 98.30% <0.00%> (-1.70%) ⬇️
.../package/compile/events/apiGateway/lib/validate.js 96.23% <0.00%> (-0.88%) ⬇️
lib/plugins/aws/deployFunction/index.js 89.56% <0.00%> (-0.71%) ⬇️
lib/classes/Variables.js 99.72% <0.00%> (-0.01%) ⬇️
lib/plugins/aws/lib/monitorStack.js 100.00% <0.00%> (ø)
lib/plugins/aws/package/compile/events/s3/index.js 100.00% <0.00%> (ø)
...ins/aws/customResources/resources/s3/lib/bucket.js 0.00% <0.00%> (ø)
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fc34140...10ed981. Read the comment docs.

@pgrzesik pgrzesik force-pushed the provisioned-concurrency-support-for-aws-stream-event branch from cdb9433 to 9d53840 Compare October 8, 2020 14:38
@pgrzesik pgrzesik requested a review from medikoo October 8, 2020 14:40
Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

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

Thank you @pgrzesik ! It looks great, I've suggested a minor improvement, that may help us to save some extra seconds

Comment on lines 30 to 32
await createSqsQueue(queueName);
log.notice(`Creating Kinesis stream "${streamName}"...`);
await createKinesisStream(streamName);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can create them in parallel (?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

of course - great idea 👍

Comment on lines 38 to 41
log.notice(`Deleting Kinesis stream "${streamName}"...`);
await deleteKinesisStream(streamName);
log.notice(`Deleting SQS queue "${queueName}"...`);
return deleteSqsQueue(queueName);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here :)

@pgrzesik pgrzesik requested a review from medikoo October 12, 2020 20:05
Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

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

Thank you @pgrzesik !

@medikoo medikoo merged commit c382d86 into serverless:master Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWS Kinesis Event Source not attaching with right provisioned Concurrency Lambda Alias
4 participants