diff --git a/.travis.yml b/.travis.yml index dce4356f0c0..330843e6675 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,10 +44,16 @@ before_install: printf '\ny\n\ny\ny\n' | ./google-cloud-sdk/install.sh && cd $TRAVIS_BUILD_DIR; fi +- gcloud components update -q +- gcloud components update preview -q - openssl aes-256-cbc -K $encrypted_95e832a36b06_key -iv $encrypted_95e832a36b06_iv -in nodejs-docs-samples.json.enc -out nodejs-docs-samples.json -d - if [ -a nodejs-docs-samples.json ]; then gcloud auth activate-service-account --key-file nodejs-docs-samples.json; fi +- openssl aes-256-cbc -K $encrypted_4e84c7c7ab67_key -iv $encrypted_4e84c7c7ab67_iv -in test/encrypted/express-demo.json.enc -out test/encrypted/express-demo.json -d +- if [ -a test/encrypted/express-demo.json ]; then + gcloud auth activate-service-account --key-file test/encrypted/express-demo.json; + fi install: #Add app specific setup here diff --git a/package.json b/package.json index ddf938af216..1ff43530246 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "googleapis": "~2.1.3" }, "devDependencies": { + "async": "^1.5.0", "coveralls": "^2.11.4", "istanbul": "^0.4.0", "jshint": "~2.8.0", diff --git a/test/appengine/test.js b/test/appengine/test.js index 74c3030e18d..9ea13d8c38b 100644 --- a/test/appengine/test.js +++ b/test/appengine/test.js @@ -14,7 +14,9 @@ 'use strict'; var spawn = require('child_process').spawn; +var exec = require('child_process').exec; var request = require('request'); +var async = require('async'); var cwd = process.cwd(); @@ -25,6 +27,7 @@ function getPath(dir) { var sampleTests = [ { dir: 'express', + projectId: 'express-demo', cmd: 'node', arg1: './bin/www', msg: 'Hello World! Express.js on Google App Engine.' @@ -93,6 +96,27 @@ if (process.env.TRAVIS_NODE_VERSION !== 'stable') { }); } +function end(timeoutId, intervalId, proc) { + clearTimeout(timeoutId); + clearInterval(intervalId); + proc.kill('SIGKILL'); +} + +function testRequest(url, sample, cb) { + request(url, function (err, res, body) { + if (err) { + cb(err, false); + } else { + if (body && body.indexOf(sample.msg) !== -1 && + (res.statusCode === 200 || res.statusCode === sample.code)) { + cb(null, true); + } else { + cb(null, false); + } + } + }); +} + describe('appengine/', function () { sampleTests.forEach(function (sample) { it(sample.dir + ': dependencies should install', function (done) { @@ -166,24 +190,47 @@ describe('appengine/', function () { } }); - timeoutId = setTimeout(end, 5000); - intervalId = setInterval(testRequest, 1000); - - function end() { - clearTimeout(timeoutId); - clearInterval(intervalId); - proc.kill('SIGKILL'); - } - - function testRequest() { - request('http://localhost:8080', function (err, res, body) { - if (body && body.indexOf(sample.msg) !== -1 && - (res.statusCode === 200 || res.statusCode === sample.code)) { - success = true; - end(); + timeoutId = setTimeout(function () { + end(timeoutId, intervalId, proc); + }, 5000); + intervalId = setInterval(function () { + testRequest('http://localhost:8080', sample, function (err, _success) { + if (err) { + console.log(err); + } else { + success = _success; } + end(timeoutId, intervalId, proc); }); - } + }, 1000); }); }); + + if (!process.env.TRAVIS) { + return; + } + + it('should deploy all samples', function (done) { + this.timeout(10 * 60 * 1000); // 10 minutes + async.parallel(sampleTests.map(function (sample) { + if (sample.projectId) { + return function (cb) { + exec('npm run deploy', { + cwd: getPath(sample.dir), + maxBuffer: 1000000 + }, function (err, stdout, stderr) { + console.log(stdout); + console.log(stderr); + if (err) { + return cb(err); + } else { + var url = 'http://' + sample.projectId + '.appspot.com'; + return testRequest(url, sample, cb); + } + }); + }; + } + return function (cb) { cb(); }; + }), done); + }); }); diff --git a/test/encrypted/express-demo.json b/test/encrypted/express-demo.json new file mode 100644 index 00000000000..a3233fbfefb --- /dev/null +++ b/test/encrypted/express-demo.json @@ -0,0 +1,7 @@ +{ + "private_key_id": "86afabe11b39d5451f9e324a18295fc1dcdc0b67", + "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDdkLGvD5y49ESR\nTnPLSGOlV3Cy304Rz81z3JTFqGKsN0POupF/mK+nHxEH9UoKAkuChdUR750qH21P\njvBBEcDI9hUqh9oisYX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mt0I7\nl3GnKFQeafdAGwmRLf3pqBSc6A9kK7TVzdlro5WbVZWr1RJQfKprDdwFAoGAGkoC\nEAmoPyX2XoFC14iFtWXqstD6fg6SuR1sP58sgeVBtAu2auMk/04MfCNsYeBg3yFw\nMA7M2JkyGUy+hkkrBaXgFbLGsMKKblXCsiIsBcwduqyxtgAXAg/MKwXfKBci4VrN\nTZSbqPsyLQLcieHHOck4vmc9kBy1BW3ffoddK5ECgYEAx8zQuR9nx/nwFayxmCC3\ntqQQo5bphwh5BVzOM39QwcLRLqY/j7WNcPcwItBf1E3OZr16hRmklMdWFn2WSqqq\nG58j6gkIzaflsYmT+i/R0uWi8EZ69NUz5lvwbPBsuy+rLXSw0qkB5JqQag9Zjd6O\nukcH/qn8yIcIZOB3yGrcryI\u003d\n-----END PRIVATE KEY-----\n", + "client_email": "331060524961-5tu4fsd2sej6cdc6iv6kuvv5p0chri0i@developer.gserviceaccount.com", + "client_id": "331060524961-5tu4fsd2sej6cdc6iv6kuvv5p0chri0i.apps.googleusercontent.com", + "type": "service_account" +} \ No newline at end of file diff --git a/test/encrypted/express-demo.json.enc b/test/encrypted/express-demo.json.enc new file mode 100644 index 00000000000..c8a52142e6b Binary files /dev/null and b/test/encrypted/express-demo.json.enc differ