From cd5d2ea52a8b388029963e5defafcb4edd1ba159 Mon Sep 17 00:00:00 2001 From: Johnathan Martin Date: Wed, 10 Jan 2024 13:35:57 -0800 Subject: [PATCH 1/3] bump redis in docker compose to currently deployed major version on both prod and stage, running 'redis-server --version' returns 'Redis server v=7.0.8 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=c255d0976966edae' --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index d830eaf6f..b6c4c29b9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,7 +27,7 @@ services: volumes: - postgres-data:/var/lib/postgresql/data redis: - image: redis:3 + image: redis:7 command: redis-server ports: - 6379:6379 From d177945db2fd1e3c58ee82367f2de5167d3e68e9 Mon Sep 17 00:00:00 2001 From: Johnathan Martin Date: Wed, 10 Jan 2024 17:20:06 -0800 Subject: [PATCH 2/3] add okcomputer check for expected RabbitMQ queues suggested in https://github.com/sul-dlss/preservation_catalog/issues/2291 --- config/initializers/okcomputer.rb | 31 +++++++++++++++++++++++++++++++ spec/config/okcomputer_spec.rb | 31 +++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/config/initializers/okcomputer.rb b/config/initializers/okcomputer.rb index 79a37f5a6..e2273e0de 100644 --- a/config/initializers/okcomputer.rb +++ b/config/initializers/okcomputer.rb @@ -68,6 +68,37 @@ def check OkComputer::Registry.register "feature-#{name}-sdr2objects", DirectoryExistsCheck.new(sdrobjects_location, Settings.minimum_subfolder_count) end +# Check that RabbitMQ queues exist +class RabbitQueueExistsCheck < OkComputer::Check + attr_reader :queue_names, :conn + + def initialize(queue_names) + @queue_names = Array(queue_names) + @conn = Bunny.new(hostname: Settings.rabbitmq.hostname, + vhost: Settings.rabbitmq.vhost, + username: Settings.rabbitmq.username, + password: Settings.rabbitmq.password) + super() + end + + def check + conn.start + status = conn.status + missing_queue_names = queue_names.reject { |queue_name| conn.queue_exists?(queue_name) } + if missing_queue_names.empty? + mark_message "'#{queue_names.join(', ')}' exists, connection status: #{status}" + else + mark_message "'#{missing_queue_names.join(', ')}' does not exist" + mark_failure + end + conn.close + rescue StandardError => e + mark_message "Error: '#{e}'" + mark_failure + end +end +OkComputer::Registry.register 'rabbit-queues', RabbitQueueExistsCheck.new('dsa.create-event') + OkComputer::Registry.register 'ruby_version', OkComputer::RubyVersionCheck.new # ------------------------------------------------------------------------------ diff --git a/spec/config/okcomputer_spec.rb b/spec/config/okcomputer_spec.rb index 5a7844fd5..418f3b834 100644 --- a/spec/config/okcomputer_spec.rb +++ b/spec/config/okcomputer_spec.rb @@ -37,4 +37,35 @@ expect(described_class.new('i-do-not-exist')).not_to be_successful end end + + describe RabbitQueueExistsCheck do + let(:bunny_conn) { instance_double(Bunny::Session) } + let(:queue_name1) { 'foo.first_queue' } + let(:queue_name2) { 'foo.second_queue' } + + before do + allow(bunny_conn).to receive_messages(start: bunny_conn, status: :open, close: true) + allow(bunny_conn).to receive(:queue_exists?).with(queue_name1).and_return(queue_exists1) + allow(bunny_conn).to receive(:queue_exists?).with(queue_name2).and_return(queue_exists2) + allow(Bunny).to receive(:new).and_return(bunny_conn) + end + + context 'when the expected queues are present' do + let(:queue_exists1) { true } + let(:queue_exists2) { true } + + it 'succeeds if the expected queue exists' do + expect(described_class.new([queue_name1, queue_name2])).to be_successful + end + end + + context 'when a queue is missing' do + let(:queue_exists1) { true } + let(:queue_exists2) { false } + + it 'succeeds if the expected queue exists' do + expect(described_class.new([queue_name1, queue_name2])).not_to be_successful + end + end + end end From a41ea8774821b1755a32a0bab98876594d41b3c4 Mon Sep 17 00:00:00 2001 From: Johnathan Martin Date: Wed, 10 Jan 2024 17:41:53 -0800 Subject: [PATCH 3/3] freshen PR template * fix reference to renamed infra integration test * add a little whitespace to testing hint, for readability --- .github/pull_request_template.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index fde0733b1..b5679e51b 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -5,7 +5,9 @@ # How was this change tested? 🤨 -⚡ ⚠ If this change has cross service impact, or if it changes code used internally for cloud replication, **_run [integration test preassembly_image_accessioning_spec.rb](https://github.com/sul-dlss/infrastructure-integration-test/blob/main/spec/features/preassembly_image_accessioning_spec.rb) against stage as it tests preservation (including cloud replication)_**, and/or test in stage environment, in addition to specs. The main classes relevant to replication are `ZipmakerJob`, `DeliveryDispatcherJob`, `*DeliveryJob`, `ResultsRecorderJob`, and `DruidVersionZip`; [see here for overview diagram of replication pipeline](https://github.com/sul-dlss/preservation_catalog/wiki/Replication-Flow).⚡ +⚡ ⚠ If this change has cross service impact, or if it changes code used internally for cloud replication, **_run [integration test preassembly_reaccessioning_spec.rb](https://github.com/sul-dlss/infrastructure-integration-test/blob/main/spec/features/preassembly_reaccessioning_spec.rb) against stage, as it tests preservation (including cloud replication)_**, and/or test manually in stage environment, in addition to specs. + +The main classes relevant to replication are `ZipmakerJob`, `DeliveryDispatcherJob`, `*DeliveryJob`, `ResultsRecorderJob`, and `DruidVersionZip`; [see here for overview diagram of replication pipeline](https://github.com/sul-dlss/preservation_catalog/wiki/Replication-Flow).⚡