Isifundo se-JMeter: Ukuhlolwa kwe-REST Web Services

Kulesi Sifundo seJmeter, sibheka ukuthi singahlola kanjani i-REST API noma i-Web Service sisebenzisa ithuluzi leJmeter.

Singasebenzisa iJmeter ukuthumela isicelo sikaJson ku-RESTful Web Service futhi sihlolisise impendulo kaJson.

Uhlelo Lokuhlola lwe-REST Web Service

  • I-Thread Group
  • Isicelo se-HTTP

Njenganoma yikuphi ukuhlolwa kweJmeter, okokuqala sidinga ukudala i-Thread Group kanye ne-HTTP Request Sampler.

test-rest-jmeter-1

Uma wenza isivivinyo manje, ungathola iphutha ngekhodi yokuphendula engu-415 nomlayezo wokuphendula othi 'Uhlobo lwemidiya olungasekelwa'

Lokhu kungenxa yokuthi i-REST API ingahle ilindele i- 'Content-Type' ne- 'Access' parameter esicelweni sikanhlokweni.



ukuhlolwa-rest-jmeter-7

  • Umphathi Wezihloko ze-HTTP

Okulandelayo sidinga ukungeza i-HTTP Header Manager ukuthumela amapharamitha kusihloko sesicelo. Sidinga ukuthumela okuguquguqukayo kwe- 'Content-Type' ne- 'Finyelela' njengezihloko zezicelo.

test-rest-jmeter-3

ukuhlolwa-rest-jmeter-4

Cishe, udinga ukubhalisa uhlelo lwakho lokusebenza ngokhiye we-API. Lokhu kudinga ukuthunyelwa njengendlela ye-POST ku-REST API ku Umzimba wesicelo .

  • Thumela idatha ku-Body of Request

ukuhlolwa-rest-jmeter-8

Impendulo ngefomethi kaJson

ukuhlolwa-rest-jmeter-9

Okulandelayo ukukhipha noma ukuhlwaya Impendulo kaJson.

  • Khipha Impendulo kaJson

UJmeter unesandla i-plugin ebizwa ngeJsonPath engasetshenziswa ukudlulisa izimpendulo zikaJson.

Lapho usuyifakile i-plugin engenhla, singasebenzisa iJson Path Extractor njengeprosesa yeposi

test-json-path-extractor

Lapho nje sesingeze iJson Path Extractor kuhlelo lwethu lokuhlola, singasebenzisa umbhalo wamachashazi ukukhomba izinto zeJson.

Kulesi sibonelo, sifuna ukukhipha inani le- 'client_id':

json-path-extractor

Inani le- “client_id” lizolondolozwa kokuguquguqukayo okubizwa nge- “client_id_value”. Unganikeza noma yiliphi igama elizwakalayo olifisayo.

Lapho inani seligcinwe egameni eliguqukayo, singakhumbula inani ngokusebenzisa lelo gama eliguqukayo ngefomethi $ {client_id_value}

jmeter-rest-testing