Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Add tests for app_type in integrations #616

Merged
merged 27 commits into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7bd1d5e
app_type testing: Added e2e app_type tests to existing features
Cawllec Feb 4, 2019
5f99786
Fixtures: Add Mailman fixture
Cawllec Feb 4, 2019
824139e
Fixtures: Add Rack fixture
Cawllec Feb 8, 2019
721a36a
Fixtures: Added Rake fixture
Cawllec Feb 8, 2019
4ecc868
Fixtures: Add Que fixture
Cawllec Feb 13, 2019
e17cfe4
Fixtures: Use existing Rack fixtures
Cawllec Feb 14, 2019
0100300
Fixtures: Ensure environment variables are correct
Cawllec Feb 14, 2019
8f5532f
Fixutres: Clean-up unneccessary args
Cawllec Feb 14, 2019
c2c287a
Fixtures: Update mailman fixture
Cawllec Feb 14, 2019
5940aeb
Rename email files
imjoehaines Jul 27, 2020
004dca0
Fix Que feature
imjoehaines Jul 27, 2020
7dff63e
Update Rack tests to match new style
imjoehaines Jul 28, 2020
7d67403
Update Rake tests
imjoehaines Jul 28, 2020
820b36d
Give stages individual icons
imjoehaines Jul 28, 2020
2604a31
Change block stage into a wait stage
imjoehaines Jul 28, 2020
94fe53b
Add new tests to Buildkite
imjoehaines Jul 28, 2020
9625b54
EOF
imjoehaines Jul 28, 2020
ef1c9b8
Add app_type routes to rails 6 fixture
imjoehaines Jul 28, 2020
48cb227
Split out tests into their own concurrency groups
imjoehaines Jul 28, 2020
abb9b68
Merge concurrency groups to avoid too many builds
imjoehaines Jul 28, 2020
e1a8d76
Fix wrong concurrency group
imjoehaines Jul 28, 2020
36bb2c1
Merge slow maze runner test concurrency groups
imjoehaines Jul 28, 2020
04e9a55
Add all supported Ruby versions to new tests
imjoehaines Jul 28, 2020
47a4150
Add comment to explain why we ignore Gemfile.lock
imjoehaines Jul 28, 2020
a7b67fe
Remove fixtures that aren't used
imjoehaines Jul 28, 2020
82b18b7
Fix code style issue
imjoehaines Jul 28, 2020
f9d2716
Remove .ruby-version file
imjoehaines Jul 28, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
564 changes: 508 additions & 56 deletions .buildkite/pipeline.yml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
NETWORK_NAME: "${BUILDKITE_JOB_ID:-ruby-maze-runner}-${RUBY_TEST_VERSION:-local}"
BUILDKITE_JOB_ID:
RAILS_VERSION:
RACK_VERSION:
SIDEKIQ_VERSION:
RUBY_TEST_VERSION:
VERBOSE:
Expand Down Expand Up @@ -43,4 +44,4 @@ services:

networks:
default:
name: ${BUILDKITE_JOB_ID:-ruby-maze-runner}-${RUBY_TEST_VERSION:-local}
name: ${BUILDKITE_JOB_ID:-ruby-maze-runner}-${RUBY_TEST_VERSION:-local}
2 changes: 2 additions & 0 deletions features/delayed_job.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Scenario: An unhandled RuntimeError sends a report with arguments
And the event "context" equals "TestModel.fail_with_args"
And the event "severityReason.type" equals "unhandledExceptionMiddleware"
And the event "severityReason.attributes.framework" equals "DelayedJob"
And the event "app.type" equals "delayed_job"
And the exception "errorClass" equals "RuntimeError"
And the event "metaData.job.class" equals "Delayed::Backend::ActiveRecord::Job"
And the event "metaData.job.id" is not null
Expand All @@ -27,6 +28,7 @@ Scenario: A handled exception sends a report
And the event "severity" equals "warning"
And the event "context" equals "TestModel.notify_with_args"
And the event "severityReason.type" equals "handledException"
And the event "app.type" equals "delayed_job"
And the exception "errorClass" equals "RuntimeError"
And the event "metaData.job.class" equals "Delayed::Backend::ActiveRecord::Job"
And the event "metaData.job.id" is not null
Expand Down
58 changes: 36 additions & 22 deletions features/fixtures/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ services:
redis:
image: redis

postgres:
image: postgres
environment:
- POSTGRES_PASSWORD=test_password

mongo:
image: mongo

Expand Down Expand Up @@ -78,7 +83,8 @@ services:
args:
- RUBY_TEST_VERSION
environment:
- endpoint
- BUGSNAG_API_KEY
- BUGSNAG_ENDPOINT
restart: "no"

rack2:
Expand All @@ -87,7 +93,8 @@ services:
args:
- RUBY_TEST_VERSION
environment:
- endpoint
- BUGSNAG_API_KEY
- BUGSNAG_ENDPOINT
restart: "no"

