mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-28 08:01:14 +00:00
[misc] test/acceptance: add tests for the draining of connections
This commit is contained in:
parent
1c9eaf574a
commit
91e296533f
1 changed files with 72 additions and 0 deletions
|
@ -0,0 +1,72 @@
|
|||
RealTimeClient = require "./helpers/RealTimeClient"
|
||||
FixturesManager = require "./helpers/FixturesManager"
|
||||
|
||||
expect = require("chai").expect
|
||||
|
||||
async = require "async"
|
||||
request = require "request"
|
||||
|
||||
Settings = require "settings-sharelatex"
|
||||
|
||||
drain = (rate, callback) ->
|
||||
request.post {
|
||||
url: "http://localhost:3026/drain?rate=#{rate}"
|
||||
auth: {
|
||||
user: Settings.internal.realTime.user,
|
||||
pass: Settings.internal.realTime.pass
|
||||
}
|
||||
}, (error, response, data) ->
|
||||
callback error, data
|
||||
return null
|
||||
|
||||
describe "DrainManagerTests", ->
|
||||
before (done) ->
|
||||
FixturesManager.setUpProject {
|
||||
privilegeLevel: "owner"
|
||||
project: {
|
||||
name: "Test Project"
|
||||
}
|
||||
}, (e, {@project_id, @user_id}) => done()
|
||||
return null
|
||||
|
||||
describe "with two clients in the project", ->
|
||||
beforeEach (done) ->
|
||||
async.series [
|
||||
(cb) =>
|
||||
@clientA = RealTimeClient.connect()
|
||||
@clientA.on "connectionAccepted", cb
|
||||
|
||||
(cb) =>
|
||||
@clientB = RealTimeClient.connect()
|
||||
@clientB.on "connectionAccepted", cb
|
||||
|
||||
(cb) =>
|
||||
@clientA.emit "joinProject", project_id: @project_id, cb
|
||||
|
||||
(cb) =>
|
||||
@clientB.emit "joinProject", project_id: @project_id, cb
|
||||
], done
|
||||
|
||||
describe "starting to drain", () ->
|
||||
# there is an internal delay of 1000ms, shift accordingly
|
||||
@timeout(5000)
|
||||
beforeEach (done) ->
|
||||
async.parallel [
|
||||
(cb) =>
|
||||
@clientA.on "reconnectGracefully", cb
|
||||
(cb) =>
|
||||
@clientB.on "reconnectGracefully", cb
|
||||
|
||||
(cb) -> drain(2, cb)
|
||||
], done
|
||||
|
||||
afterEach (done) ->
|
||||
# reset drain
|
||||
drain(0, done)
|
||||
|
||||
it "should not timeout", ->
|
||||
expect(true).to.equal(true)
|
||||
|
||||
it "should not have disconnected", ->
|
||||
expect(@clientA.socket.connected).to.equal true
|
||||
expect(@clientB.socket.connected).to.equal true
|
Loading…
Reference in a new issue