From be7f5187783d42fe2aed369772728de91c918d7e Mon Sep 17 00:00:00 2001 From: william Date: Mon, 30 May 2016 17:50:21 -0400 Subject: [PATCH] stuff --- routes/api.js | 4 ++-- testAPI.py | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/routes/api.js b/routes/api.js index ca9afff..1738d4c 100644 --- a/routes/api.js +++ b/routes/api.js @@ -181,7 +181,7 @@ var runnerFree = function(runner){ }; var lxcTimeout = function(runner, time){ - time = time || 60000 // 900000; // 15 minutes + time = time || 900000; // 15 minutes if(runner.hasOwnProperty('timeout')){ clearTimeout(runner.timeout); @@ -305,7 +305,7 @@ router.get('/liststuff', function(req, res, next){ router.post('/run/:ip?', function doRun(req, res, next){ console.log('hit runner route') - var runner = label2runner[req.params.ip] || getAvailrunner(); + var runner = label2runner[req.params.ip] || false; console.log('') return run(req, res, runner); }); diff --git a/testAPI.py b/testAPI.py index 9ae66a7..decd1ef 100644 --- a/testAPI.py +++ b/testAPI.py @@ -1,10 +1,19 @@ import requests as r import time -def testAPI(times): +def testAPI(times=100, sleep=2): errors = 0 for i in range(times): - res = r.post('http://codeland.bytedev.co:2000/api/run', data={'code': 'pwd'}) - if res.status_code != 200: errors +=1 + try: + res = r.post( + 'http://codeland.bytedev.co:2000/api/run', + data={'code': 'pwd'} + ) + if res.status_code != 200: errors += 1 + print(i, res.status_code) + except: + print('caught error') + errors += 1 + time.sleep(sleep) print('errors ', errors) \ No newline at end of file