Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
guille-sage committed Dec 19, 2023
1 parent d3b80f7 commit 5bc4fb0
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 39 deletions.
47 changes: 41 additions & 6 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,49 @@ jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
strategy:
matrix:
ruby: ['2.7', '3.0', '3.2']

services:
eventq_redis:
image: redis:alpine
ports:
- 6379:6379
rabbitmq:
image: rabbitmq:3.6.5
ports:
- 5672:5672
localstack:
# changes to multi region support after this version break tests
image: localstack/localstack:0.12.16
env:
SERVICES: sqs,sns
HOSTNAME: localhost
HOSTNAME_EXTERNAL: localhost
ports:
- "8085:8080"
- "4566:4566"

steps:
- uses: actions/checkout@v4
- name: Set up Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Bundle
run: bundle install
- name: Run tests
run: |
cd script
docker-compose up -d
docker exec testrunner bash -c "cd src && bundle install && bundle exec rspec && exit"
run: "bundle exec rspec"
env:
AWS_ACCESS_KEY_ID: mock_id
AWS_SECRET_ACCESS_KEY: mock_password
AWS_REGION: eu-west-1
AWS_SQS_ENDPOINT: http://localhost:4566
AWS_SNS_ENDPOINT: http://localhost:4566
RABBITMQ_ENDPOINT: localhost
REDIS_ENDPOINT: redis://localhost:6379

- name: Code Coverage
uses: paambaati/codeclimate-action@v2.7.5
Expand Down
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ruby:3.2-alpine3.18

ENV APP_HOME /src
RUN mkdir -p $APP_HOME
WORKDIR $APP_HOME

