Skip to content

Commit

Permalink
Merge branch 'master' into alec/12424-scm-perform-judge-actions-ama
Browse files Browse the repository at this point in the history
  • Loading branch information
va-bot authored Mar 30, 2020
2 parents ab0e86f + cac8071 commit 68ef04b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/jobs/data_integrity_checks_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ def perform
RequestStore.store[:current_user] = User.system_user

CHECKERS.each do |klass|
checker_start_time = Time.zone.now
checker = klass.constantize.new
checker.call
datadog_report_time_segment(segment: klass.underscore, start_time: checker_start_time)
if checker.report?
send_to_slack(checker)
end
end

datadog_report_runtime(metric_group_name: "data_integrity_checks_job")
end

private
Expand Down
28 changes: 26 additions & 2 deletions spec/jobs/data_integrity_checks_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,35 @@
allow(checker).to receive(:report).and_call_original
end
allow(slack_service).to receive(:send_notification).and_return(true)

@emitted_gauges = []
allow(DataDogService).to receive(:emit_gauge) do |args|
@emitted_gauges.push(args)
end
end

describe "#perform" do
subject { described_class.perform_now }

it "updates DataDog" do
subject

expect(@emitted_gauges).to include(
app_name: "caseflow_job",
metric_group: "data_integrity_checks_job",
metric_name: "runtime",
metric_value: anything
)
expect(@emitted_gauges).to include(
app_name: "caseflow_job_segment",
metric_group: "expired_async_jobs_checker",
metric_name: "runtime",
metric_value: anything
)
end

it "does not send slack notifications unless there is a report" do
described_class.perform_now
subject

expect(expired_async_jobs_checker).to have_received(:call).once
expect(expired_async_jobs_checker).to have_received(:report?).once
Expand All @@ -57,7 +81,7 @@
end

it "sends slack notification if there is a report" do
described_class.perform_now
subject

expect(expired_async_jobs_checker).to have_received(:call).once
expect(expired_async_jobs_checker).to have_received(:report?).once
Expand Down

0 comments on commit 68ef04b

Please sign in to comment.