Gatling - Maitiro Ekutumira Post Chikumbiro muStringBody () NeRandom Dhata

Muchidzidzo ichi cheGatling, tinoratidza kuti tinotumira sei zvikumbiro zveposvo zvine data rakangoitika mu StringBody().

Muzviitiko zvakawanda zvekuyedza kuita, iwe unoda kurongedza iyo data iyo inotumirwa sekukumbira kwepositi kutevedzera zvikamu zvakasiyana. Kune izvi, isu tinokwanisa kushandisa feeders iyo inoverenga data kubva ku CSV mafaera kana akajeka mavara.

Kana usati waisa Gatling pamushini wako, unogona kuverenga chinyorwa chinotsanangura maitiro ekumisikidza Gatling seMaven chirongwa.

Scala Random String jenareta

Kutanga, tinoda nzira inogadzira tambo isina kujairika muScala:

object randomStringGenerator { def randomString(length: Int) = scala.util.Random.alphanumeric.filter(_.isLetter).take(length).mkString
}

XML Chikumbiro sePositi Muviri

Mumuenzaniso uyu, isu tiri kutumira XML post chikumbiro. Izvi zvine log_session_id paramende iyo inoda kuve yakasiyana muchikumbiro chimwe nechimwe:

val req = ' ' + ' ' +
'3 ' +
'MY_APP ' +
'0000000000 ' +
'b02edd23,ClientIP=10.211.55.3 ' +
'ACTIVATION ' + ''

Isu tinofanirwa kuve nenzira yekutumira iri pamusoro XML chikumbiro sepositi mu StringBody() muGatling, asi muchikumbiro chimwe nechimwe, iyo _ _ + _ | kukosha kunofanirwa kuve tambo yakasarudzika.



Kune izvi, isu tinofanirwa kushandisa feeders.

Feeder muStringBody ()

log_session_id

Iyo yakazara script yekutumira zvisina kurongeka post chikumbiro mu var randomSession = Iterator.continually(Map('randsession' -> ( req.replace('0000000000', randomStringGenerator.randomString(10))))) val scn = scenario('Activate')
.feed(randomSession)
.exec(http('activate request')
.post('/login/activate')
.body(StringBody('''${randsession}'''))
muKubata:

StringBody()