MSFT Sync: use global_id for strand

I'm not 100% sure it makes a difference but this is safer.

Test plan:
- enqueue a syncer job (group.syncer_job.run_later)
- check that the job's strand has the global id

Change-Id: I6e55450d7cf707d50c5cde1a98fa83186a614723
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/264207
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Mysti Lilla <mysti@instructure.com>
QA-Review: Mysti Lilla <mysti@instructure.com>
Product-Review: Evan Battaglia <ebattaglia@instructure.com>
This commit is contained in:
Evan Battaglia 2021-05-04 18:54:16 -04:00
parent b0a2ee473a
commit fb1af81639
2 changed files with 14 additions and 2 deletions

View File

@ -63,6 +63,7 @@ module MicrosoftSync
STATSD_PREFIX = 'microsoft_sync.smj'
# job_state_record is assumed to be a model with the following used here:
# - global_id
# - job_state
# - workflow_state
# -> update_unless_deleted() -- atomically updates attributes if workflow_state != 'deleted'
@ -267,7 +268,7 @@ module MicrosoftSync
end
def strand
@strand ||= "#{self.class.name}:#{job_state_record.class.name}:#{job_state_record.id}"
@strand ||= "#{self.class.name}:#{job_state_record.class.name}:#{job_state_record.global_id}"
end
def run_with_delay(step=nil, delay_amount=nil, synchronous: false)

View File

@ -129,7 +129,9 @@ module MicrosoftSync
let(:state_record) { MicrosoftSync::Group.create(course: course_model) }
let(:steps_object) { StateMachineJobTestSteps1.new }
let(:strand) { "MicrosoftSync::StateMachineJobTest:MicrosoftSync::Group:#{state_record.id}" }
let(:strand) do
"MicrosoftSync::StateMachineJobTest:MicrosoftSync::Group:#{state_record.global_id}"
end
around(:each) { |example| Timecop.freeze { example.run } }
@ -155,6 +157,15 @@ module MicrosoftSync
[:delay_run, [{strand: strand, run_at: nil}], [nil]],
])
end
# On Jenkins, global and local IDs seems to be the same, so test this explicitly:
it 'uses the global id in the strand name' do
expect(state_record).to receive(:global_id).and_return 987650000000012345
subject.send(:run_later)
expect(steps_object.steps_run[0][1][0][:strand]).to eq(
"MicrosoftSync::StateMachineJobTest:MicrosoftSync::Group:987650000000012345"
)
end
end
describe '#enqueue_future_sync' do