rails3:
Expand Down Expand Up @@ -236,17 +243,6 @@ services:
aliases:
- rails6

resque:
build:
context: resque
args:
- RUBY_TEST_VERSION
depends_on:
- redis
environment:
- endpoint
restart: "no"

sidekiq:
build:
context: sidekiq
Expand Down Expand Up @@ -280,23 +276,41 @@ services:
- CALLBACK_INITIATOR
restart: "no"

sinatra1:
mailman:
build:
context: sinatra1
context: mailman
args:
- RUBY_TEST_VERSION
- RUBY_VERSION
- APP_PATH
environment:
- endpoint
- BUGSNAG_API_KEY
- BUGSNAG_ENDPOINT
- TARGET_EMAIL
ports:
- "6245:6245"
restart: "no"

sinatra2:
rake:
build:
context: sinatra2
context: rake
args:
- RUBY_TEST_VERSION
- RUBY_VERSION
environment:
- endpoint
restart: "no"
- BUGSNAG_API_KEY
- BUGSNAG_ENDPOINT
restart: 'no'

que:
build:
context: que
args:
- RUBY_VERSION
depends_on:
- postgres
environment:
- BUGSNAG_API_KEY
- BUGSNAG_ENDPOINT
restart: 'no'

networks:
default:
Expand Down
4 changes: 4 additions & 0 deletions features/fixtures/mailman/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore the lock file so that we always use an up to date version. This won't
# exist unless the fixtures are run manually anyway.
Gemfile.lock
payloads/
16 changes: 16 additions & 0 deletions features/fixtures/mailman/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ARG RUBY_VERSION
FROM ruby:$RUBY_VERSION

WORKDIR /bugsnag
COPY temp-bugsnag-lib ./

ARG APP_PATH

WORKDIR $APP_PATH

COPY app/Gemfile .
RUN bundle install

COPY app/ .

CMD ["./run.sh"]
10 changes: 10 additions & 0 deletions features/fixtures/mailman/app/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source 'https://rubygems.org'

gem 'bugsnag', path: '/bugsnag'
gem 'mailman'
gem 'hitimes', '~> 1.2.6'
gem 'i18n', '~> 0.9.5'
gem 'rb-inotify', '0.9.8'
gem 'maildir', '~> 2.1.0'
gem 'activesupport', '~> 3.2'
gem 'rack', '~> 1.6.11'
25 changes: 25 additions & 0 deletions features/fixtures/mailman/app/app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'mailman'
require 'bugsnag'

Bugsnag.configure do |conf|
puts "Configuring `api_key` to #{ENV['BUGSNAG_API_KEY']}"
conf.api_key = ENV['BUGSNAG_API_KEY']
puts "Configuring `endpoint` to #{ENV['BUGSNAG_ENDPOINT']}"
conf.endpoint = ENV['BUGSNAG_ENDPOINT']
end

Mailman.config.ignore_stdin = false

Mailman::Application.run do
subject "Unhandled" do
raise RuntimeError.new("Unhandled exception")
end

subject "Handled" do
begin
raise RuntimeError.new("Handled exception")
rescue => exception
Bugsnag.notify(exception)
end
end
end
19 changes: 19 additions & 0 deletions features/fixtures/mailman/app/emails/handled_error.eml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
MIME-Version: 1.0
Date: Mon, 4 Feb 2019 17:54:01 +0000
Message-ID: <CABpr-1gRk_ueV0LBvFVdeWPG5Tt4feVvB14iMB_FTfKgKrwt-w@mail.gmail.com>
Subject: Handled
From: Test <Test@maze-runner.mail>
To: "Test@maze-runner.mail" <Test@maze-runner.mail>
Content-Type: multipart/alternative; boundary="0000000000008ead860581152db1"

--0000000000008ead860581152db1
Content-Type: text/plain; charset="UTF-8"

test

--0000000000008ead860581152db1
Content-Type: text/html; charset="UTF-8"

<div dir="ltr">test</div>

--0000000000008ead860581152db1--
19 changes: 19 additions & 0 deletions features/fixtures/mailman/app/emails/unhandled_error.eml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
MIME-Version: 1.0
Date: Mon, 4 Feb 2019 17:54:01 +0000
Message-ID: <CABpr-1gRk_ueV0LBvFVdeWPG5Tt4feVvB14iMB_FTfKgKrwt-w@mail.gmail.com>
Subject: Unhandled
From: Test <Test@maze-runner.mail>
To: "Test@maze-runner.mail" <Test@maze-runner.mail>
Content-Type: multipart/alternative; boundary="0000000000008ead860581152db1"

--0000000000008ead860581152db1
Content-Type: text/plain; charset="UTF-8"

test

--0000000000008ead860581152db1
Content-Type: text/html; charset="UTF-8"

<div dir="ltr">test</div>

--0000000000008ead860581152db1--
2 changes: 2 additions & 0 deletions features/fixtures/mailman/app/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
cat $TARGET_EMAIL | bundle exec ruby app.rb
4 changes: 3 additions & 1 deletion features/fixtures/plain/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Ignore the lock file so that we always use an up to date version. This won't
# exist unless the fixtures are run manually anyway.
Gemfile.lock
reportExamples
reportExamples
3 changes: 3 additions & 0 deletions features/fixtures/que/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore the lock file so that we always use an up to date version. This won't
# exist unless the fixtures are run manually anyway.
app/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG RUBY_TEST_VERSION
FROM ruby:$RUBY_TEST_VERSION
ARG RUBY_VERSION
FROM ruby:$RUBY_VERSION

WORKDIR /bugsnag
COPY temp-bugsnag-lib ./
Expand All @@ -8,6 +8,4 @@ WORKDIR /usr/src/app
COPY app/Gemfile /usr/src/app/
RUN bundle install

COPY . /usr/src/app

CMD ["ruby", "app.rb"]
COPY app/ /usr/src/app
9 changes: 9 additions & 0 deletions features/fixtures/que/app/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source "https://rubygems.org"

gem "bugsnag", path: "/bugsnag"

gem "que", "~> 0.14.3"

gem "pg", RUBY_VERSION < "2.2.0" ? "0.21.0" : "> 0.21.0"

gem "activerecord", RUBY_VERSION < "2.2.0" ? "4.2.11" : "> 4.2.11"
57 changes: 57 additions & 0 deletions features/fixtures/que/app/app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
require 'pg'
require 'que'
require 'bugsnag'
require 'active_record'

Bugsnag.configure do |config|
puts "Configuring `api_key` to #{ENV['BUGSNAG_API_KEY']}"
config.api_key = ENV['BUGSNAG_API_KEY']
puts "Configuring `endpoint` to #{ENV['BUGSNAG_ENDPOINT']}"
config.endpoint = ENV['BUGSNAG_ENDPOINT']
end

ActiveRecord::Base.establish_connection(
adapter: 'postgresql',
database: 'postgres',
username: 'postgres',
password: 'test_password',
host: 'postgres'
)

Que.connection = ActiveRecord
Que.migrate!(version: 3)

# Workaround a bug in que/pg
# see https://github.com/que-rb/que/issues/247
Que::Adapters::Base::CAST_PROCS[1184] = lambda do |value|
case value
when Time then value
when String then Time.parse(value)
else raise "Unexpected time class: #{value.class} (#{value.inspect})"
end
end

class UnhandledJob < Que::Job
def run
raise RuntimeError.new("Unhandled error")
end

def handle_error(error)
destroy
end
end

class HandledJob < Que::Job
def run
raise RuntimeError.new("Handled error")
rescue => exception
Bugsnag.notify(exception)
end
end

case ARGV[0]
when "unhandled"
UnhandledJob.enqueue
when "handled"
HandledJob.enqueue
end
4 changes: 3 additions & 1 deletion features/fixtures/rack1/.dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Gemfile.lock
# Ignore the lock file so that we always use an up to date version. This won't
# exist unless the fixtures are run manually anyway.
app/Gemfile.lock
2 changes: 1 addition & 1 deletion features/fixtures/rack1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ RUN bundle install

COPY app/ /usr/src/app

CMD ["ruby", "app.rb"]
CMD ["bundle", "exec", "ruby", "app.rb"]
8 changes: 0 additions & 8 deletions features/fixtures/rack1/app.rb

This file was deleted.

File renamed without changes.
31 changes: 31 additions & 0 deletions features/fixtures/rack1/app/app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require 'bugsnag'
require 'rack'

Bugsnag.configure do |config|
puts "Configuring `api_key` to #{ENV['BUGSNAG_API_KEY']}"
config.api_key = ENV['BUGSNAG_API_KEY']
puts "Configuring `endpoint` to #{ENV['BUGSNAG_ENDPOINT']}"
config.endpoint = ENV['BUGSNAG_ENDPOINT']
end

class BugsnagTests
def call(env)
req = Rack::Request.new(env)

case req.env['REQUEST_PATH']
when '/unhandled'
raise 'Unhandled error'
when '/handled'
begin
raise 'Handled error'
rescue StandardError => e
Bugsnag.notify(e)
end
end

res = Rack::Response.new
res.finish
end
end

Rack::Server.start(app: Bugsnag::Rack.new(BugsnagTests.new), Host: '0.0.0.0', Port: 3000)
4 changes: 3 additions & 1 deletion features/fixtures/rack2/.dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Gemfile.lock
# Ignore the lock file so that we always use an up to date version. This won't
# exist unless the fixtures are run manually anyway.
app/Gemfile.lock
2 changes: 1 addition & 1 deletion features/fixtures/rack2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ RUN bundle install

COPY app/ /usr/src/app

CMD ["ruby", "app.rb"]
CMD ["bundle", "exec", "ruby", "app.rb"]
Loading