Skip to content

Commit

Permalink
Update scalafmt-core to 3.4.3 (#75)
Browse files Browse the repository at this point in the history
* Update scalafmt-core to 3.4.3

* Reformat with scalafmt 3.4.3
  • Loading branch information
scala-steward committed Feb 28, 2022
1 parent 63484bb commit 8e20673
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
runner.dialect = "scala213"
version = 3.4.0
version = 3.4.3
binPack.parentConstructors = true
maxColumn = 128
includeCurlyBraceInSelectChains = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,33 @@ import ru.tinkoff.load.example.scenarios.SampleScenario

import scala.language.postfixOps

/**
* trait Annotations allows you to write Start annotation to influxdb before starting the simulation
* and Stop annotation after completion of the simulation
/** trait Annotations allows you to write Start annotation to influxdb before starting the simulation and Stop annotation after
* completion of the simulation
*/
class SampleSimulation extends Simulation with Annotations {

/**
* how to get custom params from simulation.conf OR from JVM params like -DparamName=""
/** how to get custom params from simulation.conf OR from JVM params like -DparamName=""
*/
val stageWeight = getDoubleParam("stageWeight")
val startIntensity = getDoubleParam("startIntensity")
val warmUpDuration = getDurationParam("warmUp")

/**
* intensity, stagesNumber, stageDuration, rampDuration, testDuration, baseUrl - default provided params.
* Values are taken from the simulation.conf or -DparamName="".
* Passing this params to the simulation is not required if you do not use them.
/** intensity, stagesNumber, stageDuration, rampDuration, testDuration, baseUrl - default provided params. Values are taken
* from the simulation.conf or -DparamName="". Passing this params to the simulation is not required if you do not use them.
*
* warmUpDuration, stageWeight, startIntensity - custom params
*/
setUp(
SampleScenario().inject(
rampUsersPerSec(3600 rph) //IntensityConverter rph convert this to 1.0 Double value
to (120 rpm) //IntensityConverter rpm convert this to 2.0 Double value
rampUsersPerSec(3600 rph) // IntensityConverter rph convert this to 1.0 Double value
to (120 rpm) // IntensityConverter rpm convert this to 2.0 Double value
during warmUpDuration,
incrementUsersPerSec(intensity * stageWeight)
.times(stagesNumber)
.eachLevelLasting(stageDuration)
.separatedByRampsLasting(rampDuration)
.startingFrom(startIntensity)
)
.startingFrom(startIntensity),
),
).protocols(httpProtocol)
.maxDuration(testDuration)
.assertions(assertionFromYaml("src/test/resources/nfr.yml"))
Expand Down
4 changes: 3 additions & 1 deletion example/src/test/scala/ru/tinkoff/load/example/example.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import ru.tinkoff.gatling.config.SimulationConfig._
package object example {

val httpProtocol = http
.baseUrl(baseUrl) // Here is the root for all relative URLs, located in simulation.conf file, or -DbaseUrl="" passed to test param
.baseUrl(
baseUrl,
) // Here is the root for all relative URLs, located in simulation.conf file, or -DbaseUrl="" passed to test param
.acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("en-US,en;q=0.5")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@ object SampleScenario {
}

class SampleScenario {
//prepare RedisClientPool
// prepare RedisClientPool
val redisPool = new RedisClientPool("localhost", 6379)

//get sensitive data from ENV
// get sensitive data from ENV
val jwtSecretToken = getStringParam("jwtSecret")

//prepare jwt generator
val jwtGenerator = jwt("HS256", jwtSecretToken) //pass here jwt algorithm and jwt secret key
.defaultHeader //use default jwt header: {"alg": "HS256","typ": "JWT"}
.payloadFromResource("jwtTemplates/payload.json") //use payload template from json file
// prepare jwt generator
val jwtGenerator = jwt("HS256", jwtSecretToken) // pass here jwt algorithm and jwt secret key
.defaultHeader // use default jwt header: {"alg": "HS256","typ": "JWT"}
.payloadFromResource("jwtTemplates/payload.json") // use payload template from json file

//get some configuration param from simulation.conf/ENV/JAVA_OPTS
// get some configuration param from simulation.conf/ENV/JAVA_OPTS
val jwtCookieDomain = getStringParam("domain")

//single request
// single request
val getMainPage: HttpRequestBuilder = http("GET /")
.get("/")
.check(status is 200)

//compose all in scenario
// compose all in scenario
val sampleScenario: ScenarioBuilder = scenario("Sample scenario")
//include feeders in scenario as usual
// include feeders in scenario as usual
.feed(timeShort)
.feed(timezoneRandom)
.feed(firstWorkDayHours)
Expand Down Expand Up @@ -64,15 +64,15 @@ class SampleScenario {
.feed(feederKPP)
.feed(feederSNILS)
.feed(feederRusPassport)
//redis commands
.exec(redisPool.SADD("key", "values", "values")) //add the specified members to the set stored at key
.exec(redisPool.DEL("key", "keys")) //removes the specified keys
.exec(redisPool.SREM("key", "values", "values")) //remove the specified members from the set stored at key
//generate JWT using values from feeders
// redis commands
.exec(redisPool.SADD("key", "values", "values")) // add the specified members to the set stored at key
.exec(redisPool.DEL("key", "keys")) // removes the specified keys
.exec(redisPool.SREM("key", "values", "values")) // remove the specified members from the set stored at key
// generate JWT using values from feeders
.exec(_.setJwt(jwtGenerator, "jwtToken"))
//set JWT cookie
// set JWT cookie
.exec(addCookie(Cookie("JWT_TOKEN", "${jwtToken}").withDomain(jwtCookieDomain).withPath("/")))
//execute request signed with JWT_TOKEN cookie
// execute request signed with JWT_TOKEN cookie
.exec(getMainPage)

}

0 comments on commit 8e20673

Please sign in to comment.