-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
156 lines (127 loc) · 4.66 KB
/
build.gradle
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import com.github.jengelman.gradle.plugins.processes.tasks.JavaFork
import groovy.json.JsonSlurper
buildscript {
repositories {
mavenCentral()
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
/** i2r - Step 1.1*/
/*classpath 'org.springframework.boot:spring-boot-gradle-plugin:2.2.2.RELEASE'*/
// commented code
classpath 'org.springframework.boot:spring-boot-gradle-plugin:2.1.10.RELEASE'
/** i2r - Step 1.1*/
classpath 'com.github.johnrengelman.processes:com.github.johnrengelman.processes.gradle.plugin:0.4.1'
}
}
plugins {
/** i2r - Step 1.2*/
/*id 'org.springframework.boot' version '2.2.2.RELEASE'*/
// Commented code
id 'org.springframework.boot' version '2.1.10.RELEASE'
/** i2r - Step 1.2*/
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
id "com.github.johnrengelman.processes" version '0.5.0'
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'scala'
apply plugin: 'com.github.johnrengelman.processes'
group = 'com.its'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
/** i2r - Step 1.3*/
configurations {
compile.exclude module: 'spring-boot-starter-tomcat'
}
// No commented code as it is newly added to exclude tomcat
/** i2r - Step 1.3*/
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
/** i2r - Step 1.4*/
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-reactor-netty'
// Commented Code
/*implementation 'org.springframework.boot:spring-boot-starter-web'*/
/** i2r - Step 1.4*/
implementation 'org.springframework.boot:spring-boot-starter-actuator'
compileOnly 'org.projectlombok:lombok'
compileOnly 'org.codehaus.groovy:groovy-all:2.4.4'
testCompile 'org.scala-lang:scala-library:2.12.5'
testCompile 'io.gatling.highcharts:gatling-charts-highcharts:3.3.0'
/*developmentOnly 'org.springframework.boot:spring-boot-devtools'*/
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
/*testImplementation 'io.gatling.highcharts:gatling-charts-highcharts:2.3.0'*/
}
task startSpringBoot(type: JavaFork) {
description = 'Start Card Service application in the background.'
group = 'Load Test'
classpath = sourceSets.main.runtimeClasspath
main = 'com.its.imperative2rx.Imperative2rxApplication'
}
startSpringBoot.dependsOn assemble
task stopSpringBoot << {
description = 'Stop the instance of Card Service application that was started with \'startSpringBoot\''
group = 'Load Test'
startSpringBoot.processHandle.abort()
}
task waitUntilSpringBootIsUp << {
description = 'Call the /actuator/health endpoint and wait until it responds with the status UP.'
group = 'Load Test'
String healthCheckURL = 'http://localhost:8090/actuator/health'
boolean success = false
int count = 0
while (count < 15 && !success) {
println 'Trying to connect to \'' + healthCheckURL + '\' : Attempt number=' + count
try {
count += 1
JsonSlurper jsonSlurper = new JsonSlurper()
String healthCheckResponseBody = healthCheckURL.toURL().text
println healthCheckResponseBody
Object result = jsonSlurper.parseText(healthCheckResponseBody)
Map jsonResult = (Map) result
String status = (String) jsonResult.get('status')
success = (status == 'UP')
}
catch (all) {
sleep(5 * 1000) // wait for another 5 seconds until next retry
}
}
if (success) {
println 'SUCCEFULLY Connected to \'' + healthCheckURL + '\''
} else {
println 'FAILED to Connected to \'' + healthCheckURL + '\''
}
}
waitUntilSpringBootIsUp.dependsOn startSpringBoot
task loadTest(type: JavaExec) {
description = 'Load Test of APIs With Gatling'
group = 'Load Test'
classpath = sourceSets.test.runtimeClasspath
jvmArgs = [
/*"-Dgatling.core.directory.binaries=${sourceSets.test.java.outputDir.toString()}",*/
"-Dgatling.core.directory.binaries=${sourceSets.test.output.classesDir.toString()}",
"-Dlogback.configurationFile=${logbackGatlingConfig()}"
]
main = "io.gatling.app.Gatling"
args = [
'--simulation', 'com.its.imperative2rx.GatlingApiLoadTest',
'--results-folder', "${buildDir}/gatling-results",
/*"--binaries-folder", sourceSets.test.java.outputDir.toString()*/
'--binaries-folder', sourceSets.test.output.classesDir.toString()
]
}
def logbackGatlingConfig() {
return sourceSets.test.resources.find { it.name == 'logback-gatling.xml'};
}
loadTest.dependsOn waitUntilSpringBootIsUp
loadTest.finalizedBy stopSpringBoot