test-kitchen 0.5.0

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.
Files changed (37) hide show
  1. data/bin/kitchen +7 -0
  2. data/config/Cheffile +55 -0
  3. data/config/Kitchenfile +39 -0
  4. data/config/Vagrantfile +109 -0
  5. data/cookbooks/test-kitchen/attributes/default.rb +25 -0
  6. data/cookbooks/test-kitchen/libraries/helpers.rb +25 -0
  7. data/cookbooks/test-kitchen/metadata.rb +27 -0
  8. data/cookbooks/test-kitchen/recipes/chef.rb +19 -0
  9. data/cookbooks/test-kitchen/recipes/compat.rb +39 -0
  10. data/cookbooks/test-kitchen/recipes/default.rb +51 -0
  11. data/cookbooks/test-kitchen/recipes/erlang.rb +19 -0
  12. data/cookbooks/test-kitchen/recipes/ruby.rb +40 -0
  13. data/lib/test-kitchen.rb +34 -0
  14. data/lib/test-kitchen/cli.rb +267 -0
  15. data/lib/test-kitchen/cli/destroy.rb +42 -0
  16. data/lib/test-kitchen/cli/init.rb +37 -0
  17. data/lib/test-kitchen/cli/platform_list.rb +37 -0
  18. data/lib/test-kitchen/cli/project_info.rb +44 -0
  19. data/lib/test-kitchen/cli/ssh.rb +36 -0
  20. data/lib/test-kitchen/cli/status.rb +36 -0
  21. data/lib/test-kitchen/cli/test.rb +60 -0
  22. data/lib/test-kitchen/dsl.rb +59 -0
  23. data/lib/test-kitchen/environment.rb +164 -0
  24. data/lib/test-kitchen/platform.rb +63 -0
  25. data/lib/test-kitchen/project.rb +23 -0
  26. data/lib/test-kitchen/project/base.rb +159 -0
  27. data/lib/test-kitchen/project/cookbook.rb +87 -0
  28. data/lib/test-kitchen/project/cookbook_copy.rb +58 -0
  29. data/lib/test-kitchen/project/ruby.rb +37 -0
  30. data/lib/test-kitchen/project/supported_platforms.rb +75 -0
  31. data/lib/test-kitchen/runner.rb +20 -0
  32. data/lib/test-kitchen/runner/base.rb +144 -0
  33. data/lib/test-kitchen/runner/vagrant.rb +92 -0
  34. data/lib/test-kitchen/scaffold.rb +73 -0
  35. data/lib/test-kitchen/ui.rb +73 -0
  36. data/lib/test-kitchen/version.rb +21 -0
  37. metadata +196 -0
@@ -0,0 +1,92 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'vagrant'
20
+
21
+ module TestKitchen
22
+ module Runner
23
+ class Vagrant < Base
24
+
25
+ def initialize(env, options={})
26
+ super
27
+ @env, @options = env, options
28
+ end
29
+
30
+ def provision
31
+ super
32
+ vagrant_env.cli(vagrant_cli_argv('up'))
33
+ end
34
+
35
+ def status
36
+ vagrant_env.cli(vagrant_cli_argv('status'))
37
+ end
38
+
39
+ def destroy
40
+ vagrant_env.cli(vagrant_cli_argv(['destroy', '--force']))
41
+ end
42
+
43
+ def ssh
44
+ vagrant_env.cli(vagrant_cli_argv('ssh'))
45
+ end
46
+
47
+ def execute_remote_command(vm, command, message=nil)
48
+ vm = vagrant_env.vms[vm.to_sym] unless vm.kind_of?(::Vagrant::VM)
49
+ vm.ui.info(message, :color => :yellow) if message
50
+ vm.channel.execute(command, :error_check => false) do |type, data|
51
+ next if data =~ /stdin: is not a tty/
52
+ if [:stderr, :stdout].include?(type)
53
+ # Output the data with the proper color based on the stream.
54
+ color = type == :stdout ? :green : :red
55
+ vm.ui.info(data, :color => color, :prefix => false, :new_line => false)
56
+ end
57
+ end
58
+ end
59
+
60
+ private
61
+
62
+ def vagrant_env
63
+ @vagrant_env ||= begin
64
+ # massive hack
65
+ if test_recipe_name
66
+ vagrant_file = "test_recipe_name='#{test_recipe_name}'\n"
67
+ else
68
+ vagrant_file = 'test_recipe_name=nil'
69
+ end
70
+ vagrant_file += IO.read(TestKitchen.source_root.join('config', 'Vagrantfile'))
71
+ env.create_tmp_file('Vagrantfile', vagrant_file)
72
+
73
+ options = {
74
+ :ui_class => ::Vagrant::UI::Colored,
75
+ :cwd => env.tmp_path
76
+ }
77
+
78
+ env = ::Vagrant::Environment.new(options)
79
+ env.load!
80
+ env
81
+ end
82
+ end
83
+
84
+ def vagrant_cli_argv(command)
85
+ argv = Array(command)
86
+ argv << platform if platform
87
+ argv
88
+ end
89
+
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,73 @@
1
+ #
2
+ # Author:: Andrew Crump (<andrew@kotirisoftware.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'fileutils'
20
+
21
+ module TestKitchen
22
+
23
+ class Scaffold
24
+
25
+ def generate(output_dir)
26
+
27
+ scaffold_file '.gitignore',
28
+ <<-eos
29
+ .bundle
30
+ .cache
31
+ .kitchen
32
+ bin
33
+ eos
34
+
35
+ scaffold_file 'Gemfile',
36
+ <<-eos
37
+ source :rubygems
38
+
39
+ gem 'test-kitchen', :git => 'git@github.com:opscode/test-kitchen.git'
40
+ eos
41
+
42
+ scaffold_file 'test/kitchen/Kitchenfile',
43
+ <<-eos
44
+ #{project_type(output_dir)} "#{project_name(output_dir)}" do
45
+ #{'runtimes []' if project_type(output_dir) == 'cookbook'}
46
+ end
47
+ eos
48
+ end
49
+
50
+ private
51
+
52
+ def project_name(output_dir)
53
+ File.basename(output_dir)
54
+ end
55
+
56
+ def project_type(output_dir)
57
+ if File.exists?(File.join(output_dir, 'metadata.rb'))
58
+ 'cookbook'
59
+ else
60
+ 'integration_test'
61
+ end
62
+ end
63
+
64
+ def scaffold_file(path, content)
65
+ FileUtils.mkdir_p(File.dirname(path))
66
+ unless File.exists?(path)
67
+ File.open(path, 'w') {|f| f.write(content.gsub(/^ {10}/, '')) }
68
+ end
69
+ end
70
+
71
+ end
72
+
73
+ end
@@ -0,0 +1,73 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ module TestKitchen
20
+ class UI
21
+
22
+ attr_reader :stdout
23
+ attr_reader :stderr
24
+ attr_reader :stdin
25
+
26
+ def initialize(stdout, stderr, stdin, config)
27
+ @stdout, @stderr, @stdin, @config = stdout, stderr, stdin, config
28
+ end
29
+
30
+ def highline
31
+ @highline ||= begin
32
+ require 'highline'
33
+ HighLine.new
34
+ end
35
+ end
36
+
37
+ # Prints a message to stdout. Aliased as +info+ for compatibility with
38
+ # the logger API.
39
+ def msg(message, *colors)
40
+ if colors
41
+ message = color(message, *colors)
42
+ end
43
+ stdout.puts message
44
+ end
45
+
46
+ alias :info :msg
47
+
48
+ # Prints a msg to stderr. Used for warn, error, and fatal.
49
+ def err(message)
50
+ stderr.puts message
51
+ end
52
+
53
+ # Print a warning message
54
+ def warn(message)
55
+ err("#{color('WARNING:', :yellow, :bold)} #{message}")
56
+ end
57
+
58
+ # Print an error message
59
+ def error(message)
60
+ err("#{color('ERROR:', :red, :bold)} #{message}")
61
+ end
62
+
63
+ # Print a message describing a fatal error.
64
+ def fatal(message)
65
+ err("#{color('FATAL:', :red, :bold)} #{message}")
66
+ end
67
+
68
+ def color(string, *colors)
69
+ highline.color(string, *colors)
70
+ end
71
+
72
+ end
73
+ end
@@ -0,0 +1,21 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ module TestKitchen
20
+ VERSION = "0.5.0"
21
+ end
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: test-kitchen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Seth Chisamore
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: foodcritic
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.2.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.2.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: hashr
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.0.20
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.0.20
46
+ - !ruby/object:Gem::Dependency
47
+ name: mixlib-cli
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.2.2
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.2.2
62
+ - !ruby/object:Gem::Dependency
63
+ name: highline
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 1.6.9
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 1.6.9
78
+ - !ruby/object:Gem::Dependency
79
+ name: vagrant
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 1.0.2
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 1.0.2
94
+ - !ruby/object:Gem::Dependency
95
+ name: yajl-ruby
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 1.1.0
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.1.0
110
+ - !ruby/object:Gem::Dependency
111
+ name: librarian
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 0.0.20
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 0.0.20
126
+ description: Easily provision test environments for integration testing with Chef.
127
+ email:
128
+ - schisamo@opscode.com
129
+ executables:
130
+ - kitchen
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - bin/kitchen
135
+ - config/Cheffile
136
+ - config/Kitchenfile
137
+ - config/Vagrantfile
138
+ - cookbooks/test-kitchen/attributes/default.rb
139
+ - cookbooks/test-kitchen/libraries/helpers.rb
140
+ - cookbooks/test-kitchen/metadata.rb
141
+ - cookbooks/test-kitchen/recipes/chef.rb
142
+ - cookbooks/test-kitchen/recipes/compat.rb
143
+ - cookbooks/test-kitchen/recipes/default.rb
144
+ - cookbooks/test-kitchen/recipes/erlang.rb
145
+ - cookbooks/test-kitchen/recipes/ruby.rb
146
+ - lib/test-kitchen/cli/destroy.rb
147
+ - lib/test-kitchen/cli/init.rb
148
+ - lib/test-kitchen/cli/platform_list.rb
149
+ - lib/test-kitchen/cli/project_info.rb
150
+ - lib/test-kitchen/cli/ssh.rb
151
+ - lib/test-kitchen/cli/status.rb
152
+ - lib/test-kitchen/cli/test.rb
153
+ - lib/test-kitchen/cli.rb
154
+ - lib/test-kitchen/dsl.rb
155
+ - lib/test-kitchen/environment.rb
156
+ - lib/test-kitchen/platform.rb
157
+ - lib/test-kitchen/project/base.rb
158
+ - lib/test-kitchen/project/cookbook.rb
159
+ - lib/test-kitchen/project/cookbook_copy.rb
160
+ - lib/test-kitchen/project/ruby.rb
161
+ - lib/test-kitchen/project/supported_platforms.rb
162
+ - lib/test-kitchen/project.rb
163
+ - lib/test-kitchen/runner/base.rb
164
+ - lib/test-kitchen/runner/vagrant.rb
165
+ - lib/test-kitchen/runner.rb
166
+ - lib/test-kitchen/scaffold.rb
167
+ - lib/test-kitchen/ui.rb
168
+ - lib/test-kitchen/version.rb
169
+ - lib/test-kitchen.rb
170
+ homepage: https://github.com/opscode/test-kitchen
171
+ licenses:
172
+ - Apache
173
+ post_install_message:
174
+ rdoc_options: []
175
+ require_paths:
176
+ - lib
177
+ required_ruby_version: !ruby/object:Gem::Requirement
178
+ none: false
179
+ requirements:
180
+ - - ! '>='
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ required_rubygems_version: !ruby/object:Gem::Requirement
184
+ none: false
185
+ requirements:
186
+ - - ! '>='
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ requirements: []
190
+ rubyforge_project:
191
+ rubygems_version: 1.8.23
192
+ signing_key:
193
+ specification_version: 3
194
+ summary: Easily provision test environments for integration testing with Chef.
195
+ test_files: []
196
+ has_rdoc: