tddium-old 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
@@ -0,0 +1 @@
1
+ v0.0.1 - Initial Version
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ gem "highline"
6
+ gem "rspec", ">1.2.6", "<2.0.0"
7
+ gem "parallel"
8
+ gem "selenium-client", ">=1.2.18"
9
+ gem "fog", "=0.4.0"
10
+
11
+ # Add dependencies to develop your gem here.
12
+ # Include everything needed to run rake, tests, features, etc.
13
+ group :development do
14
+ gem "shoulda", ">= 0"
15
+ gem "bundler", "~> 1.0.0"
16
+ gem "jeweler", "~> 1.5.1"
17
+ gem "rcov", ">= 0"
18
+ gem "mocha"
19
+ gem "fakefs", ">=0.3.1"
20
+ gem "rails", "=2.3.8"
21
+ end
@@ -0,0 +1,70 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (2.3.8)
5
+ actionpack (= 2.3.8)
6
+ actionpack (2.3.8)
7
+ activesupport (= 2.3.8)
8
+ rack (~> 1.1.0)
9
+ activerecord (2.3.8)
10
+ activesupport (= 2.3.8)
11
+ activeresource (2.3.8)
12
+ activesupport (= 2.3.8)
13
+ activesupport (2.3.8)
14
+ builder (3.0.0)
15
+ excon (0.3.8)
16
+ fakefs (0.3.1)
17
+ fog (0.4.0)
18
+ builder
19
+ excon (>= 0.3.7)
20
+ formatador (>= 0.0.16)
21
+ json
22
+ mime-types
23
+ net-ssh (>= 2.0.23)
24
+ nokogiri (>= 1.4.4)
25
+ ruby-hmac
26
+ formatador (0.0.16)
27
+ git (1.2.5)
28
+ highline (1.6.1)
29
+ jeweler (1.5.2)
30
+ bundler (~> 1.0.0)
31
+ git (>= 1.2.5)
32
+ rake
33
+ json (1.4.6)
34
+ mime-types (1.16)
35
+ mocha (0.9.10)
36
+ rake
37
+ net-ssh (2.0.23)
38
+ nokogiri (1.4.4)
39
+ parallel (0.5.1)
40
+ rack (1.1.0)
41
+ rails (2.3.8)
42
+ actionmailer (= 2.3.8)
43
+ actionpack (= 2.3.8)
44
+ activerecord (= 2.3.8)
45
+ activeresource (= 2.3.8)
46
+ activesupport (= 2.3.8)
47
+ rake (>= 0.8.3)
48
+ rake (0.8.7)
49
+ rcov (0.9.9)
50
+ rspec (1.3.1)
51
+ ruby-hmac (0.4.0)
52
+ selenium-client (1.2.18)
53
+ shoulda (2.11.3)
54
+
55
+ PLATFORMS
56
+ ruby
57
+
58
+ DEPENDENCIES
59
+ bundler (~> 1.0.0)
60
+ fakefs (>= 0.3.1)
61
+ fog (= 0.4.0)
62
+ highline
63
+ jeweler (~> 1.5.1)
64
+ mocha
65
+ parallel
66
+ rails (= 2.3.8)
67
+ rcov
68
+ rspec (> 1.2.6, < 2.0.0)
69
+ selenium-client (>= 1.2.18)
70
+ shoulda
@@ -0,0 +1,2 @@
1
+ Copyright (c) 2010 Jay Moorthi All Rights Reserved.
2
+
@@ -0,0 +1,62 @@
1
+ = tddium
2
+
3
+ tddium takes the pain out of running Selenium testing in cloud.
4
+
5
+ It automatically starts private Amazon EC2 Instances, runs your test,
6
+ collect results, and cleans up the EC2 resources it used so you only pay for
7
+ what you use.
8
+
9
+ == Getting Started
10
+
11
+ 1. Sign up for an EC2 account, by going here:
12
+
13
+ https://aws-portal.amazon.com/gp/aws/developer/registration/index.html
14
+
15
+ Note that if you have a personal Amazon account, you'll want to make a new one
16
+ for Amazon Web Services.
17
+
18
+ The registration process generates a variety of certificates and keys. Please
19
+ keep track of them.
20
+
21
+ 2. Note your AWS Access Key and AWS Secret. You can find them by the following
22
+ steps:
23
+
24
+ - go to the AWS Management Console
25
+ - click on the "Account" link in the upper navigation menu
26
+ - click on "Security Credentials"
27
+ - scroll down to the first section "Access Credentials"
28
+ - the Access Key is a 20-character alphabetic string. The Secret is hidden. Click the 'show' link to reveal it.
29
+
30
+ 3. In the AWS Management Console, create a selenium-grid security group, and
31
+ create rules for:
32
+
33
+ * allow dest port 4444 (Selenium-Grid)
34
+ * allow dest port 5900 (Windows Remote Desktop)
35
+ * allow http
36
+ * allow https
37
+ * allow vnc
38
+ * allow ssh
39
+
40
+ 4. In the AWS Management Console, create a keypair called sg-keypair.
41
+
42
+ 3. Subscribe to tddium:
43
+
44
+ Subscribe your Amazon EC2 account to tddium here:
45
+
46
+ https://aws-portal.amazon.com/gp/aws/user/subscription/index.html?ie=UTF8&offeringCode=FA429DE5
47
+
48
+ 4. Start using tddium:
49
+
50
+ <tt>$ tddium config:init</tt>
51
+
52
+ # Asks you for the AWS Access Key and AWS Secret
53
+
54
+ <tt>$ tddium test:sequential</tt>
55
+
56
+ # Starts an EC2 Instance, sets SELENIUM_RC_HOST to it, and runs **/*_spec.rb in sequence
57
+
58
+ == Copyright
59
+
60
+ Copyright (c) 2010 Jay Moorthi. See LICENSE.txt for
61
+ further details.
62
+
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "tddium-old"
16
+ gem.homepage = "http://www.tddium.com/"
17
+ gem.summary = "tddium Cloud Test Runner"
18
+ gem.description = "tddium gets your rspec+selenium tests into the cloud by running them on your VMs"
19
+ gem.email = "info@tddium.com"
20
+ gem.authors = ["Jay Moorthi"]
21
+ gem.executables = ["tddium-old"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ require 'rcov/rcovtask'
37
+ Rcov::RcovTask.new do |test|
38
+ test.libs << 'test'
39
+ test.pattern = 'test/**/test_*.rb'
40
+ test.verbose = true
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "tddium #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.4.7
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ =begin
4
+ Copyright (c) 2010 tddium.com All Rights Reserved
5
+ =end
6
+
7
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
8
+
9
+ require 'rubygems'
10
+ require 'rake'
11
+
12
+ Rake.application.init('tddium')
13
+
14
+ require 'tddium/taskalias'
15
+
16
+ Rake.application.top_level
@@ -0,0 +1,68 @@
1
+ # Copyright (c) 2010 Sauce Labs Inc
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.
21
+
22
+ ActionController::Base.class_eval do
23
+ puts "Not Patching ActionController" if self.const_defined?("SpecStormLoaded")
24
+ unless self.const_defined?("SpecStormLoaded")
25
+ puts "Patching ActionController::Base"
26
+ SpecStormLoaded = true
27
+
28
+ alias_method :original_url_for, :url_for
29
+
30
+ def url_for(options = {})
31
+ options.merge!( {:db_prefix => ActiveRecord::Base.table_name_prefix} ) unless options.class != Hash
32
+ original_url_for options
33
+ end
34
+
35
+ alias_method :original_process, :process
36
+
37
+ def process(request, response, method = :perform_action, *arguments) #:nodoc:
38
+ raise StandardError.new("db_prefix cannot be nil in SpecStorm mode!") if request.params[:db_prefix].nil?
39
+ ActiveRecord::Base.table_name_prefix = request.params[:db_prefix]
40
+ ActiveRecord::Base.reset_all_table_names
41
+
42
+ original_process(request, response, method, *arguments)
43
+ end
44
+
45
+ alias_method :original_redirect_to, :redirect_to
46
+
47
+ def redirect_to(options = {}, response_status = {}) #:doc:
48
+ raise ActionControllerError.new("Cannot redirect to nil!") if options.nil?
49
+
50
+ case options
51
+ when String
52
+ options += "?db_prefix=#{ActiveRecord::Base.table_name_prefix}" unless options.include? "db_prefix="
53
+ end
54
+
55
+ original_redirect_to( options, response_status )
56
+ end
57
+ end
58
+ end
59
+
60
+ ActionController::UrlRewriter.class_eval do
61
+ alias_method :original_rewrite_path, :rewrite_path
62
+
63
+ def rewrite_path(options)
64
+ options.merge!( {:db_prefix => ActiveRecord::Base.table_name_prefix} ) unless options.class != Hash or options.has_key?(:db_prefix)
65
+
66
+ original_rewrite_path(options)
67
+ end
68
+ end
@@ -0,0 +1,52 @@
1
+ # Copyright (c) 2010 Sauce Labs Inc
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.
21
+
22
+ ActionView::Helpers::UrlHelper.class_eval do
23
+ unless self.const_defined?("SpecStormLoaded")
24
+ puts "Patching ActiveView::Base"
25
+ SpecStormLoaded = true
26
+
27
+ alias_method :original_url_to, :url_for
28
+
29
+ def url_for(options = {})
30
+ # TODO: Regex stuff to only append this when necessary
31
+ case options
32
+ when String
33
+ return "#{original_url_to( options )}?db_prefix=#{ActiveRecord::Base.table_name_prefix}" unless options.include? "db_prefix="
34
+ end
35
+
36
+ original_url_to options
37
+ end
38
+
39
+ alias_method :original_link_to, :link_to
40
+
41
+ def link_to(*args, &block)
42
+ logger.debug "link_to:\t#{args.inspect}"
43
+
44
+ arguments = args.join(",")
45
+ if block_given?
46
+ return eval("original_link_to( #{arguments}")
47
+ end
48
+
49
+ original_link_to *args
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,45 @@
1
+ # Copyright (c) 2010 Sauce Labs Inc
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.
21
+
22
+ ActiveRecord::Base.instance_eval do
23
+ unless self.const_defined?("SpecStormLoaded")
24
+ puts "Patching ActiveRecord::Base"
25
+ SpecStormLoaded = true
26
+
27
+ def prefix_and_reset_all_table_names_to(prefix)
28
+ ActiveRecord::Base.table_name_prefix = prefix
29
+ ActiveRecord::Base.reset_all_table_names
30
+ end
31
+
32
+ def reset_all_table_names
33
+ subclasses.each do |sc|
34
+ sc.reset_table_name
35
+ puts "Reset #{sc}..."
36
+ end
37
+ end
38
+
39
+ def show_all_subclasses
40
+ subclasses.each do |sc|
41
+ puts "#{sc} -> #{sc.table_name}"
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,10 @@
1
+ =begin
2
+ Copyright (c) 2010 tddium.com All Rights Reserved
3
+ =end
4
+
5
+ require 'tddium/ssh'
6
+ require 'tddium/config'
7
+ require 'tddium/reporting'
8
+ require 'tddium/instance'
9
+ require 'tddium/rails'
10
+ require 'tddium/parallel'
@@ -0,0 +1,146 @@
1
+ =begin
2
+ Copyright (c) 2011 tddium.com All Rights Reserved
3
+ =end
4
+
5
+ #
6
+ # tddium support methods
7
+ #
8
+ #
9
+
10
+ require 'rubygems'
11
+ require 'highline/import'
12
+ require 'yaml'
13
+
14
+ ALREADY_CONFIGURED =<<'EOF'
15
+
16
+ tddium has already been initialized.
17
+
18
+ (settings are in %s)
19
+
20
+ Use 'tddium config:reset' to clear configuration, and then run 'tddium config:init' again.
21
+ EOF
22
+
23
+
24
+ def get_config_paths
25
+ paths = []
26
+ if ENV['RAILS_ROOT']
27
+ paths << File.join(ENV['RAILS_ROOT'], '.tddium')
28
+ end
29
+ paths << File.expand_path('~/.tddium')
30
+ paths << '.tddium'
31
+ paths
32
+ end
33
+
34
+ def write_config(config)
35
+ File.open(get_config_paths[0], 'w', 0600) do |f|
36
+ YAML.dump(config, f)
37
+ end
38
+ end
39
+
40
+ def find_config
41
+ get_config_paths.each {|f| return f if File.exists?(f)}
42
+ nil
43
+ end
44
+
45
+ def reset_task
46
+ config_path = find_config
47
+ config = read_config
48
+ if config_path
49
+ puts "Deleting old configuration in #{config_path}:"
50
+ puts config.inspect
51
+ rm config_path, :force => true
52
+ end
53
+ end
54
+
55
+
56
+
57
+ def init_task
58
+ path = find_config
59
+ if path
60
+ puts ALREADY_CONFIGURED % path
61
+ else
62
+ conf = {}
63
+ conf[:aws_key] = ask('Enter AWS Access Key: ')
64
+ conf[:aws_secret] = ask('Enter AWS Secret: ')
65
+ conf[:test_pattern] = ask('Enter filepattern for tests: ') { |q|
66
+ q.default='**/*_spec.rb'
67
+ }
68
+ conf[:key_directory] = ask('Enter directory for secret key(s): ') { |q|
69
+ q.default='spec/secret'
70
+ }
71
+ conf[:key_name] = ask('Enter secret key name (excluding .pem suffix): ') { |q|
72
+ q.default='sg-keypair'
73
+ }
74
+ conf[:result_directory] = ask('Enter directory for result reports: ') { |q|
75
+ q.default='results'
76
+ }
77
+ conf[:server_tag] = ask("(optional) Enter tag=value to give instances: ")
78
+ conf[:ssh_tunnel] = ask("Create ssh tunnel to hub at localhost:4444:") { |q|
79
+ q.default=false
80
+ }
81
+ conf[:require_files] = ask("(optional) Filenames (comma-separated) for spec to require:")
82
+
83
+ write_config conf
84
+ end
85
+ end
86
+
87
+ CONFIG_DEFAULTS = {
88
+ :aws_key => nil,
89
+ :aws_secret => nil,
90
+ :test_pattern => '**/*_test.rb',
91
+ :key_name => nil,
92
+ :key_directory => nil,
93
+ :result_directory => 'results',
94
+ :ssh_tunnel => false,
95
+ :require_files => nil,
96
+ }
97
+
98
+ def read_config
99
+ path = find_config
100
+ file_conf = path ? YAML.load(File.read(path)) : {}
101
+ CONFIG_DEFAULTS.merge(file_conf)
102
+ end
103
+
104
+ # Compute the name of the ssh private key file from configured parameters
105
+ def key_file_name(config)
106
+ if config[:key_name].nil? || config[:key_directory].nil?
107
+ return nil
108
+ end
109
+
110
+ File.join(config[:key_directory], "#{config[:key_name]}.pem")
111
+ end
112
+
113
+ def get_keyfile
114
+ conf = read_config
115
+ key_file = key_file_name(conf)
116
+ if key_file.nil?
117
+ return nil
118
+ elsif !File.exists?(key_file)
119
+ STDERR.puts "No key file #{key_file} present"
120
+ return nil
121
+ elsif (File.stat(key_file).mode & "77".to_i(8) != 0)
122
+ mode =File.stat(key_file).mode
123
+ STDERR.puts "Keyfile has wrong perms: #{mode.to_s}. should be x00"
124
+ return nil
125
+ else
126
+ return key_file
127
+ end
128
+ end
129
+
130
+ def find_test_files(pattern=nil)
131
+ conf = read_config
132
+ pattern ||= conf[:test_pattern]
133
+ Dir[pattern].sort
134
+ end
135
+
136
+ def spec_opts(result_path)
137
+ conf = read_config
138
+ s = []
139
+ s << '--color'
140
+ s << "--require '#{conf[:require_files]}'" if conf[:require_files]
141
+ s << "--require 'rubygems,selenium/rspec/reporting/selenium_test_report_formatter'"
142
+ s << "--format=Selenium::RSpec::SeleniumTestReportFormatter:#{result_path}"
143
+ s << "--format=progress"
144
+ s << ENV['TDDIUM_SPEC_OPTS'] if ENV['TDDIUM_SPEC_OPTS']
145
+ s
146
+ end