Quote:
Originally Posted by Sholar
Nice!
One perspective is that you sort of answered your own question: "The whole idea with lambdas should be that they're independently deployable." Once they aren't independent, they shouldn't be separate.
Not too different from how microservices turn into a disaster (or start off being a disaster when logical domains aren't clear).
Right. Once we have a fairly stable system - if a lambda introduces breaking changes it should be a different version, and the other lambdas can upgrade to the new version at their leisure.
It's just about tricking the integration testing environment I guess.
I'm trying to formulate our first integration test now. It's kind of a weird flow though so I don't think it's gonna be a blueprint.
Flow is after a user signs up and confirms their email (eventually mobile too) in Cognito, it triggers a lambda. This lambda calls 3 other lambdas. #1 tries to look up the user in our CRM system based on email (eventually mobile phone too). If the first lambda finds one match the next lambda saves the CRM ID to cognito. The 3rd lambda saves the user to our local dynamo DB. Async/await is glorious here btw for reducing code mess.
I'd like the test to be as real as possible - IE connect to a stage version of cognito, our live CRM and a stage version of our app dynamo DB.
So to prepare I guess I need to 1) populate a user in cognito and 2) blank out a stage dynamo DB. Our CRM will be trickier as we don't really have a stage environment. So I will probably switch emails to a dummy user we have in the real system. Then I will execute the lambda and assert results - basically the same thing the Test feature in the lambda console does - minus the assertions. Then I have to clean up when done.
Should be interesting. I've been googling for any 3rd party stuff that does this out there and can't find anything that seems relevant. I have found some blogs that describe stuff like this and they basically built their own system.
For most of the integration tests it will be a lambda that's exposed to the web client through API Gateway. So for those I can use some standard HTTP testing tool like supertest. I might also use cucumber as a BDD layer which calls supertest under the covers.