Commit a4343a5c authored by Daniele Venzano's avatar Daniele Venzano

Do gitlab tests in a script

parent 729d24fc
......@@ -38,10 +38,27 @@ images:
- cp /registry-ca.crt /etc/docker/certs.d/$DOCKER_REGISTRY/ca.crt
- docker login -u gitlab-ci-runner -p $REGISTRY_PASSWORD $DOCKER_REGISTRY
script:
- docker build --pull -t $ZOE_TEST_IMAGE .
- docker push $ZOE_TEST_IMAGE
- sh ci/build_images.sh
#api-test:
# stage: integration-test
# services:
# - postgres:9.3
api-test:
stage: integration-test
services:
- postgres:9.3
image: docker:latest
script:
- docker run $DOCKER_REGISTRY:ci/$ZOE_TEST_IMAGE
-
docs:
stage: deploy
image: python:3.4
script:
- pip install sphinx
- sh ./build_docs.sh
frontend:
stage: deploy
image: nodejs:latest
script:
- cd zoe_fe
- ng build --env=prod --output-path=build/prod
#!/usr/bin/env bash
ZOE_TEST_IMAGE=${ZOE_TEST_IMAGE:-zoe:manual}
DOCKER_REGISTRY=${DOCKER_REGISTRY:-docker-registry:5000}
docker build --pull -t ${DOCKER_REGISTRY}/ci/${ZOE_TEST_IMAGE} .
docker push ${DOCKER_REGISTRY}/ci/${ZOE_TEST_IMAGE}
#!/usr/bin/env bash
ZOE_TEST_IMAGE=${ZOE_TEST_IMAGE:-zoe:manual}
DOCKER_REGISTRY=${DOCKER_REGISTRY:-docker-registry:5000}
CI_BUILD_REF=${CI_BUILD_REF:-manual}
if [ z${CI_BUILD_REF} != z"manual" ]; then
echo "Start Postgres"
docker run --name postgres-${CI_BUILD_REF} -d -p 5432 postgres:9.3
sleep 5
fi
echo "Start Zoe API process"
python3 zoe-api.py --debug --backend-swarm-url http://localhost:2375 --deployment-name test${CI_BUILD_REF} --dbuser postgres --dbhost localhost --dbport 5432 --dbname postgres --dbpass postgres --master-url tcp://localhost:4850 --auth-type text --proxy-type none --listen-port 5100 --workspace-base-path /tmp --log-file /tmp/zoe-api-${CI_BUILD_REF}.log &
echo "Start Zoe Master process"
python3 zoe-master.py --debug --backend-swarm-url http://172.17.0.1:2375 --deployment-name test${CI_BUILD_REF} --dbuser postgres --dbhost postgres-${CI_BUILD_REF} --dbport 5432 --dbname postgres --dbpass postgres --auth-type text --proxy-type none --workspace-base-path /tmp --log-file /tmp/zoe-master-${CI_BUILD_REF}.log &
cd tests
coverage run basic_auth_success_test.py localhost:5100
cd ..
echo "<============== MASTER LOGS ======================>"
cat /tmp/zoe-master-${CI_BUILD_REF}.log
echo "<================ API LOGS =======================>"
cat /tmp/zoe-api-${CI_BUILD_REF}.log
if [ z${CI_BUILD_REF} != z"manual" ]; then
echo "Stop Postgres"
docker rm -f postgres-${CI_BUILD_REF}
fi
import requests
import json
import time
import sys
import unittest
class ZoeRestTestSuccess(unittest.TestCase):
uri = 'http://192.168.12.2:5100/api/0.7/'
uri = ''
auth = ('admin', 'admin')
id = ''
......@@ -28,7 +30,7 @@ class ZoeRestTestSuccess(unittest.TestCase):
self.assertEqual(r.status_code, 200)
def test_4_service_details(self):
print('Test service details api aendpoint')
print('Test service details api endpoint')
r = requests.get(self.__class__.uri + 'execution/' + self.__class__.id, auth=self.__class__.auth)
sid = r.json()["services"][0]
r = requests.get(self.__class__.uri + 'service/' + str(sid), auth=self.__class__.auth)
......@@ -48,18 +50,21 @@ class ZoeRestTestSuccess(unittest.TestCase):
print('Test delete execution api endpoint')
r = requests.delete(self.__class__.uri + 'execution/delete/' + self.__class__.id, auth=self.__class__.auth)
self.assertEqual(r.status_code, 204)
def test_2_start_execution(self):
print('Test start execution api endpoint')
data = []
with open('tf.json', encoding='utf-8') as data_file:
data = json.loads(data_file.read())
r = requests.post(self.__class__.uri + 'execution', auth=self.__class__.auth, json={"application": data, "name": "requests"})
self.assertEqual(r.status_code, 201)
self.__class__.id = str(r.json()['execution_id'])
if __name__ == '__main__':
if len(sys.argv) > 1:
API_SERVER = sys.argv.pop()
ZoeRestTestSuccess.uri = 'http://' + API_SERVER + '/api/0.7/'
unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment