Skip to content

Commit

Permalink
添加并发测试
Browse files Browse the repository at this point in the history
  • Loading branch information
wei.ma1 committed Oct 30, 2021
1 parent 092206b commit f2b1407
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"node-input-validator": "^4.4.1"
},
"devDependencies": {
"express": "^4.17.1"
"express": "^4.17.1",
"node-fetch": "^2.0.0"
}
}
24 changes: 24 additions & 0 deletions test/concurrency/test01.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const fetch = require('node-fetch');

const urls = [
'http://localhost:8000/api/test/test1',
'http://localhost:8000/api/test/test2',
'http://localhost:8000/api/test/test3',
'http://localhost:8000/api/test/test4',
'http://localhost:8000/api/test/test5',
'http://localhost:8000/api/test/test6',
'http://localhost:8000/api/test/test7',
'http://localhost:8000/api/test/test8',
'http://localhost:8000/api/test/test9',
'http://localhost:8000/api/test/test10/xxxx',
'http://localhost:8000/api/test/test10/list',
'http://localhost:8000/api/test/test10/status',
];
urls.forEach((url) => {
fetch(url)
.then((data) => {
return data.json()
}).then((data) => {
console.log(url, data);
});
})
1 change: 1 addition & 0 deletions test/test2.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// 支持mockjs test2.js
$sleep(1000);

export default {
code: 1000,
Expand Down

0 comments on commit f2b1407

Please sign in to comment.