Skip to content

Commit

Permalink
Add a performance spec for start up time impact
Browse files Browse the repository at this point in the history
  • Loading branch information
tawan committed Feb 5, 2017
1 parent 6871fb2 commit 7abe07e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source 'https://rubygems.org'

gem 'rails', '~> 5.0', '>= 5.0.0.1'
gem 'sqlite3'
gemspec
gem 'bundler'
gem 'rspec', '~> 3.4'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
thor (0.19.1)
thread_safe (0.3.5)
tzinfo (1.2.2)
Expand All @@ -156,6 +157,7 @@ DEPENDENCIES
rails (~> 5.0, >= 5.0.0.1)
rdoc
rspec (~> 3.4)
sqlite3

BUNDLED WITH
1.11.2
1 change: 1 addition & 0 deletions gemfiles/Gemfile.rails-4.2.x
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source 'https://rubygems.org'

gem 'rails', '~> 4.2'
gem 'sqlite3'
gemspec :path => '../'
gem 'bundler'
gem 'rspec', '~> 3.4'
Expand Down
1 change: 1 addition & 0 deletions gemfiles/Gemfile.rails-5.0.x
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source 'https://rubygems.org'

gem 'rails', '~> 5.0', '>= 5.0.0.1'
gem 'sqlite3'
gemspec :path => '../'
gem 'bundler'
gem 'rspec', '~> 3.4'
Expand Down
8 changes: 7 additions & 1 deletion spec/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,16 @@ def create_random_string(random_string)
end
end

def run_in_rails_app_root_dir(&block)
Dir.chdir("#{root_dir}/spec/integration/rails-app-#{@version}") do
yield
end
end

private

def deploy_to_environment(env)
Dir.chdir("#{root_dir}/spec/integration/rails-app-#{@version}") do
run_in_rails_app_root_dir do
unless system("eb deploy #{env}")
raise "Could not deploy application to environment #{env}"
end
Expand Down
23 changes: 23 additions & 0 deletions spec/integration/preformance_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'spec_helper'
require 'timeout'

RAILS_START_UP_UPPER_BOUNDARY = 10 # in seconds
describe "performance" do
before(:all) do
@rails_app = Helpers::RailsApp.new("#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}")
end

describe "rails start up time" do
it "performs under #{RAILS_START_UP_UPPER_BOUNDARY} seconds" do
begin
Timeout::timeout(RAILS_START_UP_UPPER_BOUNDARY) do
@rails_app.run_in_rails_app_root_dir do
system("bundle exec rails runner \"puts 'hello world!'\" ")
end
end
rescue Timeout::Error
fail "Rails app has not started within #{RAILS_START_UP_UPPER_BOUNDARY} seconds"
end
end
end
end

0 comments on commit 7abe07e

Please sign in to comment.