Skip to content

Comments

aws-sdk-v3-upgrade - bff#6

Open
jgilbert01 wants to merge 6 commits intomasterfrom
aws-sdk-v3-upgrade
Open

aws-sdk-v3-upgrade - bff#6
jgilbert01 wants to merge 6 commits intomasterfrom
aws-sdk-v3-upgrade

Conversation

@jgilbert01
Copy link
Owner

No description provided.

},
"test:int": {
"command": "npm start -- --exec \"mocha --timeout 20000 --require @babel/register --recursive ./test/helper.js \"./test/int/**/*.test.js\"\"",
"command": "start-test --expect 404 http://localhost:3002 'mocha --timeout 20000 --require @babel/register --recursive ./test/helper.js \"./test/int/**/*.test.js\"'",
Copy link
Owner Author

Choose a reason for hiding this comment

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

serverless-offline no longer supports the --exec arg

Copy link
Owner Author

Choose a reason for hiding this comment

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

  • the lambda endpoint of 3002 returns a 404 when start-test sends a ping request
  • since there is no ping function defined
  • but that is good enough to know that serverless-offline is up

"command": "start-test --expect 404 http://localhost:3002 'mocha --timeout 20000 --require @babel/register --recursive ./test/helper.js \"./test/int/**/*.test.js\"'",
"env": {
"NODE_ENV": "test",
"AES": "false",
Copy link
Owner Author

Choose a reason for hiding this comment

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

turn AES off in the serverless-offline http and lambda processes

"babel-loader": "^9.1.3",
"babel-plugin-istanbul": "^6.1.1",
"baton-vcr-replay-for-aws-sdk": "^1.0.1",
"baton-vcr-serverless-plugin": "^1.0.0",
Copy link
Owner Author

Choose a reason for hiding this comment

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

these no longer work with the newer versions of serverless-offline


handle(event, includeErrors = true) {
handle(event, includeErrors = !process.env.IS_OFFLINE) {
return initialize(PIPELINES, this.options)
Copy link
Owner Author

Choose a reason for hiding this comment

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

automatically turn off fault handling for integration tests

}

export const handle = async (event, context, int = {}) => {
export const handle = async (event, context) => {
Copy link
Owner Author

Choose a reason for hiding this comment

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

this argument can no longer be passed by the int tests


import { handle } from '../../../src/listener';
const invoke = lambdaTest({ functionName: `${process.env.npm_package_name}-dev-listener` });

Copy link
Owner Author

Choose a reason for hiding this comment

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

  • this util works similar to supertest in the api gateway integration tests
  • it calls the serverless-offline lambda endpoint on 3002


// monkey patch replay to avoid immediate max retries and ultimately timeout
const rproxy = require('replay/lib/proxy');
rproxy.prototype.setTimeout = () => { };
Copy link
Owner Author

Choose a reason for hiding this comment

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

  • serverless-offline now starts the api gateway and lambda endpoints in separate processes from the serverless framework
  • but the baton vcr plugin runs in the sls process
  • so we need to include Replay in the webpack bundle so that we initialize it in the right processes

Choose a reason for hiding this comment

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

Should update this to not import from root index file. Since this test is still importing from the root index file, you'll have to add all the other aws-sdk dependencies like cloudwatch, etc.

externals: [
nodeExternals()
],
plugins: includeMocks() ? [new EnvironmentPlugin({ REPLAY: process.env.REPLAY })] : undefined,
Copy link
Owner Author

Choose a reason for hiding this comment

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

allow developers to set the REPLAY env var from the cli when running/recording tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants