Load testing script - JavaScript browser
https://bountify.co/load-testing-script-javascript-browser I have a system that we are using to track events, similar to google analytic. what i need is a high speed way to get some traffic on this to test it. I want to be able to give several people a url and when they open it, it will fire off a bunch of randomly generated get requests. A couple weeks ago i had a bounty for making urls which worked great (used mtruk for testing) but then we thought it might be better to just have the page automatically request the GETs vs having someone click on them. Feel free to use this previously made code for our url structure - it works perfect. http://jsfiddle.net/49oz32u0/1/ In the page/js i should be able to define how many automate requests are made, i don't want to kill the testers browser or my stats system. Ideally we can do something like 20 concurrent requests and up to 500 total. I think the only think we need to see on the page is a list of actual urls being requested. this way we can compare request of that page with what we see on the server to make sure everything is good. only needs to work in new chrome if that helps.
by Sree K
HTML
<input type="text" id="count" value="500"/> requests
<br>
<input type="text" id="parallel" value="20"/> in parallel
<br/>
<button id="go">go</button>
<br/>
<br/>
<textarea style="width: 800px; height: 500px;"></textarea>
JavaScript
$(function () {
$('#go').on('click', function(){
var cnt = 0;
var total = $('#count').val();
var parallel = $('#parallel').val();
var urls = [];
for(var i = 0; i<=total; i++){
urls.push(getRandomURL());
}
for(var i=0;i<=parallel;i++) {
var url = urls.pop();
$.get(url, cb(url));
}
function cb(oldUrl){
return function(){
$('textarea').val(oldUrl+'\n'+$('textarea').val());
var url = urls.pop();
if (url) $.get(url, cb(url));
}
}
});
});
function getRandomURL() {
return window.location.origin + '/?' + getRandomQuery();
}
function getRandomQuery() {
var data = {
user: [
'Alice',
'Billy',
'Bob',
'Chloe',
'Jenny',
'Jerry',
'John',
'Katie',
'Mary',
'Shannon',
'Thomas',
'Tom'
],
event: [
'page123',
'page124',
'page125',
'page126',
'page127',
'page128',
'page129',
'page130',
'page131',
'page132',
'page133',
'page134',
'page135',
'page136',
'page137',
'page138',
'page139',
'page140',
'page141',
'page142',
'page143',
'page144',
'page145',
'page146',
'page147',
'page148',
'page149',
'page150',
'page151',
'page152',
'page153',
'page154',
'page155',
'page156'
],
eventType: [
'click',
'create',
'delete',
'exportdocx',
'exporthtml',
'login',
'logout',
'logout',
'update'
],
project:...