[deploy] Add temporary RSS reader worker to gather monitoring data (#11037)
This commit is contained in:
parent
17535cd90b
commit
b6762fcc7b
2 changed files with 57 additions and 0 deletions
18
app/workers/articles/dev_rss_reader_worker.rb
Normal file
18
app/workers/articles/dev_rss_reader_worker.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# NOTE: [rhymes]
|
||||
# This script will soon be removed. We need it to collect monitoring data on
|
||||
# Datadog about the production behavior of the `RssReader` class
|
||||
module Articles
|
||||
class DevRssReaderWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options queue: :medium_priority, retry: 10
|
||||
|
||||
def perform
|
||||
return unless SiteConfig.community_name == "DEV"
|
||||
return if Rails.cache.read("cancel_rss_job").present?
|
||||
|
||||
# we force fetch to have realistic data
|
||||
RssReader.get_all_articles(force: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
39
spec/workers/articles/dev_rss_reader_worker_spec.rb
Normal file
39
spec/workers/articles/dev_rss_reader_worker_spec.rb
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Articles::DevRssReaderWorker, type: :worker do
|
||||
let(:worker) { subject }
|
||||
|
||||
include_examples "#enqueues_on_correct_queue", "medium_priority"
|
||||
|
||||
describe "#perform" do
|
||||
it "does not call the RssReader for non DEV communities" do
|
||||
allow(SiteConfig).to receive(:community_name).and_return("NotDEV")
|
||||
allow(RssReader).to receive(:get_all_articles)
|
||||
|
||||
worker.perform
|
||||
|
||||
expect(RssReader).not_to have_received(:get_all_articles)
|
||||
end
|
||||
|
||||
it "does not call the RssReader if the cache instructs it to cancel" do
|
||||
allow(SiteConfig).to receive(:community_name).and_return("DEV")
|
||||
allow(Rails.cache).to receive(:read).with("cancel_rss_job").and_return("true")
|
||||
|
||||
allow(RssReader).to receive(:get_all_articles)
|
||||
|
||||
worker.perform
|
||||
|
||||
expect(RssReader).not_to have_received(:get_all_articles)
|
||||
end
|
||||
|
||||
it "calls the RssReader to get all articles" do
|
||||
allow(SiteConfig).to receive(:community_name).and_return("DEV")
|
||||
allow(Rails.cache).to receive(:read).with("cancel_rss_job").and_return(nil)
|
||||
allow(RssReader).to receive(:get_all_articles)
|
||||
|
||||
worker.perform
|
||||
|
||||
expect(RssReader).to have_received(:get_all_articles).with(force: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue