dummy_performance_tests 0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ ## 0.9 (August 10, 2010)
2
+
3
+ Features:
4
+ - generating performance tests for Rails 3 applications by using dummy\_data and dummy\_routes (functionality split up from old project)
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Gonçalo Silva
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,43 @@
1
+ # Dummy performance tests
2
+
3
+ "Dummy performance tests" uses the routes generated by dummy\_routes[http://github.com/goncalossilva/dummy_routes] to generate performance tests for your Rails 3 application.
4
+
5
+ ## Description
6
+
7
+ "Dummy performance tests" generates performance tests for your Rails applications. It depends on the test routes generated by dummy\_routes[http://github.com/goncalossilva/dummy_routes]
8
+
9
+ ## Installation
10
+
11
+ $ gem install dummy\_performance\_tests
12
+
13
+ ## Usage
14
+
15
+ Add the following to the Gemfile of your Rails 3 application:
16
+ gem "dummy_performance_tests"
17
+
18
+ Now you have access to the generator:
19
+ rails generate dummy:performance_tests
20
+
21
+ You need to tell it which directory was used when generating dummy routes (default: test/dummy):
22
+ rails generate dummy:performance_tests --output-folder test/awesome_dummy
23
+
24
+ The files will be placed under _output-folder_/performance.
25
+
26
+ Feel free to mix all of these options.
27
+
28
+ The performance tests are stored in _test/dummy/performance_ (by default) while a rake file is placed in _lib/tasks/dummy\_performance.rake_. It allows you to run the previously generated tests:
29
+ rake dummy:performance:test:all
30
+
31
+ The dummy data is copied from the development database into the database you specify (test, by default). The following would copy your development database to the "dummy" database for each test:
32
+ RAILS_ENV="dummy" rake dummy:performance:test:all
33
+
34
+ Don't forget to import the data generated by dummy\_data into your development database before running the tests, otherwise they _will_ fail.
35
+
36
+ Results are stored in _test/dummy/results_ (by default). Two distinct printers are used:
37
+ - GraphYamlPrinter for automated processing
38
+ - CallStackPrinter for human processing
39
+
40
+ For these printers to be used correctly, put this in your Gemfile (the official mirror of ruby-prof is currently lacking the graph yaml printer):
41
+ gem "ruby-prof", :git => "http://github.com/wycats/ruby-prof"
42
+
43
+ Copyright (c) 2010 Gonçalo Silva
@@ -0,0 +1,3 @@
1
+ require "rubygems"
2
+ require "dummy_performance_tests"
3
+ require "generators/performance/performance_tests_generator"
@@ -0,0 +1,45 @@
1
+ module Dummy
2
+ module Generators
3
+ class PerformanceTestsGenerator < Rails::Generators::Base
4
+ include Dummy::Generators::Common
5
+
6
+ def self.source_root
7
+ @source_root ||= File.expand_path("../templates", __FILE__)
8
+ end
9
+
10
+ class_option :output_folder, :type => :string, :default => "test/dummy",
11
+ :desc => "Dummy output folder, performance/ will be used when storing the resulting performance tests."
12
+
13
+ def install_performance_tests
14
+ check_dummyfile
15
+ generate_and_write_performance_tests
16
+ copy_rake_file
17
+ end
18
+
19
+ private
20
+ def check_dummyfile
21
+ if not File.exists? "#{options.output_folder}/Dummyfile"
22
+ raise MissingDummyfile, "Could not find the Dummyfile. Did you forget to generate dummy data/routes or specified a different directory?"
23
+ end
24
+
25
+ end
26
+
27
+ def generate_and_write_performance_tests
28
+ template "test_helper.rb", "#{options.output_folder}/performance/test_helper.rb"
29
+
30
+ Dir["#{options.output_folder}/routes/*.yml"].each do |file|
31
+ @routes = YAML.load_file file
32
+ @model_name = File.basename(file).chomp(File.extname(file))
33
+
34
+ template "dummy_performance_test.rb",
35
+ "#{options.output_folder}/performance/#{@model_name}_performance_test.rb"
36
+ end
37
+ end
38
+
39
+ def copy_rake_file
40
+ template "dummy_performance.rake", "lib/tasks/dummy_performance.rake"
41
+ end
42
+ end
43
+ end
44
+ end
45
+
@@ -0,0 +1,12 @@
1
+ namespace :dummy do
2
+ namespace :performance do
3
+ namespace :test do
4
+ desc "Run all dummy performance tests"
5
+ task :all do
6
+ Dir["<%= options.output_folder %>/performance/*_test.rb"].each do |test_path|
7
+ system "ruby #{test_path}"
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ require File.expand_path('../test_helper', __FILE__)
2
+ require 'rails/performance_test_help'
3
+
4
+ class <%= @model_name.camelcase %>Test < ActionDispatch::PerformanceTest
5
+ <% @routes.each do |request, data| %>
6
+ def test_<%= request %>
7
+ <%= data["type"] %>_via_redirect "<%= data['url'] %>"<%= (", " + data["params"].to_s) if data["params"] %>
8
+ end
9
+ <% end %>
10
+ end
@@ -0,0 +1,68 @@
1
+ ENV["RAILS_ENV"] ||= "test"
2
+ require File.expand_path('../../../../config/environment', __FILE__)
3
+
4
+ require 'test/unit'
5
+ require 'active_support/core_ext/kernel/requires'
6
+ require 'active_support/test_case'
7
+ require 'active_support/testing/performance'
8
+ require 'action_dispatch/testing/integration'
9
+
10
+ # most of the code below came from rails/test_helper,
11
+ # it can't be used directly since the fixture's path is hard coded
12
+ warn "Your Rails environment is not running in test mode!" unless Rails.env.test?
13
+
14
+ if defined?(ActiveRecord)
15
+ require 'active_record/test_case'
16
+
17
+ class ActiveSupport::TestCase
18
+ include ActiveRecord::TestFixtures
19
+ self.fixture_path = File.expand_path('../../data', __FILE__)
20
+
21
+ fixtures :all
22
+ end
23
+
24
+ def create_fixtures(*table_names, &block)
25
+ Fixtures.create_fixtures(ActiveSupport::TestCase.fixture_path, table_names, {}, &block)
26
+ end
27
+ end
28
+
29
+ class ActionDispatch::IntegrationTest
30
+ setup do
31
+ @routes = Rails.application.routes
32
+ end
33
+ end
34
+
35
+ module ActiveSupport
36
+ module Testing
37
+ module Performance
38
+ DEFAULTS =
39
+ { :benchmark => false,
40
+ :runs => 1,
41
+ :min_percent => 0.001,
42
+ :metrics => [:process_time], # TODO: add :memory when ruby-prof doesn't generally fail
43
+ :formats => [:graph_yaml, :call_stack],
44
+ :output => "<%= options.output_folder %>/results/" }.freeze
45
+
46
+ class Profiler < Performer
47
+ protected
48
+
49
+ def output_filename(printer_class)
50
+ suffix =
51
+ case printer_class.name.demodulize
52
+ when 'FlatPrinter'; 'flat.txt'
53
+ when 'FlatPrinterWithLineNumbers'; 'flat_line_numbers.txt'
54
+ when 'GraphPrinter'; 'graph.txt'
55
+ when 'GraphHtmlPrinter'; 'graph.html'
56
+ when 'GraphYamlPrinter'; 'graph.yml'
57
+ when 'CallTreePrinter'; 'tree.txt'
58
+ when 'CallStackPrinter'; 'stack.html'
59
+ when 'DotPrinter'; 'graph.dot'
60
+ else printer_class.name.sub(/Printer$/, '').underscore
61
+ end
62
+
63
+ "#{super()}_#{suffix}"
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dummy_performance_tests
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 9
8
+ version: "0.9"
9
+ platform: ruby
10
+ authors:
11
+ - "Gon\xC3\xA7alo Silva"
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+
16
+ date: 2010-08-11 00:00:00 +01:00
17
+ default_executable:
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
20
+ name: dummy_data
21
+ prerelease: false
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 9
30
+ version: "0.9"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: dummy_routes
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ - 9
44
+ version: "0.9"
45
+ type: :runtime
46
+ version_requirements: *id002
47
+ - !ruby/object:Gem::Dependency
48
+ name: rails
49
+ prerelease: false
50
+ requirement: &id003 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 3
57
+ - 0
58
+ - 0
59
+ - beta
60
+ version: 3.0.0.beta
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ description: Generates dummy performance tests for Rails 3 applications by using the data generated by dummy_data and dummy_routes
64
+ email:
65
+ - goncalossilva@gmail.com
66
+ executables: []
67
+
68
+ extensions: []
69
+
70
+ extra_rdoc_files: []
71
+
72
+ files:
73
+ - lib/dummy_performance_tests.rb
74
+ - lib/generators/performance/performance_tests_generator.rb
75
+ - lib/generators/performance/templates/dummy_performance_test.rb
76
+ - lib/generators/performance/templates/test_helper.rb
77
+ - lib/generators/performance/templates/dummy_performance.rake
78
+ - LICENSE
79
+ - README.md
80
+ - CHANGELOG.md
81
+ has_rdoc: true
82
+ homepage: http://github.com/goncalossilva/dummy_routes
83
+ licenses: []
84
+
85
+ post_install_message:
86
+ rdoc_options: []
87
+
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ segments:
96
+ - 0
97
+ version: "0"
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ segments:
104
+ - 1
105
+ - 3
106
+ - 7
107
+ version: 1.3.7
108
+ requirements: []
109
+
110
+ rubyforge_project: dummy_performance_tests
111
+ rubygems_version: 1.3.7
112
+ signing_key:
113
+ specification_version: 3
114
+ summary: Generates dummy performance tests for Rails 3 applications
115
+ test_files: []
116
+