I am unable to refresh token. below is my code. After the 2nd minute the proxyToken variable is refreshed and the new value is printed. However the same is not getting passed into the ‘Proxy Service’ header. This works fine for the first time but i am facing issue only from the second call onwards when i need to refresh the token. Please help…
Edit, More info : The print statement prints the new token at the 120th sec(2nd run after the pause) but this new token does not transfer to the api call like it does in the first one(0th second)
var proxyToken = "proxy"
val apiCallSmall = exec( http("Accounts API")
.get(authzUri.toString)
.headers(Map(
"Resource-Scope" -> "Managed",
"Proxy-Service" -> "${proxyToken}",
"accept" -> "application/json"
))
.check(status.is(200))
)
val smallScenario = scenario("Small Partner scenario")
.exec(_.set("proxyToken", proxyToken))
.exec(apiCallSmall)
val getProxyScenario = scenario("Get proxy token scenario")
.exec(_.set("access_token", generateSSAV2Token()))
.exec(session => {
proxyToken = session("access_token").as[String]
println(s"Response body Proxy Scenario is:::::::::::: :::> \n$proxyToken")
session
})
.pause(2.minutes)
Simulation code
setUp(
getProxyScenario.inject(
constantConcurrentUsers(1).during(totalDuration.minutes)
)
.protocols(httpProtocol),
getUATScenario.inject(
constantConcurrentUsers(1).during(totalDuration.minutes)
)
.protocols(httpProtocol),
smallScenario.inject(
nothingFor(40.seconds),
atOnceUsers(10)
)
.throttle(
reachRps(1).in(5.seconds),holdFor(5.minutes),
jumpToRps(1),holdFor(15.minutes)
)