செயல்திறன் சோதனைக்கான கேட்லிங் கருவிக்கான விரைவான குறிப்பு வழிகாட்டியாக இந்த இடுகை செயல்படுகிறது.
முன்பு, எப்படி என்று பார்த்தோம் உங்கள் கேட்லிங் திட்டத்தை ஒழுங்கமைக்கவும் ஒரு தர்க்கரீதியான மற்றும் புரிந்துகொள்ள எளிதான கட்டமைப்பில்.
இந்த இடுகையில், செயல்திறன் சோதனை ஸ்கிரிப்ட்களை உருவாக்கும்போது சில பொதுவான கேட்லிங் செயல்பாடுகளின் சில எடுத்துக்காட்டுகள் மற்றும் பயன்பாடுகளைப் பார்க்கிறோம்.
இந்த இடுகையில் விவரிக்கப்பட்டுள்ள கேட்லிங் எடுத்துக்காட்டுகள்:
import io.gatling.core.Predef._ import io.gatling.http.Predef._ class SimplestSimulation extends Simulation {
setUp(scenario('Homepage')
.exec(http('Home').get('https://devqa.io'))
.inject(atOnceUsers(1))) }
setUp(scenario('Proxy on')
.exec(http('World').get('https://devqa.io'))
.inject(atOnceUsers(1)))
.protocols(http.proxy(Proxy('proxy.company.net', 8080))) }
மேலே உள்ள எடுத்துக்காட்டில், proxy.company.net
ப்ராக்ஸி URL மற்றும் 8080
ப்ராக்ஸி போர்ட்.
வினவல் அளவுருக்கள் கொண்ட எளிய GET கோரிக்கை
http('Get Gatling posts')
.get('https://devqa.io')
.queryParam('post', 'gatling')
.queryParam('category', 'performance testing')
.header('Accept-Language', 'en')
படிவ அளவுருக்கள் கொண்ட மாதிரி POST கோரிக்கை, எ.கா. ஒரு படிவத்தை சமர்ப்பித்தல்:
http('POST with params')
.post('https://www.example.com/login')
.formParam('firstname', 'David')
.formParam('lastname', 'Brown')
.header('Accept-Language', 'en')
கோப்பு பேலோடோடு ஒரு மாதிரி POST கோரிக்கை src/test/resources/bodies
இல் இருக்க வேண்டும்
http('Post with file payload')
.post('https://example.com/users')
.body(RawFileBody('bodyFileName.json')).asJSON
.header('Content-type','application/json')
குறிப்பு: இடைநிறுத்தத்தைப் பயன்படுத்த, நீங்கள் இந்த இறக்குமதியைச் சேர்க்க வேண்டும்import scala.concurrent.duration.DurationInt
scenario('with secode pause')
// ...
.pause(2, 3) // will make a random pause of 2-3 seconds
.pause(2) // will make a fixed pause of 2 seconds
scenario('millisecond pause')
// ...
.pause(200.milliseconds) // fixed pause of 0.2 second
scenario('repeat')
.repeat(3)( // repeat 3 times
exec(http('google').get('https://www.example.com'))
)
val scn=scenario('Virtual users') setUp(
scn.inject(
nothingFor(4.seconds),
atOnceUsers(10),
rampUsers(10) over(5.seconds))
rampUsers(10) over(5.seconds)
// linear rampup
// 10 users added over 5 seconds (1 extra user every 500 ms)
constantUsersPerSec(10) during(5.seconds)
// adds 10 users every second
// (so a total of 50 users after 5 seconds)
nothingFor(4.seconds) // no new users added during 4 seconds atOnceUsers(10) // 10 users added immediately // not really recommended since it can hammer down the tested server heavisideUsers(10) over(2.seconds) // better approximation of a peak of users
கேட்லிங்கில், நிலைக் குறியீடுகளின் மறுமொழி அமைப்புகளைச் சரிபார்க்க காசோலைகள் வழக்கமாகப் பயன்படுத்தப்படுகின்றன, அதேசமயம் பதில்களின் நேரங்களை உறுதிப்படுத்த பொதுவாக வலியுறுத்தல்கள் பயன்படுத்தப்படுகின்றன.
நிலை மற்றும் JSON தரவைச் சரிபார்க்கிறது:
http('name').get('/path')
.check(status.is(200))
.check(jsonPath('$.name').is('some name'))
கேட்லிங் அமர்வில் மறுமொழி தரவைச் சேமிக்கிறது
http('name').get('/path')
.check(header('location').saveAs('newLocation'))
.check(jsonPath('$.name').saveAs('name'))
// You can now use $newLocation and $name in your requests :
http('get home').get('/users/${name}')
setUp(scn).assertions(
global.responseTime.mean.lt(50), // mean resp time < 50 ms
forAll.failedRequests.percent.gt(5) // for each request, < 5% failure )
val feeder1 = Array(
Map('foo' -> 'foo1', 'bar' -> 'bar1'),
Map('foo' -> 'foo2', 'bar' -> 'bar2'),
Map('foo' -> 'foo3', 'bar' -> 'bar3') ) // repeating the values val feeder1a = feeder1.circular val feeder1b = feeder1.random // infinite entries with keys 'value1', 'value2' val feeder2 = Iterator.continually(Map('value1' -> 100, 'value2' -> 'toto')) // infinite random entries val feeder3 = Iterator.continually(Map(
'value1' -> Random.nextInt(100),
'value2' -> Random.alphanumeric.take(4)) ) // using the feeder to build the URLs scenario('scenario name')
.feed(feeder)
.exec(http('request name')
.get('/path/${value1}') )
// reading a csv file to build a feeder val feeder = csv('data.csv') // the csv file must have a header row which defines the keys and be comma (,) separated // filling a template file with the content of a feeder scn.feed(feeder).exec(
http('request name')
.post('https://www.example.com')
.body(ElFileBody('filename.xml')).asXML))