-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
85 lines (85 loc) · 3.08 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
pipeline {
agent any
options { timestamps() }
parameters {
string(name: 'HOSTNAME', defaultValue: 'sh.ta.tnpl.me:8080')
string(name: 'LOAD_SHORTEN', defaultValue: '100')
string(name: 'LOAD_VISIT', defaultValue: '500')
}
environment {
GIT_REPO = 'https://github.com/tanapoln/sw-arch-loadtest-script.git'
}
stages {
stage("set pipeline name") {
steps {
script {
currentBuild.displayName = "#${BUILD_NUMBER} - ${HOSTNAME}"
}
}
}
stage("run test parallel") {
steps {
script {
def labels = ["us-worker", "sg-worker"]
def builders = [:]
for (x in labels) {
def label = x
builders[label] = {
node(label) {
git branch: "main", url: GIT_REPO
sh "git clean -xdf"
sh """
JAVA_OPTS="-Dhostname=${HOSTNAME} -Dload.shorten=${LOAD_SHORTEN} -Dload.visit=${LOAD_VISIT} -Dload.shorten.duration=60 -Dload.visit.duration=60" \
./gatling/bin/gatling.sh -s sh.ShortenSimulation -nr
"""
stash includes: '**/*.log', name: "log-${label}"
}
}
}
parallel builders
}
}
}
stage("prepare log files") {
steps {
sh """
if [ -d 'logs' ]; then rm -r logs; fi
mkdir logs
"""
dir('sg-worker') {
unstash "log-sg-worker"
sh "find . -name '*.log' -exec mv -v '{}' ../logs/simulation-sg.log \\;"
deleteDir()
}
dir('us-worker') {
unstash "log-us-worker"
sh "find . -name '*.log' -exec mv -v '{}' ../logs/simulation-us.log \\;"
deleteDir()
}
dir('logs') {
stash includes: '*.log', name: "gatling-log"
}
}
}
stage("gatling test") {
steps {
git branch: "main", url: GIT_REPO
sh "git clean -xdf"
dir('results/short-simulation') {
unstash "gatling-log"
}
sh """
./gatling/bin/gatling.sh -ro short-simulation
"""
gatlingArchive()
gatlingCheck(metrics: [
'shorten-jenkins-worker-sg.qps = 1000',
'shorten-jenkins-worker-us.qps = 1000',
'visit-jenkins-worker-sg.qps = 1000',
'visit-jenkins-worker-us.qps = 1000',
'global.okRate = 100'
])
}
}
}
}