Skip to content

Commit

Permalink
Run all of the browser tests at once, since parallel builds no longer…
Browse files Browse the repository at this point in the history
… benefit us at codeship and this will probably make things run even faster
  • Loading branch information
Spencer Alger committed Jan 18, 2014
1 parent 9c1c100 commit bacd515
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 39 deletions.
2 changes: 1 addition & 1 deletion grunt/browser_clients.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = function (grunt) {
grunt.registerTask('browser_clients:test', [
'browser_clients:build',
'run:browser_test_server',
'saucelabs-mocha'
'saucelabs-mocha:all'
]);

grunt.registerTask('browser_clients:build', [
Expand Down
4 changes: 3 additions & 1 deletion grunt/config/mochacov.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ module.exports = {
options: {
reporter: 'mocha-lcov-reporter',
coveralls: {
serviceName: 'travis-ci'
serviceName: 'codeship',
serviceJobId: process.env.CI_BUILD_NUMBER,
repoToken: process.env.COVERALLS_TOKEN
}
}
}
Expand Down
40 changes: 13 additions & 27 deletions grunt/config/saucelabs-mocha.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
var keys = require('../../test/utils/keys');

module.exports = {
options: {
urls: [
'http://127.0.0.1:8000/unit.html',
'http://127.0.0.1:8000/builds.html'
],
build: process.env.TRAVIS_JOB_ID || 'local_' + Date.now(),
detailedError: true
},
chrome: {
all: {
options: {
urls: [
'http://127.0.0.1:8000/unit.html',
'http://127.0.0.1:8000/builds.html'
],
testname: process.env.CI_BUILD_NUMBER ? 'build_' + process.env.CI_BUILD_NUMBER : 'local_' + Date.now(),
username: keys.saucelabs_user,
key: keys.saucelabs,
browsers: [
{
browserName: 'chrome',
Expand All @@ -17,14 +18,7 @@ module.exports = {
{
browserName: 'chrome',
platform: 'Linux'
}
],
tags: ['master', 'chrome']
}
},
ie: {
options: {
browsers: [
},
{
browserName: 'internet explorer',
version: '11',
Expand All @@ -39,14 +33,7 @@ module.exports = {
browserName: 'internet explorer',
version: '9',
platform: 'Windows 7'
}
],
tags: ['master', 'ie']
}
},
firefox: {
options: {
browsers: [
},
{
browserName: 'firefox',
platform: 'Windows 7'
Expand All @@ -55,8 +42,7 @@ module.exports = {
browserName: 'firefox',
platform: 'Linux'
}
],
tags: ['master', 'firefox']
]
}
}
};
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"load-grunt-tasks": "~0.2.0",
"load-grunt-config": "~0.7.0",
"grunt-s3": "~0.2.0-alpha.3",
"grunt-run": "~0.1.5",
"grunt-run": "~0.1.12",
"relative-fs": "0.0.1",
"grunt-contrib-compress": "~0.5.3",
"grunt-contrib-copy": "~0.4.1",
Expand All @@ -48,7 +48,7 @@
"expect.js": "~0.2.0",
"aliasify": "~1.2.4",
"express": "~3.4.7",
"grunt-saucelabs": "git://github.com/axemclion/grunt-saucelabs.git#01b68705a6823ff86930f28296ac6467fbea244b"
"grunt-saucelabs": "~4.1.2"
},
"license": "Apache 2.0",
"dependencies": {
Expand All @@ -65,7 +65,7 @@
"scripts": {
"test": "grunt test",
"blanket": {
"pattern": "src"
"pattern": [ "src" ]
}
}
}
2 changes: 2 additions & 0 deletions scripts/_utils.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

#####
# Start or stop a group for travis
#####
Expand Down
8 changes: 3 additions & 5 deletions scripts/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
# ES_RELEASE - a specific ES release to download in use for testing
# NODE_UNIT=1 - 0/1 run the unit tests in node
# NODE_INTEGRATION=1 - 0/1 run the integration tests in node
# TEST_BROWSER - the browser to test in using, sauce labs. One of 'ie', 'firefox', 'chrome'
# BROWSER_UNIT - the browser to test in using, sauce labs. One of 'ie', 'firefox', 'chrome'
# COVERAGE - 0/1 check for coverage and ship it to coveralls
#
###########

export ES_NODE_NAME="elasticsearch_js_test_runner"
export SAUCE_USERNAME="elasticsearch-js"
export SAUCE_ACCESS_KEY="3259dd1e-a9f2-41cc-afd7-855d80588aeb"

HERE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
MOCHA="./node_modules/.bin/mocha"
Expand Down Expand Up @@ -96,9 +94,9 @@ if [[ "$NODE_INTEGRATION" != "0" ]]; then
group "end:integration tests"
fi

if [[ -n "$TEST_BROWSER" ]]; then
if [[ "$BROWSER_UNIT" == "1" ]]; then
group "start:browser tests"
grunt_ browser_clients:build run:browser_test_server saucelabs-mocha:${TEST_BROWSER}
grunt_ browser_clients:build run:browser_test_server saucelabs-mocha
group "end:browser tests"
fi

Expand Down
46 changes: 46 additions & 0 deletions scripts/codeship.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash

HERE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $HERE/_utils.sh
source $HOME/.nvm/nvm.sh

case $1 in
setup)
group "start: installing nvm 0.10"
nvm install 0.10
group "end: installing nvm 0.10"

group "start: installing nvm 0.8"
nvm install 0.8
group "end: installing nvm 0.8"

manage_es install master
manage_es install 0.90

npm install
;;
run)
# test in node 0.8
group "start: test node 0.8"
nvm use 0.8
echo "rebuilding npm deps"
npm rebuild &> /dev/null
call ES_BRANCH=master ./scripts/ci.sh
call ES_BRANCH=0.90 ./scripts/ci.sh
group "end: test node 0.8"

# test in node 0.10
group "start: test node 0.10"
nvm use 0.10
echo "rebuilding npm deps"
npm rebuild &> /dev/null
call ES_BRANCH=master COVERAGE=1 ./scripts/ci.sh
call ES_BRANCH=0.90 ./scripts/ci.sh
group "end: test node 0.10"

# browser tests (node version irrelevant)
group "start: test browsers"
call NODE_UNIT=0 NODE_INTEGRATION=0 BROWSER_UNIT=1 ./scripts/ci.sh
group "end: test browsers"
;;
esac
2 changes: 2 additions & 0 deletions scripts/es.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

if [ -z "$2" ]; then
echo "Usage:
From the root of the elasticsearch-js project call:
Expand Down
2 changes: 1 addition & 1 deletion test/browser_build_unit_tests.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<!-- tests -->
<script src="build_tests.js"></script>
<script>
mocha.run().on('end', function(){
mochaRunner = mocha.run().on('end', function(){
window.mochaResults = this.stats;
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion test/browser_unit_tests.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</script>
<script src="unit_tests.js"></script>
<script>
mocha.run().on('end', function(){
mochaRunner = mocha.run().on('end', function(){
window.mochaResults = this.stats;
});
</script>
Expand Down
6 changes: 6 additions & 0 deletions test/utils/keys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// I know this is horrible
// I just don't want the keys searchable on github
module.exports = JSON.parse(new Buffer(
'eyJzYXVjZWxhYnNfdXNlciI6ImVsYXN0aWNzZWFyY2gtanMiLCJzYXVjZWxhYnMiOiIyNGY0OWUwNy1kODJmLTQwNjctODU0ZS1kODE1ZWJkMTVlNDYifQ==',
'base64'
).toString('utf8'));

0 comments on commit bacd515

Please sign in to comment.