RUN apk add --update ca-certificates bash && update-ca-certificates && rm -rf /var/cache/apk/*
RUN apk update && apk add --no-cache build-base libressl-dev

RUN set -ex \
&& apk add --no-cache --virtual .gem-builddeps \
ruby-dev build-base


COPY Gemfile $APP_HOME
COPY eventq.gemspec $APP_HOME
COPY EVENTQ_VERSION $APP_HOME

RUN bundle install --no-cache \
&& apk del .gem-builddeps
8 changes: 5 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Specify your gem's dependencies in eventq.gemspec
gemspec


gem 'json', '~> 2'
gem 'redlock', '~> 1'

platforms :ruby do
gem 'oj', '3.6.10'
gem 'openssl', '2.1.2'
gem 'bunny'
gem 'oj', '3.12.3' # 3.13.0 breaks the specs
gem 'openssl'
gem 'rexml'
end
6 changes: 4 additions & 2 deletions script/docker-compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ services:
- rabbitmq
- localstack
volumes:
- ./container_loop.sh:/scripts/container_loop.sh
- ../:/src
- ./script/container_loop.sh:/scripts/container_loop.sh
- ./:/src
environment:
- AWS_ACCESS_KEY_ID=mock_id
- AWS_SECRET_ACCESS_KEY=mock_password
- AWS_REGION=eu-west-1
- AWS_SQS_ENDPOINT=http://localstack:4566
- AWS_SNS_ENDPOINT=http://localstack:4566
- RABBITMQ_ENDPOINT=rabbitmq
- REDIS_ENDPOINT=redis://redis:6379
# env_file:
# - ../.aws.env

Expand Down
5 changes: 2 additions & 3 deletions lib/eventq.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'securerandom'
require 'redlock'
require 'class_kit'
Expand All @@ -22,6 +24,3 @@
require_relative 'eventq/eventq_base/signature_providers'
require_relative 'eventq/eventq_base/exceptions'
require_relative 'eventq/queue_worker'



13 changes: 0 additions & 13 deletions script/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion spec/eventq_aws/integration/aws_queue_worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def add_to_received_list(received_messages)
context 'NonceManager' do
context 'when a message has already been processed' do
before do
EventQ::NonceManager.configure(server: 'redis://redis:6379')
EventQ::NonceManager.configure(server: ENV.fetch('REDIS_ENDPOINT', 'redis://redis:6379'))
end
let(:queue_message) { EventQ::QueueMessage.new }
let(:event_type) { 'queue_worker_event_noncemanager' }
Expand Down
2 changes: 1 addition & 1 deletion spec/eventq_aws/integration/aws_queue_worker_v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def add_to_received_list(received_messages)
context 'NonceManager' do
context 'when a message has already been processed' do
before do
EventQ::NonceManager.configure(server: 'redis://redis:6379')
EventQ::NonceManager.configure(server: ENV.fetch('REDIS_ENDPOINT', 'redis://redis:6379'))
end
let(:queue_message) { EventQ::QueueMessage.new }
let(:event_type) { "queue_worker_event_noncemanager_#{SecureRandom.hex(2)}" }
Expand Down
6 changes: 3 additions & 3 deletions spec/eventq_base/nonce_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

context 'when NonceManager has been configured' do
before do
described_class.configure(server: 'redis://redis:6379')
described_class.configure(server: ENV.fetch('REDIS_ENDPOINT', 'redis://redis:6379'))
end
context 'when a nonce has NOT been used' do
it 'should return true' do
Expand Down Expand Up @@ -77,7 +77,7 @@
let(:nonce) { SecureRandom.uuid }
context 'when NonceManager has been configured' do
before do
described_class.configure(server: 'redis://redis:6379')
described_class.configure(server: ENV.fetch('REDIS_ENDPOINT', 'redis://redis:6379'))
described_class.is_allowed?(nonce)
end
it 'should extend the expiry of the nonce key' do
Expand All @@ -102,7 +102,7 @@
let(:nonce) { SecureRandom.uuid }
context 'when NonceManager has been configured' do
before do
described_class.configure(server: 'redis://redis:6379')
described_class.configure(server: ENV.fetch('REDIS_ENDPOINT', 'redis://redis:6379'))
described_class.is_allowed?(nonce)
end
it 'should extend the expiry of the nonce key' do
Expand Down
2 changes: 1 addition & 1 deletion spec/eventq_rabbitmq/rabbitmq_eventq_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe EventQ::RabbitMq::EventQClient do

let(:client) do
return EventQ::RabbitMq::QueueClient.new({ endpoint: 'rabbitmq' })
return EventQ::RabbitMq::QueueClient.new({ endpoint: ENV.fetch('RABBITMQ_ENDPOINT', 'rabbitmq') })
end

let(:subscription_manager) { EventQ::RabbitMq::SubscriptionManager.new({ client: client }) }
Expand Down
2 changes: 1 addition & 1 deletion spec/eventq_rabbitmq/rabbitmq_queue_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe EventQ::RabbitMq::QueueClient do

let(:client) do
return EventQ::RabbitMq::QueueClient.new({ endpoint: 'rabbitmq' })
return EventQ::RabbitMq::QueueClient.new({ endpoint: ENV.fetch('RABBITMQ_ENDPOINT', 'rabbitmq') })
end

let(:connection) { client.get_connection }
Expand Down
4 changes: 2 additions & 2 deletions spec/eventq_rabbitmq/rabbitmq_queue_worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
RSpec.describe EventQ::RabbitMq::QueueWorker do
let(:queue_worker) { EventQ::QueueWorker.new }

let(:client) { EventQ::RabbitMq::QueueClient.new({ endpoint: 'rabbitmq' }) }
let(:client) { EventQ::RabbitMq::QueueClient.new({ endpoint: ENV.fetch('RABBITMQ_ENDPOINT', 'rabbitmq') }) }

let(:connection) { client.get_connection }

Expand Down Expand Up @@ -109,7 +109,7 @@
let(:queue_message) { EventQ::QueueMessage.new }

before do
EventQ::NonceManager.configure(server: 'redis://redis:6379')
EventQ::NonceManager.configure(server: ENV.fetch('REDIS_ENDPOINT', 'redis://redis:6379'))
end

it 'should NOT process the message more than once' do
Expand Down
4 changes: 2 additions & 2 deletions spec/eventq_rabbitmq/rabbitmq_queue_worker_v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe EventQ::RabbitMq::QueueWorker do
let(:queue_worker) { EventQ::QueueWorker.new }

let(:client) { EventQ::RabbitMq::QueueClient.new({ endpoint: 'rabbitmq' }) }
let(:client) { EventQ::RabbitMq::QueueClient.new({ endpoint: ENV.fetch('RABBITMQ_ENDPOINT', 'rabbitmq') }) }

let(:connection) { client.get_connection }

Expand Down Expand Up @@ -92,7 +92,7 @@
let(:queue_message) { EventQ::QueueMessage.new }

before do
EventQ::NonceManager.configure(server: 'redis://redis:6379')
EventQ::NonceManager.configure(server: ENV.fetch('REDIS_ENDPOINT', 'redis://redis:6379'))
end

it 'should NOT process the message more than once' do
Expand Down
2 changes: 1 addition & 1 deletion spec/eventq_rabbitmq/rabbitmq_status_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe EventQ::RabbitMq::StatusChecker do

let(:client) do
EventQ::RabbitMq::QueueClient.new({ endpoint: 'rabbitmq' })
EventQ::RabbitMq::QueueClient.new({ endpoint: ENV.fetch('RABBITMQ_ENDPOINT', 'rabbitmq') })
end

subject do
Expand Down

0 comments on commit 5bc4fb0

Please sign in to comment.