test-kitchen 1.0.0.beta.3 → 1.0.0.beta.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e92b944518afe8ad9023cf97a51f14b427b28a0
4
- data.tar.gz: e4f216d248e9e467eaa19b6c2049cb2d36cfc0f8
3
+ metadata.gz: c66b46e1a915624ed333e89ef6e7c829db84cfd1
4
+ data.tar.gz: 839dca4f7400f2dc66d4e5540684913cf586510e
5
5
  SHA512:
6
- metadata.gz: 368dd8fbff5b816cc4622533809dd0992a3074818c93d0881312a1b988d2e3bb8786085ef3b82f6f8afd9cdd036279030c085e7cee2b8fd27dace7754e4b436b
7
- data.tar.gz: 78bc12ab69f016079a311da68c6122144dcd8c94849a7b2f4c8cc22155bc5fd484403fbfef057536eccdf9450ae6d892b2ce2d061ce6c5625525b4087c5db3d8
6
+ metadata.gz: 87dfa48955478b2a69137244a9bef11763662af13ceae16218499ee95da0b6971cbeedd441486d1d88d74665562b09b81077e89113788b0e293c4ce09c9ece01
7
+ data.tar.gz: e60dbac3c1567c35eca1d819210d3298d564ce33cab87da49ff5a2a1a45d4bc0130c713a71cebdcf651db09b19a2b74088d20da9032c9864e809753a71c03464
data/.gitignore CHANGED
@@ -18,3 +18,4 @@ tmp
18
18
  .rvmrc
19
19
  .rbenv-version
20
20
  .ruby-version
21
+ .project
data/.travis.yml CHANGED
@@ -14,6 +14,8 @@ before_install:
14
14
  - gem update --system $RUBYGEMS_VERSION
15
15
  - gem --version
16
16
 
17
+ bundler_args: --without guard
18
+
17
19
  matrix:
18
20
  allow_failures:
19
21
  - rvm: ruby-head
