clean up skipped tests

tighter connection handling in scheduler
This commit is contained in:
Sam 2017-07-24 15:06:24 -04:00
parent 66ef7976ea
commit c08a7aee8f
4 changed files with 23 additions and 66 deletions

View File

@ -34,16 +34,7 @@ module Scheduler
end
@thread = Thread.new do
while !@stopped
if @manager.enable_stats
begin
RailsMultisite::ConnectionManagement.establish_connection(db: "default")
process_queue
ensure
ActiveRecord::Base.connection_handler.clear_active_connections!
end
else
process_queue
end
process_queue
end
end
end
@ -69,6 +60,7 @@ module Scheduler
end
def process_queue
klass = @queue.deq
return unless klass
@ -83,15 +75,23 @@ module Scheduler
begin
info.prev_result = "RUNNING"
@mutex.synchronize { info.write! }
if @manager.enable_stats
stat = SchedulerStat.create!(
name: klass.to_s,
hostname: hostname,
pid: Process.pid,
started_at: Time.zone.now,
live_slots_start: GC.stat[:heap_live_slots]
)
begin
RailsMultisite::ConnectionManagement.establish_connection(db: "default")
stat = SchedulerStat.create!(
name: klass.to_s,
hostname: hostname,
pid: Process.pid,
started_at: Time.zone.now,
live_slots_start: GC.stat[:heap_live_slots]
)
ensure
ActiveRecord::Base.connection_handler.clear_active_connections!
end
end
klass.new.perform
rescue => e
if e.class != Jobs::HandledExceptionWrapper
@ -120,6 +120,8 @@ module Scheduler
Discourse.handle_job_exception(ex, {message: "Processing scheduled job queue"})
ensure
@running = false
ActiveRecord::Base.connection_handler.clear_active_connections!
end
def stop!

View File

@ -1,40 +0,0 @@
require 'rails_helper'
require 'demon/base'
describe Demon do
class RudeDemon < Demon::Base
def self.prefix
"rude"
end
def after_fork
Signal.trap("HUP"){}
Signal.trap("TERM"){}
sleep 999999
end
end
it "can terminate rude demons" do
skip("forking rspec has side effects")
# Forking rspec has all sorts of weird side effects
# this spec works but we must skip it to keep rspec
# state happy
RudeDemon.start
_,demon = RudeDemon.demons.first
pid = demon.pid
wait_for {
demon.alive?
}
demon.stop_timeout = 0.05
demon.stop
demon.start
running = !!(Process.kill(0, pid)) rescue false
expect(running).to eq(false)
end
end

View File

@ -16,11 +16,6 @@ describe PrettyText do
n(PrettyText.cook(*args))
end
# see: https://github.com/sparklemotion/nokogiri/issues/1173
skip 'allows html entities correctly' do
expect(PrettyText.cook("&aleph;&pound;&#162;")).to eq("<p>&aleph;&pound;&#162;</p>")
end
let(:wrapped_image) { "<div class=\"lightbox-wrapper\"><a href=\"//localhost:3000/uploads/default/4399/33691397e78b4d75.png\" class=\"lightbox\" title=\"Screen Shot 2014-04-14 at 9.47.10 PM.png\"><img src=\"//localhost:3000/uploads/default/_optimized/bd9/b20/bbbcd6a0c0_655x500.png\" width=\"655\" height=\"500\"><div class=\"meta\">\n<span class=\"filename\">Screen Shot 2014-04-14 at 9.47.10 PM.png</span><span class=\"informations\">966x737 1.47 MB</span><span class=\"expand\"></span>\n</div></a></div>" }
let(:wrapped_image_excerpt) { }

View File

@ -59,11 +59,11 @@ describe Scheduler::Manager do
}
before {
expect(ActiveRecord::Base.connection_pool.connections.length).to eq(1)
expect(ActiveRecord::Base.connection_pool.connections.reject{|c| !c.in_use?}.length).to eq(1)
}
after {
expect(ActiveRecord::Base.connection_pool.connections.length).to eq(1)
expect(ActiveRecord::Base.connection_pool.connections.reject{|c| !c.in_use?}.length).to eq(1)
}
it 'can disable stats' do
@ -126,7 +126,7 @@ describe Scheduler::Manager do
expect($redis.zcard(Scheduler::Manager.queue_key)).to eq(0)
end
skip 'should recover from crashed manager' do
it 'should recover from crashed manager' do
info = manager.schedule_info(Testing::SuperLongJob)
info.next_run = Time.now.to_i - 1
@ -145,7 +145,7 @@ describe Scheduler::Manager do
end
# something about logging jobs causing a leak in connection pool in test
skip 'should log when job finishes running' do
it 'should log when job finishes running' do
Testing::RandomJob.runs = 0