Я новичок в Гатлинге и Скале. Я пытаюсь сделать следующее: -
test.json:
[
{
"code": "AML",
"data": "aaasdfgghh"
},
{
"code": "ABC",
"data": "aaasdfgghh"
},
{
"code": "SDF",
"data": "aaasdfgghh"
}
]
Теперь я хочу прочитать этот ключ / значение JSON в цикле. В настоящее время я делаю так:
Тело запроса и фидер: -
val jsonFileFeederFundsDoc: SourceFeederBuilder[Any] =
jsonFile("test.json").circular
//Saves locally and to S3
val upload_fund_s3: HttpRequestBuilder =
http("upload Fund docs Locally")
.post(onboarding_url_perf + "/document/passfort")
.headers(basic_headers)
.headers(auth_headers)
.body(StringBody(
"""{
"code": "${code}",
"data": "${data}"
}"""
)).asJson
.check(status.is(200))
.check(jsonPath("$.id").saveAs("id"))
И мой сценарий: -
val newFundScenario: ScenarioBuilder = scenario("Company Fund Scenarios exists")
.exec(TokenScenario.getCompanyUsersGwtToken).exitHereIfFailed
.exec(CompanyProfileRequest.check_company_exists).exitHereIfFailed
.doIf("${COMPANY_NOT_FOUND}") {
exec(CompanyProfileRequest.create_company_fund_profile).exitHereIfFailed
}
.feed(UploadFundDocsInPassfort.jsonFileFeederFundsDoc)
.exec(UploadFundDocsInPassfort.upload_fund_s3).exitHereIfFailed
.exec(UploadFundDocsInPassfort.upload_fund_passfort).exitHereIfFailed
.exec(OfficersRequest.create_director).exitHereIfFailed
И моя тестовая симуляция:
class TestCompanySimulation extends Simulation {
private val generalCompanyTestCases = GeneralCompanyScenarios
.newFundScenario
.inject(rampUsers(Integer.getInteger("users", 1)) during
(Integer.getInteger("ramp", 1) minutes))
setUp(
generalCompanyTestCases.protocols(httpConf),
)
}
Теперь проблема в том, что для одного пользователя я хочу читать данные в цикле в моем newFundScenario, но в этом случае он просто выбирает 1-е значение из файла json.
Что-то вроде
foreach(read data from json file){
//Pass Data in run time and execute
.exec(UploadFundDocsInPassfort.upload_fund_s3).exitHereIfFailed
.exec(UploadFundDocsInPassfort.upload_fund_passfort).exitHereIfFailed
}
Любая помощь очень ценится.
С уважением,
Викрам Патания