-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add smoke tests for Hub/Chrome/Firefox images
Use a container to run tests in a simple NodeJs project. The test environment loads http://google.com and verifies the page title in both Chrome and Firefox. Closes #8
- Loading branch information
Showing
9 changed files
with
89 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
tmp/ | ||
*_image/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM node:0.10-onbuild | ||
MAINTAINER Selenium <[email protected]> | ||
|
||
# The remainder of this build will be completed by the upstream image's ONBUILD commands |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "docker-selenium-tests", | ||
"version": "0.0.0", | ||
"description": "Tests for docker selenium configuration", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "node smoke-chrome.js && node smoke-firefox.js" | ||
}, | ||
"license": "Apache 2", | ||
"dependencies": { | ||
"chai": "^1.10.0", | ||
"colors": "^1.0.3", | ||
"wd": "^0.3.11" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require('./smoke-test')('chrome'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require('./smoke-test')('firefox'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require('colors'); | ||
var chai = require('chai'); | ||
chai.should(); | ||
|
||
var wd = require('wd'); | ||
|
||
module.exports = function(browserName) { | ||
var logPrefix = ('[' + browserName + '] ').grey; | ||
var browser = wd.remote({ | ||
hostname: process.env.HUB_PORT_4444_TCP_ADDR, | ||
port: process.env.HUB_PORT_4444_TCP_PORT | ||
}); | ||
|
||
// optional extra logging | ||
browser.on('status', function(info) { | ||
console.log(logPrefix + info.cyan); | ||
}); | ||
browser.on('command', function(eventType, command, response) { | ||
console.log(logPrefix + ' > ' + eventType.cyan, command, (response || '').grey); | ||
}); | ||
browser.on('http', function(meth, path, data) { | ||
console.log(logPrefix + ' > ' + meth.magenta, path, (data || '').grey); | ||
}); | ||
|
||
browser.init({ | ||
browserName: browserName | ||
}, function() { | ||
browser.get("http://google.com", function() { | ||
browser.title(function(err, title) { | ||
if (err) { | ||
console.error(err); | ||
} | ||
title.should.include('Google'); | ||
browser.quit(); | ||
}); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
echo Building test container image | ||
docker build -t selenium/test:local ./Test | ||
|
||
echo Starting Selenium Container | ||
HUB=$(docker run -d selenium/hub:2.44.0) | ||
HUB_NAME=$(docker inspect -f '{{ .Name }}' $HUB | sed s:/::) | ||
sleep 2 | ||
|
||
echo Hub Name $HUB_NAME | ||
|
||
NODE_CHROME=$(docker run -d --link $HUB_NAME:hub selenium/node-chrome:2.44.0) | ||
NODE_FIREFOX=$(docker run -d --link $HUB_NAME:hub selenium/node-firefox:2.44.0) | ||
|
||
trap "echo Tearing down Selenium Chrome Node container; docker stop $NODE_CHROME; docker rm $NODE_CHROME; echo Tearing down Selenium Firefox Node container; docker stop $NODE_FIREFOX; docker rm $NODE_FIREFOX; echo Tearing down Selenium Hub container; docker stop $HUB; docker rm $HUB; echo Done" EXIT | ||
|
||
docker logs -f $HUB & | ||
docker logs -f $NODE_CHROME & | ||
docker logs -f $NODE_FIREFOX & | ||
sleep 2 | ||
|
||
echo Running test container... | ||
docker run --rm -it --link $HUB_NAME:hub selenium/test:local |