-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathJenkinsfile
More file actions
51 lines (49 loc) · 2.46 KB
/
Jenkinsfile
File metadata and controls
51 lines (49 loc) · 2.46 KB
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
node {
def app = 'bench-6efd6'
def cases = ['gevent', 'meinheld', 'bjoern', 'gunicorn-sync', 'gunicorn-gevent', 'gunicorn-meinheld', 'uwsgi', 'uwsgi-gevent']
def timestamp = sh(script: 'date +%s', returnStdout: true).trim()
checkout scm
stage('Launch in k8s') {
sh("kubectl create namespace tsung")
sh("kubectl create -f k8s/target-svc.yaml --namespace tsung")
sh("kubectl create -f k8s/tsung-config.yaml --namespace tsung")
sh("kubectl create -f k8s/tsung-master-svc.yaml --namespace tsung")
sh("kubectl create -f k8s/tsung-slave-svc.yaml --namespace tsung")
sh("kubectl create -f k8s/tsung-slave.yaml --namespace tsung")
}
stage('Waiting for test') {
for (int i = 0; i < cases.size(); i++) {
runTest(cases.get(i))
}
}
stage('Cleanup') {
sh("kubectl delete -f k8s/tsung-slave.yaml --namespace tsung")
sh("kubectl delete -f k8s/tsung-slave-svc.yaml --namespace tsung")
sh("kubectl delete -f k8s/tsung-master-svc.yaml --namespace tsung")
sh("kubectl delete -f k8s/tsung-config.yaml --namespace tsung")
sh("kubectl delete -f k8s/target-svc.yaml --namespace tsung")
sh("kubectl delete namespace tsung")
}
stage('Reporting') {
for (int i = 0; i < cases.size(); i++) {
reportTest(app, timestamp, cases.get(i))
}
sh("curl -X PUT -d 'true' https://${app}.firebaseio.com/suits/wsgi-server/tests/${timestamp}.json")
sh("curl -X PUT -d '${timestamp}' https://${app}.firebaseio.com/suits/wsgi-server/latest.json")
}
}
def runTest(current) {
sh("kubectl create -f k8s/${current}-deployment.yaml --namespace tsung")
sleep(60)
sh("kubectl create -f k8s/tsung-master.yaml --namespace tsung")
sleep(90)
sh("curl http://tsung-master-0.tsung-master.tsung.svc.cluster.local:8091/tsung.log > ${current}.json")
sh("kubectl delete -f k8s/${current}-deployment.yaml --namespace tsung")
sh("kubectl delete -f k8s/tsung-master.yaml --namespace tsung")
}
def reportTest(app, timestamp, current) {
sh("python hacks/fixlog.py ${current}.json")
sh("curl -X PUT -d @${current}.json https://${app}.firebaseio.com/stats/wsgi-server/${timestamp}/cases/${current}.json")
sh("curl -X PUT -d 'true' https://${app}.firebaseio.com/tests/wsgi-server/${timestamp}/cases/${current}.json")
sh("curl -X PUT -d 'true' https://${app}.firebaseio.com/cases/wsgi-server/${current}/${timestamp}.json")
}