当前位置:网站首页>Jmeter- (IV) regular expression for interface testing
Jmeter- (IV) regular expression for interface testing
2022-06-25 21:18:00 【Hello, test】
Preface :
stay jmeter View a list in , Generally, we will get a corresponding... According to a field ID, For subsequent use cases , When matching , Regular expressions are used , The writing method varies according to the data structure of the return value of the list , Here are a few common formats , Then there are other formats , It can be supplemented .
These operators are used below , Please refer to the screenshot below :
Refer to the website :JsonPath Use _LZJWXJ Koalas -CSDN Blog

1. according to name obtain moid
"result":
[{
"network": 7,
"moid": "datacenter-57",
"datastore": 2,
"name": "DC1"
}]
}
JSONPath Expression: $.result[?(@.name =='${NAME}')][0].moid
2. according to host_name obtain host_moid
"result":
[ {
"cluster_name": "test FT",
"cluster_type": true,
"cluster_moid": "domain-c1960",
"child":
[ {
"host_moid": "host-2179",
"host_name": "10.10.132.111"
} ]
}]
JSONPath Expression: $.result[0].child[?(@.host_name=='${HOST_NAME}')][0].host_moid
3. Direct access to cpu and memory_KB
"result":
{
"data_store":
[ {
"moid": "datastore-2181",
"name": "datastore1",
"ssd": "false",
"type": "VMFS",
"thin_support": true
}],
"cpu":32,
"memory_KB": 67108276
}
JSONPath Expression: obtain cpu: $.result.cpu
obtain memory_KB: $.result.memory_KB
4. according to name obtain moid
"result":
{
"data_store":
[ {
"moid": "datastore-2181",
"name": "datastore1",
"type": "VMFS",
"thin_support": true
}],
"cpu":32,
"memory_KB": 67108276
}
JSONPath Expression: $.result.data_store[?(@.name=='${DATASTORE_NAME}')][0].moid
5. Based on acquisition state
"result":
{
"childSnapshotList":
[
{
"currentSnapshot": false,
"quiesced": false,
"state": "suspended",
"childSnapshotList":
[
{
"currentSnapshot": true,
"quiesced": false,
"state": "poweredOff",
"childSnapshotList":
[
],
"name"
"SNAPSHOT1_2",
"id": 56
}
],
"name"
"SNAPSHOT_2",
"id": 55
}
]
}
JSONPath Expression: $.result.childSnapshotList[0].childSnapshotList[?(@.name =='${SNAPSHOT1}')][0].state
Hello Test, The above examples are all used by me Jmeter During interface testing , Some of the common API The structure of the response data , Write regular expressions according to different structures , You can refer to the same type of structure , Leave a message in the comment area , finger heart ~
边栏推荐
- A simple file searcher
- The difference between strcpy and memcpy
- QT method of exiting application (exe)
- On ACM competition
- [opencv] opencv from introduction to mastery -- detailed explanation of input and output XML and yaml files
- What is machine learning? (Fundamentals)
- Code program related problems troubleshooting directory
- Write a "standard" macro min, which inputs two parameters and returns the smaller one
- How to write an infinite loop
- [nailing scenario capability package] smart office phone
猜你喜欢

Lantern Festival, learning at the right time! Novice training camp attacks again, learning buff continues to fill up

js (1)

A simple file searcher
![[important notice] developer document update (12.13-12.19)](/img/49/6a54235409ec95fa50bcc14ef1d405.jpg)
[important notice] developer document update (12.13-12.19)
![[buucry] sensor (Manchester code)](/img/ab/066923f1aa1e8dd8dcc572cb60a25d.jpg)
[buucry] sensor (Manchester code)

Node installation method you don't know
![[nailing scenario capability package] smart office phone](/img/ec/c2f342a54ab69d8b834a8a1c8f8a01.jpg)
[nailing scenario capability package] smart office phone

Cvpr2019 | the latest cvpr2019 papers are the first to read!

js(3)

Openocd adds third-party device support: ht32f52352 Cortex-M0+
随机推荐
[machine learning] machine learning from zero to mastery -- teach you to recognize handwritten digits using KNN
[phase 23] phased summary of spring recruitment practice (Alibaba cloud has OC)
Multi database and multi table backup and restore of MySQL under Linux
[summary] 2021unctf Campus (cry & MISC)
C language dynamic memory allocation
OLED driver learning based on ssd1306 (I): SSD Chinese command table (handling)
Analysis and cleaning of kdevtmpfsi virus content
炒股票用指南针安全还是用证券软件安全?哪里可以开户怎么开
Docker failed to remotely access 3306 after installing MySQL
Is it safe to open an account with qiniu securities?
Heavy update! Yolov4 latest paper! Interpreting yolov4 framework
Openocd adds third-party device support: ht32f52352 Cortex-M0+
Finger collar pin exclusive Medal
Shell scripts: Variables
[nailing scenario capability package] video conference (official conference system)
[important notice] developer document update (12.13-12.19)
Soft test intermediate simple notes
On dynamic programming
What is DNS (domain name server)? (Powercert animated videos)
IPtables