From e50b9a90a6116c8b8f6a5ed08530561062aa3134 Mon Sep 17 00:00:00 2001 From: Aimee Rivers Date: Fri, 6 Dec 2019 14:59:11 +0100 Subject: [PATCH 1/4] Match default authorizationHeader in the conf file --- .../src/main/resources/scala-gatling/api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/scala-gatling/api.mustache b/modules/swagger-codegen/src/main/resources/scala-gatling/api.mustache index 09ca1261324..739a569ad7a 100644 --- a/modules/swagger-codegen/src/main/resources/scala-gatling/api.mustache +++ b/modules/swagger-codegen/src/main/resources/scala-gatling/api.mustache @@ -51,7 +51,7 @@ class {{classname}}Simulation extends Simulation { .contentTypeHeader(contentTypeHeader) // set authorization header if it has been modified from config - if(!authentication.equals("~MANUAL_ENTRY")){ + if(!authentication.equals("~MANUAL_ENTRY~")){ httpConf.authorizationHeader(authentication) } From f6aab1792bc6944244a110ac9296e6f26e8fc036 Mon Sep 17 00:00:00 2001 From: Aimee Rivers Date: Fri, 6 Dec 2019 14:59:39 +0100 Subject: [PATCH 2/4] baseURL should be baseUrl --- .../src/main/resources/scala-gatling/api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/scala-gatling/api.mustache b/modules/swagger-codegen/src/main/resources/scala-gatling/api.mustache index 739a569ad7a..e686c790c7c 100644 --- a/modules/swagger-codegen/src/main/resources/scala-gatling/api.mustache +++ b/modules/swagger-codegen/src/main/resources/scala-gatling/api.mustache @@ -42,7 +42,7 @@ class {{classname}}Simulation extends Simulation { // Setup http protocol configuration val httpConf = http - .baseURL("{{basePath}}") + .baseUrl("{{basePath}}") .doNotTrackHeader("1") .acceptLanguageHeader("en-US,en;q=0.5") .acceptEncodingHeader("gzip, deflate") From 522cbbb45cc7f00279f3484a885b83f7a83f0c4b Mon Sep 17 00:00:00 2001 From: Aimee Rivers Date: Fri, 6 Dec 2019 15:03:24 +0100 Subject: [PATCH 3/4] Load the config from the correct path --- .../src/main/resources/scala-gatling/api.mustache | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/scala-gatling/api.mustache b/modules/swagger-codegen/src/main/resources/scala-gatling/api.mustache index e686c790c7c..15c96e383b1 100644 --- a/modules/swagger-codegen/src/main/resources/scala-gatling/api.mustache +++ b/modules/swagger-codegen/src/main/resources/scala-gatling/api.mustache @@ -15,10 +15,12 @@ class {{classname}}Simulation extends Simulation { def getCurrentDirectory = new File("").getAbsolutePath def userDataDirectory = getCurrentDirectory + "/src/gatling/resources/data" + def userConfDirectory = getCurrentDirectory + "/src/gatling/resources/conf" // basic test setup val configName = System.getProperty("testConfig", "baseline") - val config = ConfigFactory.load(configName).withFallback(ConfigFactory.load("default")) + val config = ConfigFactory.parseFile(new File(userConfDirectory + File.separator + configName + ".conf")) + .withFallback(ConfigFactory.parseFile(new File(userConfDirectory + File.separator + "default.conf"))) val durationSeconds = config.getInt("performance.durationSeconds") val rampUpSeconds = config.getInt("performance.rampUpSeconds") val rampDownSeconds = config.getInt("performance.rampDownSeconds") From f7e4fca21ee799758d4d3e12f1332d13df20da18 Mon Sep 17 00:00:00 2001 From: Aimee Rivers Date: Fri, 6 Dec 2019 15:44:11 +0100 Subject: [PATCH 4/4] Updated Petstore sample --- .../scala-gatling/.swagger-codegen/VERSION | 2 +- .../gatling/resources/data/addPet-BodyParams.csv | 2 +- .../resources/data/createUser-BodyParams.csv | 2 +- .../resources/data/placeOrder-BodyParams.csv | 2 +- .../resources/data/updatePet-BodyParams.csv | 2 +- .../resources/data/updateUser-BodyParams.csv | 2 +- .../resources/data/uploadFile-formParams.csv | 2 +- .../io/swagger/client/api/PetApiSimulation.scala | 14 ++++++++------ .../io/swagger/client/api/StoreApiSimulation.scala | 10 ++++++---- .../io/swagger/client/api/UserApiSimulation.scala | 12 +++++++----- 10 files changed, 28 insertions(+), 22 deletions(-) diff --git a/samples/client/petstore/scala-gatling/.swagger-codegen/VERSION b/samples/client/petstore/scala-gatling/.swagger-codegen/VERSION index 017674fb59d..a4533be7fa8 100644 --- a/samples/client/petstore/scala-gatling/.swagger-codegen/VERSION +++ b/samples/client/petstore/scala-gatling/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.3-SNAPSHOT \ No newline at end of file +2.4.11-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/scala-gatling/src/gatling/resources/data/addPet-BodyParams.csv b/samples/client/petstore/scala-gatling/src/gatling/resources/data/addPet-BodyParams.csv index 9c23144ca97..008019ef2a6 100644 --- a/samples/client/petstore/scala-gatling/src/gatling/resources/data/addPet-BodyParams.csv +++ b/samples/client/petstore/scala-gatling/src/gatling/resources/data/addPet-BodyParams.csv @@ -1 +1 @@ -photoUrls,name,id,category,tags,status \ No newline at end of file +tags,id,category,status,name,photoUrls \ No newline at end of file diff --git a/samples/client/petstore/scala-gatling/src/gatling/resources/data/createUser-BodyParams.csv b/samples/client/petstore/scala-gatling/src/gatling/resources/data/createUser-BodyParams.csv index 38dcc63f020..b888f65647d 100644 --- a/samples/client/petstore/scala-gatling/src/gatling/resources/data/createUser-BodyParams.csv +++ b/samples/client/petstore/scala-gatling/src/gatling/resources/data/createUser-BodyParams.csv @@ -1 +1 @@ -firstName,lastName,password,userStatus,phone,id,email,username \ No newline at end of file +id,lastName,phone,username,email,userStatus,firstName,password \ No newline at end of file diff --git a/samples/client/petstore/scala-gatling/src/gatling/resources/data/placeOrder-BodyParams.csv b/samples/client/petstore/scala-gatling/src/gatling/resources/data/placeOrder-BodyParams.csv index a2fe128b281..b291d54868a 100644 --- a/samples/client/petstore/scala-gatling/src/gatling/resources/data/placeOrder-BodyParams.csv +++ b/samples/client/petstore/scala-gatling/src/gatling/resources/data/placeOrder-BodyParams.csv @@ -1 +1 @@ -petId,quantity,id,shipDate,complete,status \ No newline at end of file +id,petId,complete,status,quantity,shipDate \ No newline at end of file diff --git a/samples/client/petstore/scala-gatling/src/gatling/resources/data/updatePet-BodyParams.csv b/samples/client/petstore/scala-gatling/src/gatling/resources/data/updatePet-BodyParams.csv index 9c23144ca97..008019ef2a6 100644 --- a/samples/client/petstore/scala-gatling/src/gatling/resources/data/updatePet-BodyParams.csv +++ b/samples/client/petstore/scala-gatling/src/gatling/resources/data/updatePet-BodyParams.csv @@ -1 +1 @@ -photoUrls,name,id,category,tags,status \ No newline at end of file +tags,id,category,status,name,photoUrls \ No newline at end of file diff --git a/samples/client/petstore/scala-gatling/src/gatling/resources/data/updateUser-BodyParams.csv b/samples/client/petstore/scala-gatling/src/gatling/resources/data/updateUser-BodyParams.csv index 38dcc63f020..b888f65647d 100644 --- a/samples/client/petstore/scala-gatling/src/gatling/resources/data/updateUser-BodyParams.csv +++ b/samples/client/petstore/scala-gatling/src/gatling/resources/data/updateUser-BodyParams.csv @@ -1 +1 @@ -firstName,lastName,password,userStatus,phone,id,email,username \ No newline at end of file +id,lastName,phone,username,email,userStatus,firstName,password \ No newline at end of file diff --git a/samples/client/petstore/scala-gatling/src/gatling/resources/data/uploadFile-formParams.csv b/samples/client/petstore/scala-gatling/src/gatling/resources/data/uploadFile-formParams.csv index 50f9afc8d6c..a8f6bfaf688 100644 --- a/samples/client/petstore/scala-gatling/src/gatling/resources/data/uploadFile-formParams.csv +++ b/samples/client/petstore/scala-gatling/src/gatling/resources/data/uploadFile-formParams.csv @@ -1 +1 @@ -file,additionalMetadata \ No newline at end of file +additionalMetadata,file \ No newline at end of file diff --git a/samples/client/petstore/scala-gatling/src/gatling/scala/io/swagger/client/api/PetApiSimulation.scala b/samples/client/petstore/scala-gatling/src/gatling/scala/io/swagger/client/api/PetApiSimulation.scala index 5e349cc2b6d..f70ce769b01 100644 --- a/samples/client/petstore/scala-gatling/src/gatling/scala/io/swagger/client/api/PetApiSimulation.scala +++ b/samples/client/petstore/scala-gatling/src/gatling/scala/io/swagger/client/api/PetApiSimulation.scala @@ -15,10 +15,12 @@ class PetApiSimulation extends Simulation { def getCurrentDirectory = new File("").getAbsolutePath def userDataDirectory = getCurrentDirectory + "/src/gatling/resources/data" + def userConfDirectory = getCurrentDirectory + "/src/gatling/resources/conf" // basic test setup val configName = System.getProperty("testConfig", "baseline") - val config = ConfigFactory.load(configName).withFallback(ConfigFactory.load("default")) + val config = ConfigFactory.parseFile(new File(userConfDirectory + File.separator + configName + ".conf")) + .withFallback(ConfigFactory.parseFile(new File(userConfDirectory + File.separator + "default.conf"))) val durationSeconds = config.getInt("performance.durationSeconds") val rampUpSeconds = config.getInt("performance.rampUpSeconds") val rampDownSeconds = config.getInt("performance.rampDownSeconds") @@ -42,7 +44,7 @@ class PetApiSimulation extends Simulation { // Setup http protocol configuration val httpConf = http - .baseURL("http://petstore.swagger.io/v2") + .baseUrl("http://petstore.swagger.io/v2") .doNotTrackHeader("1") .acceptLanguageHeader("en-US,en;q=0.5") .acceptEncodingHeader("gzip, deflate") @@ -51,7 +53,7 @@ class PetApiSimulation extends Simulation { .contentTypeHeader(contentTypeHeader) // set authorization header if it has been modified from config - if(!authentication.equals("~MANUAL_ENTRY")){ + if(!authentication.equals("~MANUAL_ENTRY~")){ httpConf.authorizationHeader(authentication) } @@ -87,7 +89,7 @@ class PetApiSimulation extends Simulation { .feed(addPetBodyFeeder) .exec(http("addPet") .httpRequest("POST","/pet") - .body(StringBody(Pet.toStringBody("${id}","${category}","${name}","${tags}","${status}","${photoUrls}"))) + .body(StringBody(Pet.toStringBody("${status}","${id}","${tags}","${category}","${name}","${photoUrls}"))) ) // Run scnaddPet with warm up and reach a constant rate for entire duration @@ -162,7 +164,7 @@ class PetApiSimulation extends Simulation { .feed(updatePetBodyFeeder) .exec(http("updatePet") .httpRequest("PUT","/pet") - .body(StringBody(Pet.toStringBody("${id}","${category}","${name}","${tags}","${status}","${photoUrls}"))) + .body(StringBody(Pet.toStringBody("${status}","${id}","${tags}","${category}","${name}","${photoUrls}"))) ) // Run scnupdatePet with warm up and reach a constant rate for entire duration @@ -195,8 +197,8 @@ class PetApiSimulation extends Simulation { .feed(uploadFilePATHFeeder) .exec(http("uploadFile") .httpRequest("POST","/pet/${petId}/uploadImage") - .formParam("file","${file}") .formParam("additionalMetadata","${additionalMetadata}") + .formParam("file","${file}") ) // Run scnuploadFile with warm up and reach a constant rate for entire duration diff --git a/samples/client/petstore/scala-gatling/src/gatling/scala/io/swagger/client/api/StoreApiSimulation.scala b/samples/client/petstore/scala-gatling/src/gatling/scala/io/swagger/client/api/StoreApiSimulation.scala index 3331dc06aa2..906278edbb1 100644 --- a/samples/client/petstore/scala-gatling/src/gatling/scala/io/swagger/client/api/StoreApiSimulation.scala +++ b/samples/client/petstore/scala-gatling/src/gatling/scala/io/swagger/client/api/StoreApiSimulation.scala @@ -15,10 +15,12 @@ class StoreApiSimulation extends Simulation { def getCurrentDirectory = new File("").getAbsolutePath def userDataDirectory = getCurrentDirectory + "/src/gatling/resources/data" + def userConfDirectory = getCurrentDirectory + "/src/gatling/resources/conf" // basic test setup val configName = System.getProperty("testConfig", "baseline") - val config = ConfigFactory.load(configName).withFallback(ConfigFactory.load("default")) + val config = ConfigFactory.parseFile(new File(userConfDirectory + File.separator + configName + ".conf")) + .withFallback(ConfigFactory.parseFile(new File(userConfDirectory + File.separator + "default.conf"))) val durationSeconds = config.getInt("performance.durationSeconds") val rampUpSeconds = config.getInt("performance.rampUpSeconds") val rampDownSeconds = config.getInt("performance.rampDownSeconds") @@ -42,7 +44,7 @@ class StoreApiSimulation extends Simulation { // Setup http protocol configuration val httpConf = http - .baseURL("http://petstore.swagger.io/v2") + .baseUrl("http://petstore.swagger.io/v2") .doNotTrackHeader("1") .acceptLanguageHeader("en-US,en;q=0.5") .acceptEncodingHeader("gzip, deflate") @@ -51,7 +53,7 @@ class StoreApiSimulation extends Simulation { .contentTypeHeader(contentTypeHeader) // set authorization header if it has been modified from config - if(!authentication.equals("~MANUAL_ENTRY")){ + if(!authentication.equals("~MANUAL_ENTRY~")){ httpConf.authorizationHeader(authentication) } @@ -116,7 +118,7 @@ class StoreApiSimulation extends Simulation { .feed(placeOrderBodyFeeder) .exec(http("placeOrder") .httpRequest("POST","/store/order") - .body(StringBody(Order.toStringBody("${id}","${shipDate}","${complete}","${quantity}","${status}","${petId}"))) + .body(StringBody(Order.toStringBody("${status}","${id}","${petId}","${quantity}","${complete}","${shipDate}"))) ) // Run scnplaceOrder with warm up and reach a constant rate for entire duration diff --git a/samples/client/petstore/scala-gatling/src/gatling/scala/io/swagger/client/api/UserApiSimulation.scala b/samples/client/petstore/scala-gatling/src/gatling/scala/io/swagger/client/api/UserApiSimulation.scala index b065e226dff..7012b9be50b 100644 --- a/samples/client/petstore/scala-gatling/src/gatling/scala/io/swagger/client/api/UserApiSimulation.scala +++ b/samples/client/petstore/scala-gatling/src/gatling/scala/io/swagger/client/api/UserApiSimulation.scala @@ -15,10 +15,12 @@ class UserApiSimulation extends Simulation { def getCurrentDirectory = new File("").getAbsolutePath def userDataDirectory = getCurrentDirectory + "/src/gatling/resources/data" + def userConfDirectory = getCurrentDirectory + "/src/gatling/resources/conf" // basic test setup val configName = System.getProperty("testConfig", "baseline") - val config = ConfigFactory.load(configName).withFallback(ConfigFactory.load("default")) + val config = ConfigFactory.parseFile(new File(userConfDirectory + File.separator + configName + ".conf")) + .withFallback(ConfigFactory.parseFile(new File(userConfDirectory + File.separator + "default.conf"))) val durationSeconds = config.getInt("performance.durationSeconds") val rampUpSeconds = config.getInt("performance.rampUpSeconds") val rampDownSeconds = config.getInt("performance.rampDownSeconds") @@ -42,7 +44,7 @@ class UserApiSimulation extends Simulation { // Setup http protocol configuration val httpConf = http - .baseURL("http://petstore.swagger.io/v2") + .baseUrl("http://petstore.swagger.io/v2") .doNotTrackHeader("1") .acceptLanguageHeader("en-US,en;q=0.5") .acceptEncodingHeader("gzip, deflate") @@ -51,7 +53,7 @@ class UserApiSimulation extends Simulation { .contentTypeHeader(contentTypeHeader) // set authorization header if it has been modified from config - if(!authentication.equals("~MANUAL_ENTRY")){ + if(!authentication.equals("~MANUAL_ENTRY~")){ httpConf.authorizationHeader(authentication) } @@ -82,7 +84,7 @@ class UserApiSimulation extends Simulation { .feed(createUserBodyFeeder) .exec(http("createUser") .httpRequest("POST","/user") - .body(StringBody(User.toStringBody("${password}","${id}","${lastName}","${firstName}","${email}","${userStatus}","${phone}","${username}"))) + .body(StringBody(User.toStringBody("${email}","${firstName}","${lastName}","${id}","${userStatus}","${phone}","${password}","${username}"))) ) // Run scncreateUser with warm up and reach a constant rate for entire duration @@ -183,7 +185,7 @@ class UserApiSimulation extends Simulation { .feed(updateUserPATHFeeder) .exec(http("updateUser") .httpRequest("PUT","/user/${username}") - .body(StringBody(User.toStringBody("${password}","${id}","${lastName}","${firstName}","${email}","${userStatus}","${phone}","${username}"))) + .body(StringBody(User.toStringBody("${email}","${firstName}","${lastName}","${id}","${userStatus}","${phone}","${password}","${username}"))) ) // Run scnupdateUser with warm up and reach a constant rate for entire duration