Skip to content

Commit

Permalink
spec: use sharding for DJ apm spec
Browse files Browse the repository at this point in the history
FIXES APM-25
flag = none

also properly implments plugin
reset so that we can enable/disable
without rebooting the process

test plan:
  specs pass flaky spec catcher
Change-Id: I96e8137e351639559d68c8f1e9242e1c315cb26d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/231006
Reviewed-by: David Warkentin <[email protected]>
Reviewed-by: James Butters <[email protected]>
Tested-by: Service Cloud Jenkins <[email protected]>
QA-Review: Ethan Vizitei <[email protected]>
Product-Review: Ethan Vizitei <[email protected]>
  • Loading branch information
evizitei committed Mar 23, 2020
1 parent 2675c3b commit 56da7cc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/canvas/apm/inst_jobs/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class << self
attr_writer :tracer

def reset!
super
@tracer = nil
end

Expand Down
11 changes: 8 additions & 3 deletions spec/lib/canvas/apm/inst_jobs/plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
require 'spec_helper'
require_relative '../../../../sharding_spec_helper'

require 'delayed/testing'
require_dependency "canvas/apm/inst_jobs/plugin"

Expand Down Expand Up @@ -75,6 +76,7 @@ def enabled
end

describe 'instrumented job invocation' do
specs_require_sharding
let(:sample_job_object) do
stub_const('SampleJob', Class.new do
def perform; end
Expand All @@ -84,15 +86,18 @@ def perform; end
it 'has resource name equal to job name' do
expect(Canvas::Apm::InstJobs::Plugin.tracer).to eq(tracer)
job = Delayed::Job.enqueue(sample_job_object.new, {})
job.account_id = 12345
Delayed::Testing.run_job(job)
expect(span.resource).to eq('SampleJob')
expect(span.tags["inst_jobs.id"] > 0).to be_truthy
expect(span.tags["inst_jobs.queue"]).to eq("canvas_queue")
expect(span.tags["inst_jobs.priority"] > 0).to be_truthy
expect(span.tags["inst_jobs.attempts"]).to eq(0)
expect(span.tags["inst_jobs.strand"]).to be_nil
expect(span.tags["shard"]).to eq(job.shard_id)
expect(span.tags["root_account"]).to eq(job.account_id)
expect(job.shard_id > 0).to be_truthy
expect(span.tags["shard"]).to eq(job.shard_id.to_s)
expect(job.account_id > 0).to be_truthy
expect(span.tags["root_account"]).to eq(job.account_id.to_s)
end
end
end
2 changes: 1 addition & 1 deletion spec/lib/canvas/apm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.

require 'spec_helper'
require_relative '../../sharding_spec_helper'

describe Canvas::Apm do
after(:each) do
Expand Down

0 comments on commit 56da7cc

Please sign in to comment.