Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Minor modifications to smoke test. Fix #4

  • Loading branch information...
commit 8dc1e91acbdf0309bd0aa134cc9a753de20d9f3c 1 parent f93b8c7
Marek majek authored
Showing with 18 additions and 17 deletions.
  1. +2 −3 client.coffee
  2. +5 −0 common.coffee
  3. +11 −14 smoke-test.coffee
5 client.coffee
View
@@ -3,7 +3,7 @@ common = require('./common')
exports.GenericClient = class GenericClient extends events.EventEmitter
constructor: (url) ->
- @id = ('' + Math.random()).slice(2)
+ @id = ('' + Math.random()).slice(2, 16)
@url = url + '/0/' + @id
@buffer = []
@is_opened = false
@@ -19,9 +19,8 @@ exports.GenericClient = class GenericClient extends events.EventEmitter
@is_opened = true
@emit('open')
else
- console.log('Already open')
@is_closed = true
- @emit('close', 1000, 'error')
+ @emit('close', 1000, 'Connection prematurely closed!')
when 'h' then null
when 'a'
for m in JSON.parse(payload)
5 common.coffee
View
@@ -21,6 +21,7 @@ exports.HttpRequest = class HttpRequest extends events.EventEmitter
@req.socket.setTimeout(60000)
@status = @res.statusCode
@headers = @res.headers
+ @emit('start')
@res.on 'data', (chunk) =>
chunk = chunk.toString('utf-8')
@chunks.push(chunk)
@@ -33,6 +34,7 @@ exports.HttpRequest = class HttpRequest extends events.EventEmitter
@req.on 'error', (e) =>
console.log('error!',e)
+ process.exit(1)
if (body or '').length > 0
@req.end(body, 'utf-8')
else
@@ -74,3 +76,6 @@ exports.StdDev = class StdDev
avg = @avg()
variance = (@sum_sq / @count) - (avg * avg)
return Math.sqrt(variance)
+
+exports.now = ->
+ (new Date()).getTime()
25 smoke-test.coffee
View
@@ -7,15 +7,13 @@ common = require('./common')
url = 'http://localhost:8080/echo'
-count = 200
-hz = 5
-seconds = 5
-test = 'idle'
-transport = 'xhr_polling'
+count = 500
+hz = 1
+seconds = 20
console.log(' [*] Connecting to ' + url +
- ' (connections:' + count +
- ', test:' + test + ', transport:' + transport + ')')
+ ' (count:' + count +
+ ', hz:' + hz + ', seconds:' + seconds + ')')
connected_counter = 0
connected = ->
@@ -33,8 +31,6 @@ closed = ->
' dev=', stats.dev(),
' (' + stats.count + ' data points)')
-now = ->
- (new Date()).getTime()
stats = new common.StdDev()
@@ -45,16 +41,17 @@ conns = for i in [0...count]
conn.on('open', connected)
conn.on 'message', (t0) ->
c -= 1
- delay = now() - Number(t0)
+ delay = common.now() - Number(t0)
stats.add(delay)
if c > 0
- go = -> conn.send('' + now())
+ go = -> conn.send('' + common.now())
setTimeout(go, 1000/hz)
else
closed()
conn.close()
- conn.on 'close', -> console.log('ERROR')
+ conn.on 'close', (_, reason) ->
+ closed()
+ console.log('ERROR', reason)
return ->
- conn.send('' + now())
-
+ conn.send('' + common.now())
Please sign in to comment.
Something went wrong with that request. Please try again.