-
-
Save bigjust/3687479 to your computer and use it in GitHub Desktop.
a simple script for loadtesting solr using it's logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var sys = require("sys"); | |
var http = require("http"); | |
var request = require("request"); | |
// this is what you'll be testing | |
var host = process.argv[2]; | |
var port = 80; | |
var regex = /"GET (\S+)/; | |
//open stdin | |
process.stdin.resume(); | |
process.stdin.setEncoding('utf8'); | |
var data = ''; | |
var jar = request.jar(); | |
jar.add(request.cookie("""""""""")); | |
//split into lines and async | |
process.stdin.on('data', function (chunk) { | |
var foo = data + chunk; | |
var lines = foo.split('\n'); | |
data = lines.pop(); | |
console.log(lines.length); | |
lines.forEach( function(line) { | |
process.nextTick(function() {make_request(line);}); | |
console.log("calling back"); | |
}); | |
}); | |
//make sure the line is a request, extract the url and make it | |
var make_request = function make_request (line) { | |
console.log("called the shit"); | |
var match = regex.exec(line); | |
if(match) { | |
var url = match[2]; | |
url = "http://" + host + url; | |
request({url: url, jar: jar }, function(err, resp, body){ | |
console.log('MADE REQUEST TO: '+ host + url); | |
console.log('STATUS: ' + response.statusCode); | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var sys = require("sys"); | |
var http = require("http"); | |
// this is what you'll be testing | |
var host = "www.test.wsbtv.com" //process.argv[2]; | |
var conc = 100 //process.argv[3]; | |
var port = 80; | |
var path = '/'; | |
var success = 0; | |
var error = 0; | |
var counter = 0 | |
var make_request = function make_request (client) { | |
var request = client.request('GET', path, { 'host': host}); | |
request.end(); | |
request.on('response', function(response) { | |
if(response.statusCode != 200){ | |
error++; | |
console.log('STATUS: ' + response.statusCode + ' ' + error); | |
} | |
counter++; | |
if (counter%100 == 0){ | |
console.log("counter: " + counter); | |
} | |
make_request(client); | |
}); | |
} | |
for(var i=0; i<conc; i++){ | |
console.log("starting a client"); | |
var client = http.createClient(port, host); | |
//process.nextTick(function() { make_request(client); }); | |
make_request(client); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var sys = require("sys"); | |
var http = require("http"); | |
// this is what you'll be testing | |
var host = 'localhost'; | |
var port = 8080; | |
var solr = http.createClient(port, host); | |
var core_path = '/solr/medley'; | |
var regex = /path=(\/\w+\/)\sparams=\{(.+)\}/g; | |
//open stdin | |
process.stdin.resume(); | |
process.stdin.setEncoding('utf8'); | |
var data = ''; | |
//split into lines and async | |
process.stdin.on('data', function (chunk) { | |
foo = data + chunk; | |
var lines = foo.split('\n'); | |
data = lines.pop(); | |
console.log(lines.length); | |
lines.forEach( function(line) { | |
process.nextTick(function() {make_request(line);}); | |
console.log("calling back"); | |
}); | |
}); | |
//make sure the line is a request, extract the url and make it | |
var make_request = function make_request (line) { | |
console.log("called the shit"); | |
var match = regex.exec(line); | |
if(match) { | |
var url = core_path + match[1] + '?' + match[2]; | |
var request = solr.request('GET', url); | |
request.end(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment