Log In
Log In
Places
All Projects
Status Monitor
Collapse sidebar
obs:server:fedora:2.9
obs-server
obs-server-2.9-0031-ci-Make-test-backend-crash-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File obs-server-2.9-0031-ci-Make-test-backend-crash-more-prominent.patch of Package obs-server
From fa2bd3dc2e2a9eb908942d7a72bf87f7a331c780 Mon Sep 17 00:00:00 2001 From: Oleg Girko <ol@infoserver.lv> Date: Mon, 15 Oct 2018 00:49:01 +0100 Subject: [PATCH] [ci] Make test backend crash more prominent. Before this change test backend crashes were silent. All backends were keeping working, just their output was not logged anymore, and some tests were failing for non-obvious reasons. This change fixes this "swipe under rug" approach. A thread is started that keeps monitoring test backend's output after backend reported that its initialisation is complete with "DONE NOW" output line. If test backend has finished prematurely, EOF condition is detected by that thread, backend is marked as dead and exception is raised. All subsequent attempts to start test backend are prevented by raising the same exception. This doesn't cause the whole test suite to fail fast, but at least, it makes problems with crashed test backend prominent enough to attract attention. Signed-off-by: Oleg Girko <ol@infoserver.lv> --- src/api/lib/backend/test.rb | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/api/lib/backend/test.rb b/src/api/lib/backend/test.rb index 0d1963fd1b..6a80916339 100644 --- a/src/api/lib/backend/test.rb +++ b/src/api/lib/backend/test.rb @@ -6,14 +6,20 @@ module Backend # Starts the test backend def self.start(options = {}) return unless Rails.env.test? - return if @backend + if @backend + raise 'Backend died' if @backend == :backend_died + return + end return if ENV['BACKEND_STARTED'] print 'Starting test backend...' @backend = IO.popen("#{Rails.root}/script/start_test_backend") Rails.logger.debug "Test backend started with pid: #{@backend.pid}" loop do line = @backend.gets - raise 'Backend died' unless line + unless line + @backend = :backend_died + raise 'Backend died' + end break if line =~ /DONE NOW/ Rails.logger.debug line.strip end @@ -21,9 +27,23 @@ module Backend CONFIG['global_write_through'] = true WebMock.disable_net_connect!(allow_localhost: true) ENV['BACKEND_STARTED'] = '1' + backend_done = false + backend_logger = Thread.new do + loop do + line = @backend.gets + unless line + break if backend_done + @backend = :backend_died + raise 'Backend died' + end + end + end + backend_logger.abort_on_exception = true at_exit do + backend_done = true puts 'Killing test backend' Process.kill 'INT', @backend.pid + backend_logger.join @backend = nil end -- 2.20.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Contact
Support
@OBShq
The Open Build Service is an
openSUSE project
.
Log In
Places
Places
All Projects
Status Monitor