cuken 0.1.9 → 0.1.10
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.
- data/Gemfile.lock +3 -3
- data/README.md +9 -0
- data/VERSION +1 -1
- data/cuken.gemspec +3 -2
- data/features/about.md +51 -10
- data/features/chef_examples/cookbooks_cookbook.feature +18 -7
- data/lib/cuken/api/chef.rb +6 -4
- data/lib/cuken/api/chef/common.rb +1 -0
- data/lib/cuken/api/chef/cookbook.rb +81 -0
- data/lib/cuken/cucumber/chef.rb +0 -4
- data/lib/cuken/cucumber/chef/common.rb +0 -4
- data/lib/cuken/cucumber/chef/cookbook.rb +2 -10
- metadata +4 -3
data/Gemfile.lock
CHANGED
@@ -9,11 +9,11 @@ GEM
|
|
9
9
|
rspec (>= 2.5.0)
|
10
10
|
builder (3.0.0)
|
11
11
|
bunny (0.6.0)
|
12
|
-
chef (0.10.0.rc.
|
12
|
+
chef (0.10.0.rc.1)
|
13
13
|
bunny (>= 0.6.0)
|
14
14
|
erubis
|
15
15
|
highline
|
16
|
-
json (
|
16
|
+
json (>= 1.4.4, <= 1.5.2)
|
17
17
|
mixlib-authentication (>= 1.1.0)
|
18
18
|
mixlib-cli (>= 1.1.0)
|
19
19
|
mixlib-config (>= 1.1.2)
|
@@ -22,7 +22,7 @@ GEM
|
|
22
22
|
net-ssh (~> 2.1.3)
|
23
23
|
net-ssh-multi (~> 1.0.1)
|
24
24
|
ohai (>= 0.6.0)
|
25
|
-
rest-client (
|
25
|
+
rest-client (>= 1.0.4, < 1.7.0)
|
26
26
|
treetop (~> 1.4.9)
|
27
27
|
uuidtools
|
28
28
|
childprocess (0.1.7)
|
data/README.md
CHANGED
@@ -14,6 +14,15 @@ For example usage see the [Cucumber-Nagios][0] gem.
|
|
14
14
|
This library structure is modeled on Aruba, and infact
|
15
15
|
largely uses Aruba's steps.
|
16
16
|
|
17
|
+
## Related projects
|
18
|
+
Cucumber steps for verifing metrics from NewRelic's API, [here][1]
|
19
|
+
Cucumber steps for verifying Scout metrics, [here][2]
|
20
|
+
A library for using mailinator for testing email from rspec and cucumber, [here][3]
|
21
|
+
|
22
|
+
[1]: https://github.com/jnewland/cucumber-newrelic
|
23
|
+
[2]: https://github.com/jnewland/cucumber-scout/
|
24
|
+
[3]: https://github.com/technicalpickles/mailinator-spec
|
25
|
+
|
17
26
|
## Contributing to cuken
|
18
27
|
|
19
28
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.10
|
data/cuken.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{cuken}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.10"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Hedgehog"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-05-02}
|
13
13
|
s.description = %q{Reusable Cucumber steps and API for post-convergence system integration descriptions}
|
14
14
|
s.email = %q{hedgehogshiatus@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -401,6 +401,7 @@ Gem::Specification.new do |s|
|
|
401
401
|
"lib/cuken/all.rb",
|
402
402
|
"lib/cuken/api/chef.rb",
|
403
403
|
"lib/cuken/api/chef/common.rb",
|
404
|
+
"lib/cuken/api/chef/cookbook.rb",
|
404
405
|
"lib/cuken/api/chef/knife.rb",
|
405
406
|
"lib/cuken/api/cmd.rb",
|
406
407
|
"lib/cuken/api/common.rb",
|
data/features/about.md
CHANGED
@@ -18,15 +18,53 @@ If you have ideas to clarify or improve any of these cucumber features,
|
|
18
18
|
please submit an [issue][9] or [pull request][8].
|
19
19
|
|
20
20
|
## The Chef JSON Issue
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
21
|
+
Due to several JSON gem conflicts between various gems, Cuken is only intended
|
22
|
+
to work with the 0.10 series of Chef. Of course you are free to work whatever
|
23
|
+
magic you wish.
|
24
|
+
|
25
|
+
## Opinons
|
26
|
+
Virtual machines are [Vagrant][11] VM's.
|
27
|
+
Vagrant VM's are all named.
|
28
|
+
Configuration management and system integration is done with [Opscode's Chef][12].
|
29
|
+
Chef Cookbooks are sourced from the the [Cookbooks account][13] on Github.
|
30
|
+
|
31
|
+
## Conventions
|
32
|
+
Rather than repeatedly refer to Chef and Vagrant in step definitions, where it is unambiguous,
|
33
|
+
we simply treat the item or attribute as the pro-noun, and capitalize it.
|
34
|
+
Examples:
|
35
|
+
|
36
|
+
Given the VM "chef" is not running
|
37
|
+
Given I create the Data Bag "user"
|
38
|
+
|
39
|
+
Aruba will timeout if a command takes too long. A convention is to tag Features/Scenarios
|
40
|
+
according to the size of the timeout threshold:
|
41
|
+
|
42
|
+
no tag: 3 seconds (Aruba default)
|
43
|
+
@slow
|
44
|
+
@glacial
|
45
|
+
@cosmic
|
46
|
+
|
47
|
+
Aruba will timeout if IO takes too long. This affects interactive SSH connections.
|
48
|
+
|
49
|
+
no tag: 0.1 seconds (Aruba default)
|
50
|
+
@ssh_local
|
51
|
+
@ssh_remote
|
52
|
+
@ssh_pigeon
|
53
|
+
|
54
|
+
The default before blocks are in some of the Cucumber files. Example:
|
55
|
+
|
56
|
+
./lib/cuken/cucumber/chef.rb
|
57
|
+
|
58
|
+
If you need to change a default, add to your features/support/env.rb:
|
59
|
+
|
60
|
+
Before do
|
61
|
+
@aruba_timeout_seconds.nil? || @aruba_timeout_seconds < 3 ? @aruba_timeout_seconds = 3 : @aruba_timeout_seconds
|
62
|
+
end
|
63
|
+
|
64
|
+
Before('@glacial') do
|
65
|
+
@aruba_timeout_seconds.nil? || @aruba_timeout_seconds < 3600 ? @aruba_timeout_seconds = 3600 : @aruba_timeout_seconds
|
66
|
+
end
|
67
|
+
|
30
68
|
|
31
69
|
## Step contributions:
|
32
70
|
- Ideally the API methods should be covered by RSpec (I've been slack
|
@@ -51,4 +89,7 @@ steps to port).
|
|
51
89
|
[7]: https://github.com/mattwynne/ssh-forever
|
52
90
|
[8]: http://help.github.com/pull-requests
|
53
91
|
[9]: https://github.com/hedgehog/cuken/issues
|
54
|
-
[10]: http://groups.google.com/group/agile-system-administration/msg/4128b2de36ccf899
|
92
|
+
[10]: http://groups.google.com/group/agile-system-administration/msg/4128b2de36ccf899
|
93
|
+
[11]: http://vagrantup.com/
|
94
|
+
[12]: http://wiki.opscode.com/display/chef/Home
|
95
|
+
[13]: https://github.com/cookbooks/
|
@@ -1,4 +1,4 @@
|
|
1
|
-
@announce @
|
1
|
+
@announce @cookbooks @cookbook_validity
|
2
2
|
Feature: Cookbook Validity
|
3
3
|
In order to understand cookbooks without evaluating them
|
4
4
|
As an Administrator
|
@@ -42,11 +42,22 @@ Feature: Cookbook Validity
|
|
42
42
|
Scenario: Clone multiple Site-Cookbooks from a Cookbooks URI
|
43
43
|
Given the remote Cookbooks URI "git://github.com/cookbooks/"
|
44
44
|
When I clone the Cookbooks:
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
|cookbook | branch | destination |
|
46
|
+
| hosts | master | ckbk/scratch/myapp/site-cookbooks/hosts4 |
|
47
|
+
| users | master | ckbk/scratch/myapp/site-cookbooks/users2 |
|
48
48
|
And these local Site-Cookbooks exist:
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
|cookbook |
|
50
|
+
| hosts4 |
|
51
|
+
| users2 |
|
52
|
+
|
53
|
+
Scenario: Download Site-Cookbooks from a Cookbooks URI
|
54
|
+
Given the remote Cookbooks URI "git://github.com/cookbooks/"
|
55
|
+
When I clone the Cookbooks:
|
56
|
+
| cookbook | branch | destination |
|
57
|
+
| users | 37s | ckbk/scratch/myapp/cookbooks/users |
|
58
|
+
| users | 37s | ckbk/scratch/myapp/site-cookbooks/users2 |
|
59
|
+
Then these local Cookbooks exist:
|
60
|
+
| cookbook | site-cookbook |
|
61
|
+
| users | |
|
62
|
+
| | users2 |
|
52
63
|
|
data/lib/cuken/api/chef.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'aruba/api' unless defined? Aruba::Api
|
2
2
|
require 'chef' unless defined? Chef
|
3
3
|
require 'grit' unless defined? Grit
|
4
|
+
require 'vagrant' unless defined? Vagrant
|
4
5
|
require 'cuken/api/common'
|
5
6
|
require 'cuken/api/chef/common'
|
7
|
+
require 'cuken/api/chef/cookbook'
|
6
8
|
require 'cuken/api/chef/knife'
|
7
9
|
|
8
10
|
module ::Cuken
|
@@ -13,13 +15,13 @@ module ::Cuken
|
|
13
15
|
|
14
16
|
def append_cookbook_path(cookbook, lp, lrp)
|
15
17
|
if lrp.exist?
|
16
|
-
announce_or_puts(%{
|
18
|
+
announce_or_puts(%{Adding cookbook path: #{lp}}) if @announce_env && cookbook
|
17
19
|
chef.cookbook_paths << lp if cookbook
|
18
|
-
announce_or_puts(%{
|
20
|
+
announce_or_puts(%{Adding cookbooks path: #{lp.parent}}) if @announce_env && cookbook
|
19
21
|
chef.cookbooks_paths << lp.parent if cookbook
|
20
22
|
lrp
|
21
23
|
else
|
22
|
-
announce_or_puts(%{
|
24
|
+
announce_or_puts(%{WARNING: cookbook(s) path: #{lp} is not a Git repository.}) if @announce_env && cookbook
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
@@ -36,7 +38,7 @@ module ::Cuken
|
|
36
38
|
end
|
37
39
|
chef.cookbooks_paths.uniq!
|
38
40
|
if chef.cookbooks_paths.empty?
|
39
|
-
announce_or_puts(%{
|
41
|
+
announce_or_puts(%{WARNING: cookbooks path: #{lp} does not contain any Git repositories.}) if @announce_env
|
40
42
|
end
|
41
43
|
end
|
42
44
|
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module ::Cuken
|
2
|
+
module Api
|
3
|
+
module Chef
|
4
|
+
module Cookbook
|
5
|
+
|
6
|
+
def parse_to_cookbooks_path(hsh)
|
7
|
+
case
|
8
|
+
when not(hsh['cookbook'].nil? || hsh['cookbook'].empty?)
|
9
|
+
ckbk = hsh['cookbook']
|
10
|
+
ckbk_src = "cookbooks/#{ckbk}"
|
11
|
+
when not(hsh['site-cookbook'].nil? || hsh['site-cookbook'].empty?)
|
12
|
+
ckbk = hsh['site-cookbook']
|
13
|
+
ckbk_src = "site-cookbooks/#{ckbk}"
|
14
|
+
else
|
15
|
+
src =""
|
16
|
+
end
|
17
|
+
return ckbk, ckbk_src
|
18
|
+
end
|
19
|
+
|
20
|
+
def check_cookbooks_table_presence(table, expect_presence = true)
|
21
|
+
table.hashes.each do |hsh|
|
22
|
+
ckbk, ckbk_src = parse_to_cookbooks_path(hsh)
|
23
|
+
full_cookbook_src = find_path_in_cookbook_folders(ckbk, ckbk_src, ckbk)
|
24
|
+
announce_or_puts(%{Looking for cookbook: #{full_cookbook_src}}) if @announce_env
|
25
|
+
check_cookbook_presence(full_cookbook_src, expect_presence)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def find_path_in_cookbook_folders(ckbk, ckbk_src, path_fragment1, path_fagment2='')
|
30
|
+
verify_cookbook_folders
|
31
|
+
full_data_bag_src = nil
|
32
|
+
in_chef_root do
|
33
|
+
list1 = chef.cookbooks_paths.find_all { |dir| Pathname(dir + path_fragment1 + path_fagment2).exist? }
|
34
|
+
list2 = chef.cookbook_paths.find_all { |dir| (dir.to_s[/#{ckbk_src}/] && Pathname(dir+path_fagment2).exist?) }
|
35
|
+
loc = list2[0] || ((list1[0] + ckbk) if list1[0].exist?)
|
36
|
+
if loc.nil? || not(loc.exist?)
|
37
|
+
# TODO: error handling if data bags or cookbooks do not exist
|
38
|
+
else
|
39
|
+
full_data_bag_src = (loc + path_fagment2).expand_path.realdirpath.to_s
|
40
|
+
end
|
41
|
+
end
|
42
|
+
full_data_bag_src
|
43
|
+
end
|
44
|
+
|
45
|
+
def verify_cookbook_folders
|
46
|
+
if (chef.cookbooks_paths.empty? && chef.cookbook_paths.empty?)
|
47
|
+
check_default_cookbooks_paths
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def check_default_cookbooks_paths
|
52
|
+
in_chef_root do
|
53
|
+
['site-cookbooks', 'cookbooks'].each do |dir|
|
54
|
+
path = (Pathname('.')+dir)
|
55
|
+
chef.cookbooks_paths << path if path.exist?
|
56
|
+
end
|
57
|
+
if chef.cookbooks_paths.empty?
|
58
|
+
raise(RuntimeError, "chef.cookbooks_paths AND chef.cookbook_paths cannot both be empty.", caller)
|
59
|
+
end
|
60
|
+
chef.cookbooks_paths.uniq
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def check_cookbook_presence(ckbk, expect_presence = true)
|
65
|
+
chef.cookbook_paths.each do |pn|
|
66
|
+
curr_ckbk = pn.basename.to_s
|
67
|
+
condition = Pathname(pn).exist?
|
68
|
+
given_ckbk = Pathname(ckbk).basename.to_s
|
69
|
+
result = given_ckbk == curr_ckbk
|
70
|
+
if condition && result
|
71
|
+
given_ckbk.should == curr_ckbk
|
72
|
+
announce_or_puts(%{Found cookbook: #{pn}}) if @announce_env
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
data/lib/cuken/cucumber/chef.rb
CHANGED
@@ -8,10 +8,6 @@ Before do
|
|
8
8
|
::Grit::Git.git_timeout = 3610
|
9
9
|
end
|
10
10
|
|
11
|
-
#Before('@work_in_cwd') do
|
12
|
-
# @dirs = [Pathname.getwd.expand_path.realpath.to_s]
|
13
|
-
#end
|
14
|
-
|
15
11
|
require 'cuken/cucumber/chef/common'
|
16
12
|
require 'cuken/cucumber/chef/knife'
|
17
13
|
require 'cuken/cucumber/chef/cookbook'
|
@@ -22,6 +22,7 @@
|
|
22
22
|
# See the License for the specific language governing permissions and
|
23
23
|
# limitations under the License.
|
24
24
|
#
|
25
|
+
World(::Cuken::Api::Chef::Cookbook)
|
25
26
|
|
26
27
|
Given /^the remote Cookbook repository "([^"]*)"$/ do |ckbk_repo|
|
27
28
|
in_current_dir do
|
@@ -90,15 +91,7 @@ Then /^the local Site\-Cookbook "([^"]*)" exists$/ do |ckbk|
|
|
90
91
|
end
|
91
92
|
|
92
93
|
And /^these local Cookbooks exist:$/ do |table|
|
93
|
-
|
94
|
-
table.hashes.each do |hsh|
|
95
|
-
chef.cookbook_paths.each do |pn|
|
96
|
-
curr_ckbk = pn.basename.to_s
|
97
|
-
if curr_ckbk == hsh['cookbook']
|
98
|
-
break true if curr_ckbk.should == hsh['cookbook']
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
94
|
+
check_cookbooks_table_presence(table)
|
102
95
|
end
|
103
96
|
|
104
97
|
And /^these local Site\-Cookbooks exist:$/ do |table|
|
@@ -131,7 +124,6 @@ Given /^I clone the Cookbook "([^"]*)" branch "([^"]*)" to "([^"]*)"$/ do |ckbk,
|
|
131
124
|
end
|
132
125
|
|
133
126
|
When /^I clone the Cookbooks:$/ do |table|
|
134
|
-
# table is a Cucumber::Ast::Table
|
135
127
|
table.hashes.each do |hsh|
|
136
128
|
src = {}
|
137
129
|
src['branch'] = hsh['branch'] if hsh['branch']
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: cuken
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.10
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Hedgehog
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-05-02 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: aruba
|
@@ -593,6 +593,7 @@ files:
|
|
593
593
|
- lib/cuken/all.rb
|
594
594
|
- lib/cuken/api/chef.rb
|
595
595
|
- lib/cuken/api/chef/common.rb
|
596
|
+
- lib/cuken/api/chef/cookbook.rb
|
596
597
|
- lib/cuken/api/chef/knife.rb
|
597
598
|
- lib/cuken/api/cmd.rb
|
598
599
|
- lib/cuken/api/common.rb
|
@@ -655,7 +656,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
655
656
|
requirements:
|
656
657
|
- - ">="
|
657
658
|
- !ruby/object:Gem::Version
|
658
|
-
hash:
|
659
|
+
hash: -3241898451513143532
|
659
660
|
segments:
|
660
661
|
- 0
|
661
662
|
version: "0"
|