Maintenance: improves Websocket stability in CI

This commit is contained in:
Mantas Masalskis 2020-04-24 08:55:06 +03:00
parent c59a627383
commit 62a6d5e2ca
6 changed files with 33 additions and 5 deletions

View file

@ -361,7 +361,7 @@ browser:build:
.variables_browser_template: &variables_browser_definition
RAILS_ENV: "production"
APP_RESTART_CMD: "bundle exec rake zammad:ci:app:restart"
APP_RESTART_CMD: "bundle exec rake environment zammad:ci:app:restart"
.test_browser_core_template: &test_browser_core_definition
<<: *base_env

View file

@ -52,7 +52,7 @@ class _webSocketSingleton extends App.Controller
connectionEstablished: false
connectionWasEstablished: false
tryToConnect: false
backend: 'websocket'
backend: undefined # set in constructor when config is available
backend_port: ''
client_id: undefined
error: false
@ -60,6 +60,8 @@ class _webSocketSingleton extends App.Controller
constructor: (@args) ->
super
@backend = @Config.get('websocket_backend') || 'websocket'
# on auth, send new auth data to server
App.Event.bind(
'auth'

View file

@ -0,0 +1,15 @@
class SettingWebsocketBackend < ActiveRecord::Migration[5.2]
def change
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
Setting.create_if_not_exists(
title: 'Websocket backend',
name: 'websocket_backend',
area: 'System::WebSocket',
description: 'Defines how to reach websocket server. "websocket" is default on production, "websocketPort" is for CI',
state: Rails.env.production? ? 'websocket' : 'websocketPort',
frontend: true
)
end
end

View file

@ -277,6 +277,14 @@ Setting.create_if_not_exists(
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Websocket backend',
name: 'websocket_backend',
area: 'System::WebSocket',
description: 'Defines how to reach websocket server. "websocket" is default on production, "websocketPort" is for CI',
state: Rails.env.production? ? 'websocket' : 'websocketPort',
frontend: true
)
Setting.create_if_not_exists(
title: 'Websocket port',
name: 'websocket_port',

View file

@ -6,6 +6,9 @@ namespace :zammad do
desc 'Starts the application and uses BROWSER_PORT, RAILS_ENV and WS_PORT ENVs'
task :start do # rubocop:disable Rails/RakeEnvironment
# runs in CI old browser tests as RAILS_ENV=production, thus needs setting in here
Setting.set('websocket_backend', 'websocketPort')
Rake::Task['zammad:ci:service:puma:start'].invoke(ENV['BROWSER_PORT'], ENV['RAILS_ENV'])
Rake::Task['zammad:ci:service:websocket:start'].invoke(ENV['WS_PORT'])
Rake::Task['zammad:ci:service:scheduler:start'].invoke

View file

@ -21,7 +21,7 @@ RSpec.describe 'Login Message', type: :system, authenticated: false do
Setting.set 'maintenance_login', false
wait(10).until_disappears { find '.js-maintenanceLogin', text: message }
wait(10).until_disappears { find '.js-maintenanceLogin', text: message, wait: false }
expect(page).not_to have_css('.js-maintenanceLogin')
end
@ -31,7 +31,7 @@ RSpec.describe 'Login Message', type: :system, authenticated: false do
Setting.set 'maintenance_login_message', alt_message
wait(10).until_exists { find '.js-maintenanceLogin', text: alt_message }
wait(10).until_exists { find '.js-maintenanceLogin', text: alt_message, wait: false }
expect(page).to have_css('.js-maintenanceLogin', text: alt_message)
end
@ -51,7 +51,7 @@ RSpec.describe 'Login Message', type: :system, authenticated: false do
Setting.set 'maintenance_login', true
wait(10).until_exists { find '.js-maintenanceLogin', text: message }
wait(10).until_exists { find '.js-maintenanceLogin', text: message, wait: false }
expect(page).to have_css('.js-maintenanceLogin', text: message)
end