summaryrefslogtreecommitdiff
path: root/acceptance/top-cookbooks
diff options
context:
space:
mode:
authorSalim Alam <salam@chef.io>2016-02-05 15:09:17 -0800
committerSalim Alam <salam@chef.io>2016-02-09 15:05:05 -0800
commitb4a0661e75108b641621e687d083dad1793334a0 (patch)
tree4e514cff6debd103035069acc5b21f64c6ad52d7 /acceptance/top-cookbooks
parent7755b93c72ef33d5041b6a9c4b53bcf29814579d (diff)
downloadchef-b4a0661e75108b641621e687d083dad1793334a0.tar.gz
WIP: Make cookbooks infra more generic
Diffstat (limited to 'acceptance/top-cookbooks')
-rw-r--r--acceptance/top-cookbooks/.acceptance/acceptance-cookbook/.gitignore2
-rw-r--r--acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb41
-rw-r--r--acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/init.rb17
-rw-r--r--acceptance/top-cookbooks/.acceptance/acceptance-cookbook/metadata.rb3
-rw-r--r--acceptance/top-cookbooks/.acceptance/acceptance-cookbook/recipes/destroy.rb1
-rw-r--r--acceptance/top-cookbooks/.acceptance/acceptance-cookbook/recipes/provision.rb2
-rw-r--r--acceptance/top-cookbooks/.acceptance/acceptance-cookbook/recipes/verify.rb1
-rw-r--r--acceptance/top-cookbooks/.gitignore1
-rw-r--r--acceptance/top-cookbooks/.kitchen.yml12
9 files changed, 80 insertions, 0 deletions
diff --git a/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/.gitignore b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/.gitignore
new file mode 100644
index 0000000000..041413b040
--- /dev/null
+++ b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/.gitignore
@@ -0,0 +1,2 @@
+nodes/
+tmp/
diff --git a/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb
new file mode 100644
index 0000000000..c2d65b4b0c
--- /dev/null
+++ b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb
@@ -0,0 +1,41 @@
+class CookbookKitchen < KitchenAcceptance::Kitchen
+ resource_name :cookbook_kitchen
+
+ property :command, default: lazy { name.split(" ")[0] }
+ property :test_cookbook, default: lazy { name.split(" ")[1] }
+ property :kitchen_dir, default: lazy { ::File.join(Chef.node["chef-acceptance"]["suite-dir"], "test_run", test_cookbook) }
+ property :repository, default: lazy { "chef-cookbooks/#{test_cookbook}" },
+ coerce: proc { |v|
+ # chef-cookbooks/runit -> https://github.com/chef-cookbooks/runit.git
+ if !v.include?(':')
+ "https://github.com/#{v}.git"
+ else
+ v
+ end
+ }
+ property :branch, default: "master"
+ property :env, default: lazy {
+ {
+ "BUNDLE_GEMFILE" => ::File.expand_path("../Gemfile", Chef.node["chef-acceptance"]["suite-dir"]),
+ "KITCHEN_GLOBAL_YAML" => ::File.join(kitchen_dir, ".kitchen.yml"),
+ "KITCHEN_YAML" => ::File.join(node["chef-acceptance"]["suite-dir"], ".kitchen.yml")
+ }
+ }
+
+ action :run do
+ if command == "converge"
+ # Ensure the parent directory exists
+ directory ::File.expand_path("..", kitchen_dir)
+
+ # Grab the cookbook
+ # TODO Grab the source URL from supermarket
+ # TODO get git to include its kitchen tests in the cookbook.
+ git kitchen_dir do
+ repository new_resource.repository
+ branch new_resource.branch
+ end
+ end
+
+ super()
+ end
+end
diff --git a/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/init.rb b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/init.rb
new file mode 100644
index 0000000000..8561d6e798
--- /dev/null
+++ b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/init.rb
@@ -0,0 +1,17 @@
+module CookbookGit
+ def self.test_cookbook_name
+ "git"
+ end
+
+ def self.test_run_path
+ File.join(Chef.node["chef-acceptance"]["suite-dir"], "test_run")
+ end
+
+ def self.acceptance_path
+ File.expand_path("..", Chef.node["chef-acceptance"]["suite-dir"])
+ end
+
+ def self.acceptance_gemfile
+ File.join(acceptance_path, "Gemfile")
+ end
+end
diff --git a/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/metadata.rb b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/metadata.rb
new file mode 100644
index 0000000000..26cdab4e99
--- /dev/null
+++ b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/metadata.rb
@@ -0,0 +1,3 @@
+name "acceptance-cookbook"
+
+depends "kitchen_acceptance"
diff --git a/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/recipes/destroy.rb b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/recipes/destroy.rb
new file mode 100644
index 0000000000..35af0e020c
--- /dev/null
+++ b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/recipes/destroy.rb
@@ -0,0 +1 @@
+cookbook_kitchen "destroy git"
diff --git a/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/recipes/provision.rb b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/recipes/provision.rb
new file mode 100644
index 0000000000..8e87a548e3
--- /dev/null
+++ b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/recipes/provision.rb
@@ -0,0 +1,2 @@
+# Run the test on the current platform
+cookbook_kitchen "converge git"
diff --git a/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/recipes/verify.rb b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/recipes/verify.rb
new file mode 100644
index 0000000000..ddc5d27514
--- /dev/null
+++ b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/recipes/verify.rb
@@ -0,0 +1 @@
+cookbook_kitchen "verify git"
diff --git a/acceptance/top-cookbooks/.gitignore b/acceptance/top-cookbooks/.gitignore
new file mode 100644
index 0000000000..306f0cce57
--- /dev/null
+++ b/acceptance/top-cookbooks/.gitignore
@@ -0,0 +1 @@
+test_run/
diff --git a/acceptance/top-cookbooks/.kitchen.yml b/acceptance/top-cookbooks/.kitchen.yml
new file mode 100644
index 0000000000..4f4e15807f
--- /dev/null
+++ b/acceptance/top-cookbooks/.kitchen.yml
@@ -0,0 +1,12 @@
+suites:
+ - name: git-default
+ run_list: ["recipe[git]"]
+ includes: [ubuntu-14.04]
+ - name: git-source
+ run_list: ["recipe[git::source]"]
+ includes: [nonexistent]
+ - name: git-default-windows
+ run_list: ["recipe[git]"]
+ includes: [windows-2012r2]
+ # - name: learn-the-basics-windows
+ # includes: [windows-2012r2]