Test stabilization: Limited window for possible race condition between server restart and availability check.
This commit is contained in:
parent
db1378244c
commit
798add3642
1 changed files with 14 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
||||||
class Widget extends App.Controller
|
class Widget extends App.Controller
|
||||||
errorCount: 0
|
serverRestarted: false
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
|
|
||||||
|
@ -109,21 +109,24 @@ class Widget extends App.Controller
|
||||||
)
|
)
|
||||||
@delay(message, 2000)
|
@delay(message, 2000)
|
||||||
|
|
||||||
checkAvailability: (delay) =>
|
checkAvailability: (timeout) =>
|
||||||
delay = =>
|
delay = =>
|
||||||
@ajax(
|
@ajax(
|
||||||
id: 'check_availability'
|
id: 'check_availability'
|
||||||
type: 'get'
|
type: 'get'
|
||||||
url: "#{@apiPath}/available"
|
url: "#{@apiPath}/available"
|
||||||
success: (data) =>
|
success: (data) =>
|
||||||
if @errorCount is 0
|
if @serverRestarted
|
||||||
@checkAvailability()
|
@windowReload()
|
||||||
return
|
return
|
||||||
@windowReload()
|
|
||||||
error: =>
|
|
||||||
@errorCount += 1
|
|
||||||
@checkAvailability()
|
@checkAvailability()
|
||||||
|
error: =>
|
||||||
|
@serverRestarted = true
|
||||||
|
@checkAvailability(2000)
|
||||||
)
|
)
|
||||||
@delay(delay, 2000)
|
|
||||||
|
timeout ?= 1000
|
||||||
|
@delay(delay, timeout)
|
||||||
|
|
||||||
App.Config.set('maintenance', Widget, 'Widgets')
|
App.Config.set('maintenance', Widget, 'Widgets')
|
||||||
|
|
Loading…
Reference in a new issue