Hello guys,
I can imagine that my doubt could be a kind of stupid but lets go
I’m loading a scenario from a Json file and trying to execute the requests inside a loop.
Everything works fine, the file Json is parsed, objects are populated but when the cursor reach the setUp line, I’m receiving this error:
java.lang.IllegalArgumentException: requirement failed: Scenario Basic Scenario is empty
This is the code. Why calling scn.exe inside a loop doesn’ t work?
Thank you very much!!!
`
import com.google.gson.Gson
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import org.apache.commons.io.IOUtils
class Gatling extends Simulation {
var classLoader = getClass().getClassLoader();
var jsonDataInputStream = classLoader.getResourceAsStream(“scenario.json”);
var jsonDataContent = IOUtils.toString(jsonDataInputStream);
var gson = new Gson()
var scenarioJson = gson.fromJson(jsonDataContent, classOf[Scenario])
val httpConf = http
.baseURL(scenarioJson.getHttp.getBaseUrl)
.acceptHeader(scenarioJson.getHttp.getAcceptHeader)
.doNotTrackHeader(scenarioJson.getHttp.getDoNotTrackHeader)
.acceptLanguageHeader(scenarioJson.getHttp.getAcceptLanguageHeader)
.acceptEncodingHeader(scenarioJson.getHttp.getAcceptEncodingHeader)
.userAgentHeader(scenarioJson.getHttp.getUserAgentHeader)
var scn = scenario(scenarioJson.getName);
val requests = scenarioJson.getRequests.iterator()
while (requests.hasNext()){
var request = requests.next()
var auth = scenarioJson.getAuth
scn.exec(http(request.getName)
.get(request.getUrl)
.basicAuth(auth.getUsername, auth.getPassword))
.pause(2)
// println("################################")
// println(request.getName)
// println(request.getUrl)
// println("################################")
}
setUp(scn.inject(atOnceUsers(100)).protocols(httpConf))
}
`