Skip to content

Commit

Permalink
Integration test (#142)
Browse files Browse the repository at this point in the history
* Add acceptance test function
Adds serverless function that runs built master
also fixes some bugs found in doing so
  • Loading branch information
pselle committed Jun 9, 2017
1 parent b9c0c67 commit 3a1e859
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
.DS_Store
.serverless
node_modules
coverage
dist
3 changes: 3 additions & 0 deletions .npmignore
@@ -1 +1,4 @@
spec
acceptance
coverage
src
9 changes: 9 additions & 0 deletions acceptance/handler.js
@@ -0,0 +1,9 @@
'use strict';
var iopipe = require('./iopipe')({
debug: true
});

module.exports.simpleSuccess = iopipe((event, context, callback) => {
iopipe.log('custom_metric', 'A custom metric')
callback(null, { message: 'Successful invocation', event });
});
13 changes: 13 additions & 0 deletions acceptance/package.json
@@ -0,0 +1,13 @@
{
"name": "acceptance-test",
"version": "1.0.0",
"description": "",
"main": "handler.js",
"scripts": {
"build": "cp ../dist/iopipe.js ./iopipe.js",
"deploy": "serverless deploy",
"invoke": "sls invoke -f simpleSuccess",
"local": "sls invoke local -f simpleSuccess",
"all": "npm run build && npm run local && npm run deploy"
}
}
16 changes: 16 additions & 0 deletions acceptance/serverless.yml
@@ -0,0 +1,16 @@
service: qa-events-agent

provider:
name: aws
runtime: nodejs6.10
stage: prod
region: us-west-2

functions:
simpleSuccess:
handler: handler.simpleSuccess
environment:
IOPIPE_TOKEN: ${env:IOPIPE_TOKEN}
role: ${env:IAM_ROLE}
events:
- schedule: rate(10 minutes)
12 changes: 12 additions & 0 deletions circle.yml
@@ -1,3 +1,7 @@
machine:
environment:
PATH: "${PATH}:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin"

deployment:
release:
# release on tagged versions
Expand All @@ -7,3 +11,11 @@ deployment:
# login using environment variables
- echo -e "$NPM_USERNAME\n$NPM_PASSWORD\n$NPM_EMAIL" | npm login
- npm publish

acceptanceTests:
branch: master
owner: iopipe
commands:
- npm install serverless@1.15.1
- npm run build
- cd acceptance && npm run all
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -92,7 +92,7 @@ module.exports = function(options) {
s: stringValue
})

fn.VERSION = VERSION
fn.VERSION = globals.VERSION
}

return fn
Expand Down
4 changes: 3 additions & 1 deletion src/report.js
Expand Up @@ -87,10 +87,12 @@ class Report {
coldstart: globals.COLDSTART,
custom_metrics: metrics || [],
}

// Set to false after coldstart
globals.COLDSTART = false
}

send(err, callback) {

// Send report only once
if (this.sent) {
return
Expand Down

0 comments on commit 3a1e859

Please sign in to comment.