Last active
February 4, 2019 21:14
-
-
Save Jotschi/a7d8b219dee19b037e4dadacc1dcd475 to your computer and use it in GitHub Desktop.
protractor-docker-example
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
describe('mesh demo test', function() { | |
it('should be list the demo', function() { | |
browser.get('http://' + browser.params.meshHost + ':' + browser.params.meshPort + '/demo'); | |
}); | |
}); |
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
version: '2' | |
services: | |
tester: | |
build: . | |
entrypoint: bash -c "while ! timeout 1 wget -qO- http://selenium:4444/wd/hub > /dev/null ; do sleep 1; done; protractor --seleniumAddress http://selenium:4444/wd/hub /app/protractor.conf.js --params.meshHost mesh --params.meshPort 8080" | |
selenium: | |
image: selenium/standalone-firefox | |
entrypoint: bash -c "while ! timeout 1 wget -qO- http://mesh:8080/api/v1/admin/status > /dev/null ; do sleep 1; done ; ./opt/bin/entry_point.sh" | |
mesh: | |
image: gentics/mesh-demo:latest | |
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
FROM jotschi/protractor | |
RUN mkdir -p /app | |
COPY *.js /app/ |
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
describe('mesh login test', function() { | |
it('should be able to login', function() { | |
browser.get('http://' + browser.params.meshHost + ':' + browser.params.meshPort + '/mesh-ui'); | |
element(by.model('vm.userName')).sendKeys('admin'); | |
element(by.model('vm.password')).sendKeys('admin'); | |
element(by.model('vm.password')).sendKeys('\n'); | |
var projectList = element.all(by.repeater('project in vm.projects')); | |
expect(projectList.count()).toEqual(1); | |
expect(projectList.get(0).getText()).toEqual('demo'); | |
}); | |
}); |
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
exports.config = { | |
specs : [ 'login-test.js', 'demo-test.js' ], | |
capabilities : { | |
'browserName' : '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
#!/bin/bash | |
PROJECT_NAME="e2e" | |
# define some colors to use for output | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
NC='\033[0m' | |
# kill and remove any running containers | |
cleanup () { | |
docker-compose -p $PROJECT_NAME kill | |
docker-compose -p $PROJECT_NAME rm -f | |
} | |
# catch unexpected failures, do cleanup and output an error message | |
trap 'cleanup ; printf "${RED}Tests Failed For Unexpected Reasons${NC}\n"' HUP INT QUIT PIPE TERM | |
# build and run the composed services | |
docker-compose -p $PROJECT_NAME build && docker-compose -p $PROJECT_NAME up -d | |
if [ $? -ne 0 ] ; then | |
printf "${RED}Docker Compose Failed${NC}\n" | |
exit -1 | |
fi | |
# wait for the test service to complete and grab the exit code | |
TEST_EXIT_CODE=`docker wait ${PROJECT_NAME}_tester_1` | |
# output the logs for the test (for clarity) | |
docker logs --tail=all ${PROJECT_NAME}_tester_1 | |
# inspect the output of the test and display respective message | |
if [ -z ${TEST_EXIT_CODE+x} ] || [ "$TEST_EXIT_CODE" -ne 0 ] ; then | |
printf "${RED}Tests Failed${NC} - Exit Code: $TEST_EXIT_CODE\n" | |
else | |
printf "${GREEN}Tests Passed${NC}\n" | |
fi | |
# call the cleanup fuction | |
cleanup | |
# exit the script with the same code as the test service code | |
exit $TEST_EXIT_CODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment