简单的测试小工具

test.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script>
<body>

<!--<a href="https://www.baidu.com" download="baidu.html">下载</a>-->
<button onclick="run()">测试接口</button>
<button onclick="runConcurrency()">并发测试接口</button>
</body>

<script>

var settings = {
"async": true,
"crossDomain": true,
"url": "http://local.ims.qunarman.com:8080/pay/freeRoom/deduction.json",
"method": "POST",
"headers": {
"content-type": "application/json",
"cache-control": "no-cache",
"postman-token": "cf69a168-df11-df81-c8cf-61dac0168c72"
},
"processData": false,
"data": "{\n \"hotelSeq\": \"sanya_2048\",\n \"freeRoomPayParam\": {\n \"freeRooms\": [\n {\n \"saleSRoomId\": 100000,\n \"freeRoomTypeName\": \"标间\",\n \"forbiddenDateRangeList\": [\n {\n \"startTime\": \"2017-12-25\",\n \"endTime\": \"2017-12-29\"\n }\n ],\n \"roomQuantity\": 1,\n \"weekendSale\": true\n }\n ]\n },\n \"order\": \"o611392963963\",\n \"orderVersion\": 1,\n \"code\": \"1234\"\n}"
}

function run() {
console.log("开始请求");
$.ajax(settings).done(function (response) {
console.log(response);
});
}

function runConcurrency() {
for (var i = 0; i < 1000; i++) {
console.log("开始请求第", i + 1, "次");
$.ajax(settings).done(function (response) {
console.log(response);
});
}

}

</script>
</html>