Merge pull request #20 from bfirsh/add-ci-test-for-docker-cloud
Docker Cloud stack file and CI tests
This commit is contained in:
commit
c6a5cc9b1c
33
dockercloud.yml
Normal file
33
dockercloud.yml
Normal file
@ -0,0 +1,33 @@
|
||||
db:
|
||||
image: 'postgres:9.4'
|
||||
restart: always
|
||||
redis:
|
||||
image: 'redis:latest'
|
||||
restart: always
|
||||
result-app:
|
||||
autoredeploy: true
|
||||
image: 'instavote/result-app:latest'
|
||||
ports:
|
||||
- '80:80'
|
||||
restart: always
|
||||
lb:
|
||||
autoredeploy: true
|
||||
image: 'dockercloud/haproxy:latest'
|
||||
links:
|
||||
- voting-app
|
||||
ports:
|
||||
- "80:80"
|
||||
roles:
|
||||
- global
|
||||
restart: always
|
||||
voting-app:
|
||||
autoredeploy: true
|
||||
image: 'instavote/voting-app:latest'
|
||||
restart: always
|
||||
target_num_containers: 5
|
||||
|
||||
worker:
|
||||
autoredeploy: true
|
||||
image: 'instavote/worker:latest'
|
||||
restart: always
|
||||
target_num_containers: 3
|
60
result-app/docker-compose.test.yml
Normal file
60
result-app/docker-compose.test.yml
Normal file
@ -0,0 +1,60 @@
|
||||
version: '2'
|
||||
|
||||
services:
|
||||
|
||||
sut:
|
||||
build: ./tests/
|
||||
depends_on:
|
||||
- voting-app
|
||||
- result-app
|
||||
- worker
|
||||
networks:
|
||||
- front-tier
|
||||
|
||||
voting-app:
|
||||
build: ../voting-app/
|
||||
ports: ["80"]
|
||||
depends_on:
|
||||
- redis
|
||||
- db
|
||||
networks:
|
||||
- front-tier
|
||||
- back-tier
|
||||
|
||||
result-app:
|
||||
build: .
|
||||
ports: ["80"]
|
||||
depends_on:
|
||||
- redis
|
||||
- db
|
||||
networks:
|
||||
- front-tier
|
||||
- back-tier
|
||||
|
||||
worker:
|
||||
build: ../worker/
|
||||
depends_on:
|
||||
- redis
|
||||
- db
|
||||
networks:
|
||||
- back-tier
|
||||
|
||||
redis:
|
||||
image: redis:alpine
|
||||
ports: ["6379"]
|
||||
networks:
|
||||
- back-tier
|
||||
|
||||
db:
|
||||
image: postgres:9.4
|
||||
volumes:
|
||||
- "db-data:/var/lib/postgresql/data"
|
||||
networks:
|
||||
- back-tier
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
|
||||
networks:
|
||||
front-tier:
|
||||
back-tier:
|
5
result-app/tests/Dockerfile
Normal file
5
result-app/tests/Dockerfile
Normal file
@ -0,0 +1,5 @@
|
||||
FROM node
|
||||
RUN npm install -g phantomjs
|
||||
ADD . /app
|
||||
WORKDIR /app
|
||||
CMD ["/app/tests.sh"]
|
15
result-app/tests/render.js
Normal file
15
result-app/tests/render.js
Normal file
@ -0,0 +1,15 @@
|
||||
var system = require('system');
|
||||
var page = require('webpage').create();
|
||||
var url = system.args[1];
|
||||
|
||||
page.onLoadFinished = function() {
|
||||
setTimeout(function(){
|
||||
console.log(page.content);
|
||||
phantom.exit();
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
page.open(url, function() {
|
||||
page.evaluate(function() {
|
||||
});
|
||||
});
|
15
result-app/tests/tests.sh
Executable file
15
result-app/tests/tests.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
while ! timeout 1 bash -c "echo > /dev/tcp/voting-app/80"; do sleep 1; done
|
||||
curl -sS -X POST --data "vote=a" http://voting-app > /dev/null
|
||||
curl -sS -X POST --data "vote=b" http://voting-app > /dev/null
|
||||
sleep 10
|
||||
if phantomjs render.js http://result-app | grep -q '2 votes'; then
|
||||
echo -e "\e[42m------------"
|
||||
echo -e "\e[92mTests passed"
|
||||
echo -e "\e[42m------------"
|
||||
exit 0
|
||||
fi
|
||||
echo -e "\e[41m------------"
|
||||
echo -e "\e[91mTests failed"
|
||||
echo -e "\e[41m------------"
|
||||
exit 1
|
Loading…
Reference in New Issue
Block a user