forked from dfci/matchengine-V2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
61 lines (49 loc) · 2.29 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
node {
stage('Checkout') {
checkout scm
//parent wrapper image
docker.image('mongo:3.6.10').withRun('-e "MONGO_INITDB_ROOT_USERNAME=root" -e "MONGO_INITDB_ROOT_PASSWORD=password"') { c ->
stage("spin up db") {
//get access to mongoshell methods
docker.image('mongo:3.6.10').inside("--link ${c.id}") {
sh "env"
//wait until mongodb is initialized
sh "bash -c 'COUNTER=0 && until mongo mongodb://root:password@${c.id}:27017/integration?authSource=admin --eval \"print(\\\"waited for connection\\\")\"; do sleep 1; let \"COUNTER++\"; echo \$COUNTER; if [ \$COUNTER -eq 15 ]; then exit 1 ; fi; done'"
sh "echo loading test data..."
stage("load test data") {
sh "mongorestore --uri mongodb://root:password@${c.id}:27017/integration?authSource=admin -d integration --gzip --dir=matchengine/tests/data/integration_data"
}
}
}
//use api test image
stage("run tests") {
docker.image('python:3.7').inside("--link ${c.id}") {
sh """
cat << 'EOF' > SECRETS_JSON.json
{
"MONGO_HOST": "${c.id.substring(0, 12)}",
"MONGO_PORT": 27017,
"MONGO_USERNAME": "root",
"MONGO_PASSWORD": "password",
"MONGO_RO_USERNAME": "root",
"MONGO_RO_PASSWORD": "password",
"MONGO_DBNAME": "integration",
"MONGO_AUTH_SOURCE": "admin"
}
"""
sh "cat SECRETS_JSON.json"
sh 'apt-get update && apt-get install -y libgraphviz-dev graphviz'
sh """
python setup.py install && \
pip install pygraphviz nose matplotlib && \
export SECRETS_JSON=SECRETS_JSON.json && \
nosetests -v --with-xunit matchengine/tests
"""
//report on nosetests results
sh "ls *xml"
junit "*xml"
}
}
}
}
}