መሰብሰብ - በዘፈቀደ ውሂብ በ StringBody () ውስጥ የልጥፍ ጥያቄን እንዴት መላክ እንደሚቻል

በዚህ የጋቲንግ ማጠናከሪያ ትምህርት ውስጥ በ StringBody() ውስጥ የዘፈቀደ ውሂብን የያዙ የልጥፍ ጥያቄዎችን እንዴት እንደላክን ያሳያል

በአብዛኛዎቹ የአፈፃፀም ሙከራ ሁኔታዎች ውስጥ የተለያዩ ክፍለ-ጊዜዎችን ለማስመሰል እንደ ልጥፍ ጥያቄ የተላከውን መረጃ በዘፈቀደ መለየት ይፈልጋሉ ፡፡ ለዚህም ከሲ.ኤስ.ቪ ፋይሎች ወይም ከተራ ጽሑፍ ላይ መረጃን የሚያነቡ መጋቢዎችን መጠቀም እንችላለን ፡፡

ገና በማሽኑዎ ላይ ጋቲንግን ካላዋቀሩ የሚያብራራውን ልጥፍ ማንበብ ይችላሉ ጋትሊንግን እንደ ማቨን ፕሮጀክት እንዴት ማዋቀር እንደሚቻል ፡፡


ስካላ የዘፈቀደ ገመድ ጀነሬተር

በመጀመሪያ ፣ በስካላ ውስጥ የዘፈቀደ ገመድ የሚያመነጭ ዘዴ እንፈልጋለን

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

የኤክስኤምኤል ጥያቄ እንደ ልጥፍ አካል

በዚህ ምሳሌ ውስጥ የ XML ልጥፍ ጥያቄ እንልካለን ፡፡ ይህ በእያንዳንዱ ጥያቄ ውስጥ የተለየ መሆን ያለበት የ log_session_id ግቤትን ይ :ል-


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

StringBody() ውስጥ ከላይ ያለውን የ XML ጥያቄ እንደ ልጥፍ የምንልክበት መንገድ ሊኖረን ይገባል በጋቲንግ ውስጥ ግን በእያንዳንዱ ጥያቄ የ log_session_id እሴት የዘፈቀደ ገመድ መሆን አለበት።



ለዚህም መጋቢዎችን መጠቀም አለብን ፡፡

StringBody ውስጥ መጋቢ ()

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}'''))

StringBody() ውስጥ የዘፈቀደ ልጥፍ ጥያቄን ለመላክ ሙሉው እስክሪፕት በጋቲንግ ውስጥ

import io.gatling.core.Predef._ import io.gatling.http.Predef._ import io.gatling.http.config.HttpProtocolBuilder.toHttpProtocol import io.gatling.http.request.builder.HttpRequestBuilder.toActionBuilder class Activate extends Simulation { object randomStringGenerator {
def randomString(length: Int) = scala.util.Random.alphanumeric.filter(_.isLetter).take(length).mkString } val req = ' ' +
' ' +
'3 ' +
'MY_APP ' +
'0000000000 ' +
'b02edd23,ClientIP=10.211.55.3 ' +
'ACTIVATION ' +
'' var randomSession = Iterator.continually(Map('randsession' -> ( req.replace('0000000000', randomStringGenerator.randomString(10))))) val httpConf = http
.baseURL('http://localhost:5000')
.acceptHeader('text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
.userAgentHeader('Mozilla/4.0(compatible;IE;GACv10. 0. 0. 1)') val scn = scenario('Activate')
.feed(randomSession)
.exec(http('activate request')
.post('/login/activate')
.body(StringBody('''${randsession}'''))
.check(status.is(200)))
.pause(5) setUp(
scn.inject(atOnceUsers(5)) ).protocols(httpConf) }