当前位置:网站首页>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 ~
边栏推荐
- [nailing scenario capability package] ranking of enterprise employees' points
- Illustrated with pictures and texts, 700 pages of machine learning notes are popular! Worth learning
- Shell syntax
- How to write an infinite loop
- Inventory - those automated test interview questions you can't help but know
- The difference between strcpy and memcpy
- What is machine learning? (Fundamentals)
- couldn‘t be accessed by user ‘_ apt‘
- Lesson 1 Preparation
- Openocd compilation and installation
猜你喜欢
[opencv] opencv from introduction to mastery -- detailed explanation of input and output XML and yaml files
C language soul torture: do you know the difference between the two?
Volatile qualifier
[distributed system design profile (1)] raft
Node installation method you don't know
Yolov4 reading notes (with mind map)! YOLOv4: Optimal Speed and Accuracy of Object Detection
Explain memcached principle in detail
[nail scenario capability package] hospital visitor verification
"Developer theory" multi system integrated development - rapid nailing of enterprise owned systems
04 disk space management
随机推荐
C language soul torture: do you know the difference between the two?
[distributed system design profile (1)] raft
How to solve the problem of flash write protection in STM32?
JS__ Inheritance mode, namespace, object enumeration__ Duyi
What is API
Server pressure troubleshooting top
couldn‘t be accessed by user ‘_ apt‘
Cvpr2021 collection of papers | cvpr2021 latest papers | cvpr2021 review results | cvpr2021 admission results
Is it legal to open an account for flush stock trading software? Is it safe?
Lesson 3 urllib
Multi database and multi table backup and restore of MySQL under Linux
2022年启牛学堂证券开户安全嘛?
同花顺炒股软件开户是合法的吗?安全吗
VFS appears when mounting a file system from an SD card: cannot open root device "mmcblk1p2“
银河证券靠谱吗?开证券账户安全吗?
Svn various color states
Shell syntax
Docker Alpine image installation PHP extension redis
On merging and sorting
Get parameters in URL