Isifundo seJmeter: Uyithumela njani ifayile yeJSON njengeSicelo kuMzimba

Kule JMeter Tutorial, sichaza indlela yokuthumela enye okanye iifayile zeJSON ezininzi kumzimba wesicelo se-HTTP.

Xa kuvavanywa i-RESTful API, sihlala sithumela isicelo se-POST kwi-REST API kwifomathi yeJSON. Iiparamitha zesicelo kwifomathi yeJSON kufuneka zithunyelwe emzimbeni wesicelo se-HTTP.

Kuqala, uyakufuna ifayile yokubhaliweyo ngesicelo seJSON. Siza kuyisebenzisa le fayile ukuyithumela kwi-REST API yethu emzimbeni wesicelo se-POST.


Masithi, ifayile ibekwe kwi /Users/testing-excellence/Perf/blog/json_request.txt

jmeter-json-isicelo-seposi


Isikripthi sethu seJMeter siza kujonga into enje:

jmeter-post-sicelo-json

Ngamanye amagama, kufuneka sikhethe idatha yeQumrhu kwi-Sampler ye-HTTP kwaye sifake umgca olandelayo wekhowudi

${__FileToString(/Users/testing-excellence/Perf/blog/${__eval(${json_file})}.txt,,)}

Ngokucacileyo, indlela iya kwahluka kumatshini wakho.


Umgca ongentla uthatha imixholo yefayile enegama json_file.txt kwaye uthumele imixholo emzimbeni wesicelo kwi-REST API.

Njengoko iJMeter isetyenziselwa ukuvavanywa kokusebenza kunye nokulayisha, sinokulayisha uvavanyo lwethu REST API ngokuthumela izicelo ezininzi zeJSON.

Ukwenza oko sisebenzisa iJMeter yeCVS Data Set Config element.

Kwifayile ye-CSV, sinekholamu enamagama ezicelo zesicelo seJSON. Le fayile ye-CSV isebenza njengesalathiso kwiifayile zeJSON.


Masithi sineefayile ezili-10 zeJSON, ezinamagama efayile 100.txt, 101.txt, 103.txt… .110.txt

jmeter-post-json-isicelo

Kwaye ifayile ye-CSV iya kujongeka:

jmeter-csv-json-isicelo


Ke kwiJMeter, sidibanisa i-CSV Data Set Config element kwisicwangciso sethu sovavanyo

json-csv-sicelo-post-jmeter

Umahluko ngu-JSON_FILE othatha amaxabiso e-100, 101, 102, njl ... kwifayile ye-CSV.

Emva koko sifuna ukubhekisa koku kwahluka kwethu __FileToString() Umsebenzi weJMeter, okt.


jmeter-json-ifayile-csv-isicelo

Xa sisenza olu vavanyo lweJMeter, luya kutyhutyha i-CVS, ithathe igama lefayile nganye kwaye ikhuphe imixholo kwifayile nganye ukuba iyithumele njengeJSON kumzimba wesicelo.