Skip to content

Commit d85c3e7

Browse files
Merge pull request #1367 from sanger/fixes-for-volume-tracking-emq-integration
Updating to serialize UUIDs properly with raw UUID values
2 parents 290447a + 14993a7 commit d85c3e7

File tree

5 files changed

+33
-31
lines changed

5 files changed

+33
-31
lines changed

app/exchanges/volume_tracking/message_builder.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ def publish_data # rubocop:disable Metrics/MethodLength
2020

2121
aliquot = object
2222
data = { source_type: '', source_barcode: '', sample_name: '',
23-
used_by_type: 'nil', used_by_barcode: '', aliquot_uuid: aliquot.uuid || '' }
23+
used_by_type: 'nil', used_by_barcode: '',
24+
aliquot_uuid: aliquot.uuid,
25+
message_uuid: SecureRandom.uuid }
2426

2527
case aliquot.source_type
2628
when 'Pacbio::Library'

config/pipelines/pacbio.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ default: &default
316316
type: :constant
317317
value: Time.current
318318
messageUuid:
319-
type: :constant
320-
value: SecureRandom.uuid.to_s
319+
type: :self
320+
value: publish_data&.message_uuid
321321
recordedAt:
322322
type: :model
323323
value: created_at

spec/exchanges/volume_tracking/message_builder_spec.rb

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
let(:message_builder) { described_class.new(object: aliquot, configuration:) }
1616

1717
it 'produces the message in the correct format' do
18-
expect(message_builder.publish_data).to eq({
19-
source_type: 'library',
20-
source_barcode: pacbio_library.tube.barcode,
21-
sample_name: pacbio_library.sample_name,
22-
used_by_type: 'nil',
23-
used_by_barcode: '',
24-
aliquot_uuid: aliquot.uuid
25-
})
18+
expect(message_builder.publish_data).to include({
19+
source_type: 'library',
20+
source_barcode: pacbio_library.tube.barcode,
21+
sample_name: pacbio_library.sample_name,
22+
used_by_type: 'nil',
23+
used_by_barcode: '',
24+
aliquot_uuid: aliquot.uuid
25+
})
2626
end
2727
end
2828

@@ -31,14 +31,14 @@
3131
let(:message_builder) { described_class.new(object: aliquot, configuration:) }
3232

3333
it 'produces the message in the correct format' do
34-
expect(message_builder.publish_data).to eq({
35-
source_type: 'library',
36-
source_barcode: pacbio_library.tube.barcode,
37-
sample_name: pacbio_library.sample_name,
38-
used_by_type: 'pool',
39-
used_by_barcode: pacbio_pool.tube.barcode,
40-
aliquot_uuid: aliquot.uuid
41-
})
34+
expect(message_builder.publish_data).to include({
35+
source_type: 'library',
36+
source_barcode: pacbio_library.tube.barcode,
37+
sample_name: pacbio_library.sample_name,
38+
used_by_type: 'pool',
39+
used_by_barcode: pacbio_pool.tube.barcode,
40+
aliquot_uuid: aliquot.uuid
41+
})
4242
end
4343
end
4444

@@ -47,14 +47,14 @@
4747
let(:message_builder) { described_class.new(object: aliquot, configuration:) }
4848

4949
it 'produces the message in the correct format' do
50-
expect(message_builder.publish_data).to eq({
51-
source_type: 'library',
52-
source_barcode: pacbio_library.tube.barcode,
53-
sample_name: pacbio_library.sample_name,
54-
used_by_type: 'well',
55-
used_by_barcode: "#{pacbio_well.plate.sequencing_kit_box_barcode}:#{pacbio_well.plate.plate_number}:#{pacbio_well.position}",
56-
aliquot_uuid: aliquot.uuid
57-
})
50+
expect(message_builder.publish_data).to include({
51+
source_type: 'library',
52+
source_barcode: pacbio_library.tube.barcode,
53+
sample_name: pacbio_library.sample_name,
54+
used_by_type: 'well',
55+
used_by_barcode: "#{pacbio_well.plate.sequencing_kit_box_barcode}:#{pacbio_well.plate.plate_number}:#{pacbio_well.position}",
56+
aliquot_uuid: aliquot.uuid
57+
})
5858
end
5959
end
6060
end

spec/messages/emq/encoder_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
RSpec.describe Emq::Encoder do
99
let(:pacbio_library) { create(:pacbio_library) }
1010
let(:pacbio_pool) { create(:pacbio_pool) }
11-
let(:aliquot) { build(:aliquot, source: pacbio_library, used_by: pacbio_pool, created_at: Time.zone.now) }
11+
let(:aliquot) { build(:aliquot, uuid: SecureRandom.uuid, source: pacbio_library, used_by: pacbio_pool, created_at: Time.zone.now) }
1212
let(:cache_file_path) { "data/avro_schema_cache/#{schema_subject}_v#{schema_version}.avsc" }
1313
let(:schema_key) { 'volume_tracking' }
1414
let(:schema_subject) { 'create-aliquot-in-mlwh' }

spec/messages/emq/publishing_job_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
RSpec.describe Emq::PublishingJob do
88
let(:pacbio_library) { create(:pacbio_library) }
99
let(:pacbio_pool) { create(:pacbio_pool) }
10-
let(:aliquot) { build(:aliquot, source: pacbio_library, used_by: pacbio_pool, created_at: Time.zone.now) }
10+
let(:aliquot) { build(:aliquot, uuid: SecureRandom.uuid, source: pacbio_library, used_by: pacbio_pool, created_at: Time.zone.now) }
1111

1212
let(:publishing_job) { described_class.new }
1313
let(:emq_sender_mock) { instance_double(Emq::Sender) }
@@ -73,13 +73,13 @@
7373

7474
it 'can publish multiple messages' do
7575
expect(emq_sender_mock).to receive(:send_message).twice
76-
aliquot2 = build(:aliquot, source: pacbio_library, used_by: pacbio_pool, created_at: Time.zone.now)
76+
aliquot2 = build(:aliquot, uuid: SecureRandom.uuid, source: pacbio_library, used_by: pacbio_pool, created_at: Time.zone.now)
7777
publishing_job.publish([aliquot, aliquot2], Pipelines.pacbio, 'volume_tracking')
7878
end
7979

8080
it 'does not publish messages when schema key is missing in config' do
8181
expect(emq_sender_mock).not_to receive(:send_message)
82-
aliquot2 = build(:aliquot, source: pacbio_library, used_by: pacbio_pool, created_at: Time.zone.now)
82+
aliquot2 = build(:aliquot, uuid: SecureRandom.uuid, source: pacbio_library, used_by: pacbio_pool, created_at: Time.zone.now)
8383
publishing_job.publish([aliquot, aliquot2], Pipelines.pacbio, 'test')
8484
end
8585

0 commit comments

Comments
 (0)