Skip to content

Commit 3a75314

Browse files
authored
Merge pull request #9919 from drdk/scala-gatling-fixes
Fixes to scala-gatling generated scripts
2 parents b930bb4 + 269e191 commit 3a75314

File tree

11 files changed

+33
-25
lines changed

11 files changed

+33
-25
lines changed

modules/swagger-codegen/src/main/resources/scala-gatling/api.mustache

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ class {{classname}}Simulation extends Simulation {
1515
1616
def getCurrentDirectory = new File("").getAbsolutePath
1717
def userDataDirectory = getCurrentDirectory + "/src/gatling/resources/data"
18+
def userConfDirectory = getCurrentDirectory + "/src/gatling/resources/conf"
1819
1920
// basic test setup
2021
val configName = System.getProperty("testConfig", "baseline")
21-
val config = ConfigFactory.load(configName).withFallback(ConfigFactory.load("default"))
22+
val config = ConfigFactory.parseFile(new File(userConfDirectory + File.separator + configName + ".conf"))
23+
.withFallback(ConfigFactory.parseFile(new File(userConfDirectory + File.separator + "default.conf")))
2224
val durationSeconds = config.getInt("performance.durationSeconds")
2325
val rampUpSeconds = config.getInt("performance.rampUpSeconds")
2426
val rampDownSeconds = config.getInt("performance.rampDownSeconds")
@@ -42,7 +44,7 @@ class {{classname}}Simulation extends Simulation {
4244
4345
// Setup http protocol configuration
4446
val httpConf = http
45-
.baseURL("{{basePath}}")
47+
.baseUrl("{{basePath}}")
4648
.doNotTrackHeader("1")
4749
.acceptLanguageHeader("en-US,en;q=0.5")
4850
.acceptEncodingHeader("gzip, deflate")
@@ -51,7 +53,7 @@ class {{classname}}Simulation extends Simulation {
5153
.contentTypeHeader(contentTypeHeader)
5254
5355
// set authorization header if it has been modified from config
54-
if(!authentication.equals("~MANUAL_ENTRY")){
56+
if(!authentication.equals("~MANUAL_ENTRY~")){
5557
httpConf.authorizationHeader(authentication)
5658
}
5759

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.4.3-SNAPSHOT
1+
2.4.11-SNAPSHOT
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
photoUrls,name,id,category,tags,status
1+
tags,id,category,status,name,photoUrls
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
firstName,lastName,password,userStatus,phone,id,email,username
1+
id,lastName,phone,username,email,userStatus,firstName,password
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
petId,quantity,id,shipDate,complete,status
1+
id,petId,complete,status,quantity,shipDate
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
photoUrls,name,id,category,tags,status
1+
tags,id,category,status,name,photoUrls
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
firstName,lastName,password,userStatus,phone,id,email,username
1+
id,lastName,phone,username,email,userStatus,firstName,password
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
file,additionalMetadata
1+
additionalMetadata,file

samples/client/petstore/scala-gatling/src/gatling/scala/io/swagger/client/api/PetApiSimulation.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ class PetApiSimulation extends Simulation {
1515

1616
def getCurrentDirectory = new File("").getAbsolutePath
1717
def userDataDirectory = getCurrentDirectory + "/src/gatling/resources/data"
18+
def userConfDirectory = getCurrentDirectory + "/src/gatling/resources/conf"
1819

1920
// basic test setup
2021
val configName = System.getProperty("testConfig", "baseline")
21-
val config = ConfigFactory.load(configName).withFallback(ConfigFactory.load("default"))
22+
val config = ConfigFactory.parseFile(new File(userConfDirectory + File.separator + configName + ".conf"))
23+
.withFallback(ConfigFactory.parseFile(new File(userConfDirectory + File.separator + "default.conf")))
2224
val durationSeconds = config.getInt("performance.durationSeconds")
2325
val rampUpSeconds = config.getInt("performance.rampUpSeconds")
2426
val rampDownSeconds = config.getInt("performance.rampDownSeconds")
@@ -42,7 +44,7 @@ class PetApiSimulation extends Simulation {
4244

4345
// Setup http protocol configuration
4446
val httpConf = http
45-
.baseURL("http://petstore.swagger.io/v2")
47+
.baseUrl("http://petstore.swagger.io/v2")
4648
.doNotTrackHeader("1")
4749
.acceptLanguageHeader("en-US,en;q=0.5")
4850
.acceptEncodingHeader("gzip, deflate")
@@ -51,7 +53,7 @@ class PetApiSimulation extends Simulation {
5153
.contentTypeHeader(contentTypeHeader)
5254

5355
// set authorization header if it has been modified from config
54-
if(!authentication.equals("~MANUAL_ENTRY")){
56+
if(!authentication.equals("~MANUAL_ENTRY~")){
5557
httpConf.authorizationHeader(authentication)
5658
}
5759

@@ -87,7 +89,7 @@ class PetApiSimulation extends Simulation {
8789
.feed(addPetBodyFeeder)
8890
.exec(http("addPet")
8991
.httpRequest("POST","/pet")
90-
.body(StringBody(Pet.toStringBody("${id}","${category}","${name}","${tags}","${status}","${photoUrls}")))
92+
.body(StringBody(Pet.toStringBody("${status}","${id}","${tags}","${category}","${name}","${photoUrls}")))
9193
)
9294

9395
// Run scnaddPet with warm up and reach a constant rate for entire duration
@@ -162,7 +164,7 @@ class PetApiSimulation extends Simulation {
162164
.feed(updatePetBodyFeeder)
163165
.exec(http("updatePet")
164166
.httpRequest("PUT","/pet")
165-
.body(StringBody(Pet.toStringBody("${id}","${category}","${name}","${tags}","${status}","${photoUrls}")))
167+
.body(StringBody(Pet.toStringBody("${status}","${id}","${tags}","${category}","${name}","${photoUrls}")))
166168
)
167169

168170
// Run scnupdatePet with warm up and reach a constant rate for entire duration
@@ -195,8 +197,8 @@ class PetApiSimulation extends Simulation {
195197
.feed(uploadFilePATHFeeder)
196198
.exec(http("uploadFile")
197199
.httpRequest("POST","/pet/${petId}/uploadImage")
198-
.formParam("file","${file}")
199200
.formParam("additionalMetadata","${additionalMetadata}")
201+
.formParam("file","${file}")
200202
)
201203

202204
// Run scnuploadFile with warm up and reach a constant rate for entire duration

samples/client/petstore/scala-gatling/src/gatling/scala/io/swagger/client/api/StoreApiSimulation.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ class StoreApiSimulation extends Simulation {
1515

1616
def getCurrentDirectory = new File("").getAbsolutePath
1717
def userDataDirectory = getCurrentDirectory + "/src/gatling/resources/data"
18+
def userConfDirectory = getCurrentDirectory + "/src/gatling/resources/conf"
1819

1920
// basic test setup
2021
val configName = System.getProperty("testConfig", "baseline")
21-
val config = ConfigFactory.load(configName).withFallback(ConfigFactory.load("default"))
22+
val config = ConfigFactory.parseFile(new File(userConfDirectory + File.separator + configName + ".conf"))
23+
.withFallback(ConfigFactory.parseFile(new File(userConfDirectory + File.separator + "default.conf")))
2224
val durationSeconds = config.getInt("performance.durationSeconds")
2325
val rampUpSeconds = config.getInt("performance.rampUpSeconds")
2426
val rampDownSeconds = config.getInt("performance.rampDownSeconds")
@@ -42,7 +44,7 @@ class StoreApiSimulation extends Simulation {
4244

4345
// Setup http protocol configuration
4446
val httpConf = http
45-
.baseURL("http://petstore.swagger.io/v2")
47+
.baseUrl("http://petstore.swagger.io/v2")
4648
.doNotTrackHeader("1")
4749
.acceptLanguageHeader("en-US,en;q=0.5")
4850
.acceptEncodingHeader("gzip, deflate")
@@ -51,7 +53,7 @@ class StoreApiSimulation extends Simulation {
5153
.contentTypeHeader(contentTypeHeader)
5254

5355
// set authorization header if it has been modified from config
54-
if(!authentication.equals("~MANUAL_ENTRY")){
56+
if(!authentication.equals("~MANUAL_ENTRY~")){
5557
httpConf.authorizationHeader(authentication)
5658
}
5759

@@ -116,7 +118,7 @@ class StoreApiSimulation extends Simulation {
116118
.feed(placeOrderBodyFeeder)
117119
.exec(http("placeOrder")
118120
.httpRequest("POST","/store/order")
119-
.body(StringBody(Order.toStringBody("${id}","${shipDate}","${complete}","${quantity}","${status}","${petId}")))
121+
.body(StringBody(Order.toStringBody("${status}","${id}","${petId}","${quantity}","${complete}","${shipDate}")))
120122
)
121123

122124
// Run scnplaceOrder with warm up and reach a constant rate for entire duration

0 commit comments

Comments
 (0)