summaryrefslogtreecommitdiff
path: root/tests/http/server.js
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-11-02 13:17:11 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-11-02 13:17:11 -0800
commitfd3916a49e7923e95c47c70afb8696f110b79951 (patch)
tree5008ae1856ad91cbd599614c99001b3aafd7882e /tests/http/server.js
parente53ef9642e0201880672699ca12edd50d103be9e (diff)
downloadinfinitytier-fd3916a49e7923e95c47c70afb8696f110b79951.tar.gz
infinitytier-fd3916a49e7923e95c47c70afb8696f110b79951.zip
More test stuff... make it more granular and less batch based.
Diffstat (limited to 'tests/http/server.js')
-rw-r--r--tests/http/server.js40
1 files changed, 10 insertions, 30 deletions
diff --git a/tests/http/server.js b/tests/http/server.js
index 30d8339a..57109392 100644
--- a/tests/http/server.js
+++ b/tests/http/server.js
@@ -20,42 +20,22 @@ app.use(function(req,res,next) {
var knownAgents = {};
-app.get('/:agentId',function(req,res) {
- var agentId = req.params.agentId;
- if ((!agentId)||(agentId.length !== 32))
- return res.status(404).send('');
- knownAgents[agentId] = Date.now();
- return res.status(200).send(JSON.stringify(Object.keys(knownAgents)));
-});
-
-app.post('/:testNumber/:agentId',function(req,res) {
- var testNumber = req.params.testNumber;
+app.post('/:agentId',function(req,res) {
var agentId = req.params.agentId;
if ((!agentId)||(agentId.length !== 32))
return res.status(404).send('');
- var receiveTime = Date.now();
- var resultData = null;
- try {
- resultData = JSON.parse(req.rawBody);
- } catch (e) {
- resultData = req.rawBody;
+ if (req.rawBody) {
+ var receiveTime = Date.now();
+ var resultData = null;
+ try {
+ resultData = JSON.parse(req.rawBody);
+ console.log(resultData.source+','+resultData.target+','+resultData.time+','+resultData.bytes+','+resultData.timedOut+',"'+((resultData.error) ? resultData.error : '')+'"');
+ } catch (e) {}
}
- result = {
- agentId: agentId,
- testNumber: parseInt(testNumber),
- receiveTime: receiveTime,
- results: resultData
- };
-
- testNumber = testNumber.toString();
- while (testNumber.length < 10)
- testNumber = '0' + testNumber;
- fs.writeFile('result_'+testNumber+'_'+agentId,JSON.stringify(result),function(err) {
- console.log(result);
- });
- return res.status(200).send('');
+ knownAgents[agentId] = Date.now();
+ return res.status(200).send(JSON.stringify(Object.keys(knownAgents)));
});
var expressServer = app.listen(SERVER_PORT,function () {