data/CHANGELOG.md CHANGED
@@ -1,3 +1,29 @@
1
+ ## 1.0.0.beta.4 / 2013-01-11
2
+
3
+ ### Bug fixes
4
+
5
+ * Change permissions on the Chef sandbox to world readable and writable (0755) ([@fnichol][])
6
+ * Minor typographical and documentation errors ([@gmiranda23][])
7
+ * Improve error message when Berkshelf/Librarian is not present ([@fnichol][])
8
+ * Ensure busser respects the `sudo` driver configuration ([@schisamo][])
9
+
10
+ ### Improvements
11
+
12
+ * Pull request [#235][]: Add Chef Solo environment support ([@ekrupnik][])
13
+ * Pull request [#231][]: Use chefignore to determine which files to copy ([@rteabeault][])
14
+ * Pull request [#222][]: Remove dependency on Celluloid and use pure Ruby threads ([@sethvargo][])
15
+ * Pull request [#218][]: Add support for `site-cookbooks` ([@hollow][])
16
+ * Pull request [#217][]: Add support for specific driver configs ([@hollow][])
17
+ * Pull request [#206][]: Add pessismestic locks on all gem requirements ([@sethvargo][])
18
+ * Pull request [#193][]: Allow users to configure ssh forwarding ([@fnordfish][])
19
+ * Pull request [#192][]: Add chef config has and proxy information ([@scotthain][])
20
+ * Pull request [#94][]: Support passing multiple instance names ([@sethvargo][])
21
+ * Drop hard dependency on `pry` gem for `kitchen console` ([@fnichol][])
22
+ * Remove bash-specific code in favor of pure sh for non-standard Unix devices ([@schisamo][])
23
+ * Make remote RUBY_BIN configurable ([@schisamo][])
24
+ * Ensure busser and Chef Zero are executed in their own the sandboxes ([@schisamo][])
25
+
26
+
1
27
  ## 1.0.0.beta.3 / 2013-08-29
2
28
 
3
29
  ### Bug fixes
@@ -201,6 +227,7 @@ The initial release.
201
227
  [#84]: https://github.com/opscode/test-kitchen/issues/84
202
228
  [#90]: https://github.com/opscode/test-kitchen/issues/90
203
229
  [#92]: https://github.com/opscode/test-kitchen/issues/92
230
+ [#94]: https://github.com/opscode/test-kitchen/issues/94
204
231
  [#97]: https://github.com/opscode/test-kitchen/issues/97
205
232
  [#98]: https://github.com/opscode/test-kitchen/issues/98
206
233
  [#99]: https://github.com/opscode/test-kitchen/issues/99
@@ -243,15 +270,27 @@ The initial release.
243
270
  [#179]: https://github.com/opscode/test-kitchen/issues/179
244
271
  [#187]: https://github.com/opscode/test-kitchen/issues/187
245
272
  [#188]: https://github.com/opscode/test-kitchen/issues/188
273
+ [#192]: https://github.com/opscode/test-kitchen/issues/192
274
+ [#193]: https://github.com/opscode/test-kitchen/issues/193
275
+ [#206]: https://github.com/opscode/test-kitchen/issues/206
276
+ [#217]: https://github.com/opscode/test-kitchen/issues/217
277
+ [#218]: https://github.com/opscode/test-kitchen/issues/218
278
+ [#222]: https://github.com/opscode/test-kitchen/issues/222
279
+ [#231]: https://github.com/opscode/test-kitchen/issues/231
280
+ [#235]: https://github.com/opscode/test-kitchen/issues/235
246
281
  [@ChrisLundquist]: https://github.com/ChrisLundquist
247
282
  [@adamhjk]: https://github.com/adamhjk
248
283
  [@arangamani]: https://github.com/arangamani
249
284
  [@arunthampi]: https://github.com/arunthampi
250
285
  [@bryanwb]: https://github.com/bryanwb
251
286
  [@calavera]: https://github.com/calavera
287
+ [@ekrupnik]: https://github.com/ekrupnik
252
288
  [@fnichol]: https://github.com/fnichol
289
+ [@fnordfish]: https://github.com/fnordfish
290
+ [@gmiranda23]: https://github.com/gmiranda23
253
291
  [@gondoi]: https://github.com/gondoi
254
292
  [@grahamc]: https://github.com/grahamc
293
+ [@hollow]: https://github.com/hollow
255
294
  [@jasonroelofs]: https://github.com/jasonroelofs
256
295
  [@jonsmorrow]: https://github.com/jonsmorrow
257
296
  [@josephholsten]: https://github.com/josephholsten
@@ -267,6 +306,8 @@ The initial release.
267
306
  [@rteabeault]: https://github.com/rteabeault
268
307
  [@ryansouza]: https://github.com/ryansouza
269
308
  [@saketoba]: https://github.com/saketoba
309
+ [@schisamo]: https://github.com/schisamo
310
+ [@scotthain]: https://github.com/scotthain
270
311
  [@sethvargo]: https://github.com/sethvargo
271
312
  [@smith]: https://github.com/smith
272
313
  [@stevendanna]: https://github.com/stevendanna
data/Gemfile CHANGED
@@ -1,9 +1,10 @@
1
1
  source 'https://rubygems.org'
2
-
3
2
  gemspec
4
3
 
5
- group :development do
4
+ group :guard do
6
5
  gem 'rb-inotify', :require => false
7
6
  gem 'rb-fsevent', :require => false
8
7
  gem 'rb-fchange', :require => false
8
+ gem 'guard-minitest', '~> 1.3'
9
+ gem 'guard-cucumber', '~> 1.4'
9
10
  end
data/Rakefile CHANGED
@@ -30,6 +30,7 @@ unless RUBY_ENGINE == 'jruby'
30
30
 
31
31
  desc "Run cane to check quality metrics"
32
32
  Cane::RakeTask.new do |cane|
33
+ cane.abc_max = 20
33
34
  cane.abc_exclude = %w(
34
35
  Kitchen::RakeTasks#define
35
36
  Kitchen::ThorTasks#define
data/lib/kitchen.rb CHANGED
@@ -16,7 +16,6 @@
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
18
 
19
- require 'celluloid'
20
19
  require 'pathname'
21
20
  require 'thread'
22
21
 
@@ -34,11 +33,10 @@ require 'kitchen/collection'
34
33
  require 'kitchen/config'
35
34
  require 'kitchen/driver'
36
35
  require 'kitchen/driver/base'
36
+ require 'kitchen/driver/proxy'
37
37
  require 'kitchen/driver/ssh_base'
38
38
  require 'kitchen/instance'
39
- require 'kitchen/instance_actor'
40
39
  require 'kitchen/loader/yaml'
41
- require 'kitchen/manager'
42
40
  require 'kitchen/metadata_chopper'
43
41
  require 'kitchen/platform'
44
42
  require 'kitchen/state_file'
@@ -77,11 +75,6 @@ module Kitchen
77
75
  Logger.new(:stdout => STDOUT, :logdev => logfile, :level => env_log)
78
76
  end
79
77
 
80
- def celluloid_file_logger
81
- logfile = File.expand_path(File.join(".kitchen", "logs", "celluloid.log"))
82
- Logger.new(:logdev => logfile, :level => env_log, :progname => "Celluloid")
83
- end
84
-
85
78
  private
86
79
 
87
80
  def env_log
@@ -94,15 +87,8 @@ module Kitchen
94
87
  DEFAULT_LOG_LEVEL = :info
95
88
  end
96
89
 
97
- # Initialize the base logger and use that for Celluloid's logger
90
+ # Initialize the base logger
98
91
  Kitchen.logger = Kitchen.default_logger
99
- Celluloid.logger = Kitchen.logger
100
92
 
101
93
  # Setup a collection of instance crash exceptions for error reporting
102
- Kitchen.crashes = []
103
- Celluloid.exception_handler do |exception|
104
- Kitchen.logger.debug("An instance crashed because of #{exception.inspect}")
105
- Kitchen.mutex.synchronize { Kitchen.crashes << exception }
106
- end
107
-
108
94
  Kitchen.mutex = Mutex.new
@@ -38,9 +38,11 @@ module Kitchen
38
38
  def initialize(suite_name, opts = {})
39
39
  validate_options(suite_name)
40
40
 
41
+ @ruby_binpath = opts.fetch(:ruby_binpath, DEFAULT_RUBY_BINPATH)
42
+ @busser_root = opts.fetch(:busser_root, DEFAULT_BUSSER_ROOT)
41
43
  @test_root = opts.fetch(:test_root, DEFAULT_TEST_ROOT)
42
44
  @suite_name = suite_name
43
- @use_sudo = opts.fetch(:use_sudo, true)
45
+ @use_sudo = opts.fetch(:sudo, true)
44
46
  end
45
47
 
46
48
  # Returns a command string which installs Busser, and installs all
@@ -55,12 +57,14 @@ module Kitchen
55
57
  @setup_cmd ||= if local_suite_files.empty?
56
58
  nil
57
59
  else
60
+ # use Bourne (/bin/sh) as Bash does not exist on all Unix flavors
58
61
  <<-INSTALL_CMD.gsub(/^ {10}/, '')
59
- bash -c '
60
- if ! #{sudo}#{ruby_binpath}/gem list busser -i >/dev/null ; then
61
- #{sudo}#{ruby_binpath}/gem install #{busser_gem} --no-rdoc --no-ri
62
+ sh -c '
63
+ #{sandbox_env(true)}
64
+ if ! #{sudo}#{gem_bin} list busser -i >/dev/null; then
65
+ echo "-----> Installing busser and plugins"
66
+ #{sudo}#{gem_bin} install busser --no-rdoc --no-ri
62
67
  fi
63
- #{sudo}#{ruby_binpath}/busser setup
64
68
  #{sudo}#{busser_bin} plugin install #{plugins.join(' ')}'
65
69
  INSTALL_CMD
66
70
  end
@@ -78,8 +82,10 @@ module Kitchen
78
82
  @sync_cmd ||= if local_suite_files.empty?
79
83
  nil
80
84
  else
85
+ # use Bourne (/bin/sh) as Bash does not exist on all Unix flavors
81
86
  <<-INSTALL_CMD.gsub(/^ {10}/, '')
82
- bash -c '
87
+ sh -c '
88
+ #{sandbox_env(true)}
83
89
  #{sudo}#{busser_bin} suite cleanup
84
90
  #{local_suite_files.map { |f| stream_file(f, remote_file(f, @suite_name)) }.join}
85
91
  #{helper_files.map { |f| stream_file(f, remote_file(f, "helpers")) }.join}'
@@ -95,15 +101,17 @@ module Kitchen
95
101
  # @return [String] a command string to run the test suites, or nil if no
96
102
  # work needs to be performed
97
103
  def run_cmd
98
- @run_cmd ||= local_suite_files.empty? ? nil : "#{sudo}#{busser_bin} test"
104
+ @run_cmd ||= local_suite_files.empty? ? nil : "#{sandbox_env} #{sudo}#{busser_bin} test"
99
105
  end
100
106
 
101
107
  private
102
108
 
103
109
  DEFAULT_RUBY_BINPATH = "/opt/chef/embedded/bin".freeze
104
- DEFAULT_BUSSER_ROOT = "/opt/busser".freeze
110
+ DEFAULT_BUSSER_ROOT = "/tmp/kitchen-busser".freeze
105
111
  DEFAULT_TEST_ROOT = File.join(Dir.pwd, "test/integration").freeze
106
112
 
113
+ attr_reader :ruby_binpath
114
+ attr_reader :busser_root
107
115
  attr_reader :test_root
108
116
 
109
117
  def validate_options(suite_name)
@@ -135,7 +143,7 @@ module Kitchen
135
143
 
136
144
  def remote_file(file, dir)
137
145
  local_prefix = File.join(test_root, dir)
138
- "$(#{sudo}#{busser_bin} suite path)/".concat(file.sub(%r{^#{local_prefix}/}, ''))
146
+ "$(#{sandbox_env} #{sudo}#{busser_bin} suite path)/".concat(file.sub(%r{^#{local_prefix}/}, ''))
139
147
  end
140
148
 
141
149
  def stream_file(local_path, remote_path)
@@ -162,16 +170,32 @@ module Kitchen
162
170
  @use_sudo ? "sudo -E " : ""
163
171
  end
164
172
 
165
- def ruby_binpath
166
- DEFAULT_RUBY_BINPATH
173
+ def ruby_bin
174
+ @ruby_bin ||= File.join(ruby_binpath, 'ruby')
175
+ end
176
+
177
+ def gem_bin
178
+ @gem_bin ||= File.join(ruby_binpath, 'gem')
167
179
  end
168
180
 
169
181
  def busser_bin
170
- File.join(DEFAULT_BUSSER_ROOT, "bin/busser")
182
+ @busser_bin ||= "#{ruby_bin} #{File.join(busser_root, "gems", "bin", "busser")}"
171
183
  end
172
184
 
173
- def busser_gem
174
- "busser"
185
+ def sandbox_env(export=false)
186
+ env = [
187
+ "BUSSER_ROOT=#{busser_root}",
188
+ "GEM_HOME=#{busser_root}/gems",
189
+ "GEM_PATH=$GEM_HOME",
190
+ "GEM_CACHE=$GEM_HOME/cache",
191
+ "PATH=$PATH:$GEM_HOME/bin"
192
+ ]
193
+
194
+ if export
195
+ env << "; export BUSSER_ROOT GEM_HOME GEM_PATH GEM_CACHE PATH;"
196
+ end
197
+
198
+ env.join(" ")
175
199
  end
176
200
  end
177
201
  end
data/lib/kitchen/cli.rb CHANGED
@@ -20,6 +20,7 @@ require 'benchmark'
20
20
  require 'erb'
21
21
  require 'ostruct'
22
22
  require 'thor'
23
+ require 'thread'
23
24
 
24
25
  require 'kitchen'
25
26
  require 'kitchen/generator/driver_create'
@@ -40,11 +41,9 @@ module Kitchen
40
41
  super
41
42
  $stdout.sync = true
42
43
  Kitchen.logger = Kitchen.default_file_logger
43
- Celluloid.logger = Kitchen.celluloid_file_logger
44
44
  @config = Kitchen::Config.new(
45
45
  :loader => Kitchen::Loader::YAML.new(ENV['KITCHEN_YAML']),
46
- :log_level => ENV['KITCHEN_LOG'] && ENV['KITCHEN_LOG'].downcase.to_sym,
47
- :supervised => false
46
+ :log_level => ENV['KITCHEN_LOG'] && ENV['KITCHEN_LOG'].downcase.to_sym
48
47
  )
49
48
  end
50
49
 
@@ -106,7 +105,7 @@ module Kitchen
106
105
  ensure_initialized
107
106
  destroy_mode = options[:destroy].to_sym
108
107
  @task = :test
109
- results = parse_subcommand(args.first)
108
+ results = parse_subcommand(args.join('|'))
110
109
 
111
110
  if options[:parallel]
112
111
  run_parallel(results, destroy_mode)
@@ -283,8 +282,12 @@ module Kitchen
283
282
  end
284
283
 
285
284
  def run_parallel(instances, *args)
286
- futures = Array(instances).map { |i| i.future.public_send(task, *args) }
287
- futures.map { |i| i.value }
285
+ threads = Array(instances).map do |i|
286
+ Thread.new do
287
+ i.public_send(task, *args)
288
+ end
289
+ end
290
+ threads.map { |i| i.join }
288
291
  end
289
292
 
290
293
  def parse_subcommand(arg = nil)
@@ -292,11 +295,7 @@ module Kitchen
292
295
  end
293
296
 
294
297
  def get_all_instances
295
- result = if options[:parallel]
296
- @config.instance_actors
297
- else
298
- @config.instances
299
- end
298
+ result = @config.instances
300
299
 
301
300
  if result.empty?
302
301
  die task, "No instances defined"
@@ -306,11 +305,7 @@ module Kitchen
306
305
  end
307
306
 
308
307
  def get_filtered_instances(regexp)
309
- result = if options[:parallel]
310
- @config.instance_actors(/#{regexp}/)
311
- else
312
- @config.instances.get_all(/#{regexp}/)
313
- end
308
+ result = @config.instances.get_all(/#{regexp}/)
314
309
 
315
310
  if result.empty?
316
311
  die task, "No instances for regex `#{regexp}', try running `kitchen list'"
@@ -16,7 +16,6 @@
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
18
 
19
- require 'celluloid'
20
19
  require 'vendor/hash_recursive_merge'
21
20
 
22
21
  module Kitchen
@@ -30,7 +29,6 @@ module Kitchen
30
29
  attr_accessor :kitchen_root
31
30
  attr_accessor :test_base_path
32
31
  attr_accessor :log_level
33
- attr_writer :supervised
34
32
  attr_writer :platforms
35
33
  attr_writer :suites
36
34
 
@@ -47,13 +45,11 @@ module Kitchen
47
45
  # @option options [String] :kitchen_root
48
46
  # @option options [String] :test_base_path
49
47
  # @option options [Symbol] :log_level
50
- # @option options [TrueClass,FalseClass] :supervised
51
48
  def initialize(options = {})
52
49
  @loader = options[:loader] || Kitchen::Loader::YAML.new
53
50
  @kitchen_root = options[:kitchen_root] || Dir.pwd
54
51
  @test_base_path = options[:test_base_path] || default_test_base_path
55
52
  @log_level = options[:log_level] || Kitchen::DEFAULT_LOG_LEVEL
56
- @supervised = options[:supervised]
57
53
  end
58
54
 
59
55
  # @return [Array<Platform>] all defined platforms which will be used in
@@ -76,20 +72,6 @@ module Kitchen
76
72
  @instances ||= build_instances
77
73
  end
78
74
 
79
- # Returns an InstanceActor for all instance names matched by the regexp,
80
- # or all by default.
81
- #
82
- # @param [Regexp] a regular expression to match on instance names
83
- # @return [Array<InstanceActor>] all instance actors matching the regexp
84
- def instance_actors(regexp = nil)
85
- result = regexp.nil? ? instances : instances.get_all(regexp)
86
- Collection.new(result.map { |instance| actor_registry(instance) })
87
- end
88
-
89
- def supervised
90
- @supervised.nil? ? @supervised = true : @supervised
91
- end
92
-
93
75
  private
94
76
 
95
77
  def new_suite(hash)
@@ -127,6 +109,7 @@ module Kitchen
127
109
 
128
110
  def new_instance(suite, platform, index)
129
111
  platform_hash = platform_driver_hash(platform.name)
112
+ platform_hash[:driver_config].rmerge!(suite.driver_config)
130
113
  driver = new_driver(merge_driver_hash(platform_hash))
131
114
  provisioner = driver[:provisioner]
132
115
 
@@ -162,41 +145,13 @@ module Kitchen
162
145
  end
163
146
  end
164
147
 
165
- def actor_registry(instance)
166
- Celluloid::Actor[actor_key(instance)] || new_instance_actor(instance)
167
- end
168
-
169
- def actor_key(instance)
170
- "#{object_id}__#{instance.name}"
171
- end
172
-
173
- def new_instance_actor(instance)
174
- actor_name = actor_key(instance)
175
-
176
- actor = if supervised
177
- supervisor = InstanceActor.supervise_as(actor_name, instance)
178
- actor = supervisor.actors.first
179
- Kitchen.logger.debug("Supervising #{actor.to_str} with #{supervisor}")
180
- actor
181
- else
182
- Celluloid::Actor[actor_name] = InstanceActor.new(instance)
183
- end
184
-
185
- manager.link(actor)
186
-
187
- actor
188
- end
189
-
190
- def manager
191
- @manager ||= Manager.new
192
- end
193
-
194
148
  def log_root
195
149
  File.expand_path(File.join(kitchen_root, ".kitchen", "logs"))
196
150
  end
197
151
 
198
152
  def platform_driver_hash(platform_name)
199
153
  h = data[:platforms].find { |p| p[:name] == platform_name } || Hash.new
154
+ h[:driver_config] ||= {}
200
155
 
201
156
  h.select do |key, value|
202
157
  [:driver_plugin, :driver_config, :provisioner].include?(key)