Created
February 25, 2014 17:57
-
-
Save davidworkman9/9214246 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var url = 'http://localhost:3000'; | |
var page = require('webpage').create(); | |
var pageCreator = require('webpage'); | |
var listeners = 0, | |
numListeners = 1, | |
loginCount = 0, | |
listenerPages = []; | |
(function () { | |
for(var i = 0; i < numListeners; ++i) { | |
listenerPages.push(pageCreator.create()); | |
} | |
})(); | |
function loadListener(listener) { | |
if(!listener) { return; } | |
listener.open(url, function (status) { | |
listener.onConsoleMessage = function (msg) { | |
if(msg === "increaseLogCount") { loginCount++; } else { console.log(msg); } | |
}; | |
listener.evaluate(function () { | |
Meteor.loginWithPassword('email', 'password', function (err) { if(err) { console.log(err); } console.log('increaseLogCount'); }); | |
}); | |
loadListener(listenerPages[listenerPages.indexOf(listener)+1]); | |
}); | |
} | |
loadListener(listenerPages[0]); | |
var handle = setInterval(function () { | |
console.log(loginCount, numListeners); | |
if(loginCount !== numListeners) | |
return; | |
console.log('loaded all ' + numListeners + ' listeners'); | |
clearInterval(handle); | |
page.open(url, function (status) { | |
page.onConsoleMessage = function (msg) { | |
if(msg === "exit") { phantom.exit(); } | |
else { console.log(msg); } | |
}; | |
page.evaluate(function() { | |
Meteor.loginWithPassword('email', 'password', function(err) { | |
if(err) { console.log(err); console.log('exit'); } | |
console.log('about to insert'); | |
var iters = 200; | |
var tmp; | |
var id = Collection.insert({name: 'loadTester' }); | |
console.log('inserted id ' + id); | |
for(var i=1; i<=iters; i++) { | |
tmp = "loadTester" + i.toString(); | |
Collection.update({"_id": id }, {$set : {"name" : tmp}}, function() { if(i=iters) console.log('exit'); }); | |
} | |
}); | |
}); | |
}); | |
},1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment