summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortyler-ball <tyleraball@gmail.com>2016-03-29 15:48:45 -0600
committertyler-ball <tyleraball@gmail.com>2016-03-29 15:48:45 -0600
commit9562c00fef4917ffa6a1ad1188b22d9fe1ce5377 (patch)
treeb668058dde7ad87d29bd363b7dd652409490a979
parent72fa1edf8b969aaf64d8b5af551447a83bf0da25 (diff)
downloadchef-tball/omnitruck_acceptance.tar.gz
Adding acceptance tests for Omnitruck that ensure it only returns 32-bit packages for Chef versions < 12.9tball/omnitruck_acceptance
-rw-r--r--acceptance/Gemfile2
-rw-r--r--acceptance/omnitruck/.acceptance/acceptance-cookbook/.gitignore2
-rw-r--r--acceptance/omnitruck/.acceptance/acceptance-cookbook/metadata.rb1
-rw-r--r--acceptance/omnitruck/.acceptance/acceptance-cookbook/recipes/destroy.rb1
-rw-r--r--acceptance/omnitruck/.acceptance/acceptance-cookbook/recipes/provision.rb1
-rw-r--r--acceptance/omnitruck/.acceptance/acceptance-cookbook/recipes/verify.rb61
6 files changed, 67 insertions, 1 deletions
diff --git a/acceptance/Gemfile b/acceptance/Gemfile
index 4573bc5fb3..c747a27ce5 100644
--- a/acceptance/Gemfile
+++ b/acceptance/Gemfile
@@ -1,7 +1,7 @@
source "https://rubygems.org"
gem "mixlib-install", github: "chef/mixlib-install"
-gem "chef-acceptance", github: "chef/chef-acceptance"
+gem "chef-acceptance", github: "chef/chef-acceptance", branch: "audit_mode"
gem "test-kitchen", github: "sersut/test-kitchen", branch: "sersut/mixlib-install-update"
gem "kitchen-ec2", github: "test-kitchen/kitchen-ec2", branch: "jk/image-search-only"
gem "kitchen-inspec"
diff --git a/acceptance/omnitruck/.acceptance/acceptance-cookbook/.gitignore b/acceptance/omnitruck/.acceptance/acceptance-cookbook/.gitignore
new file mode 100644
index 0000000000..041413b040
--- /dev/null
+++ b/acceptance/omnitruck/.acceptance/acceptance-cookbook/.gitignore
@@ -0,0 +1,2 @@
+nodes/
+tmp/
diff --git a/acceptance/omnitruck/.acceptance/acceptance-cookbook/metadata.rb b/acceptance/omnitruck/.acceptance/acceptance-cookbook/metadata.rb
new file mode 100644
index 0000000000..4c7c42d9bd
--- /dev/null
+++ b/acceptance/omnitruck/.acceptance/acceptance-cookbook/metadata.rb
@@ -0,0 +1 @@
+name 'acceptance-cookbook'
diff --git a/acceptance/omnitruck/.acceptance/acceptance-cookbook/recipes/destroy.rb b/acceptance/omnitruck/.acceptance/acceptance-cookbook/recipes/destroy.rb
new file mode 100644
index 0000000000..f890b597fe
--- /dev/null
+++ b/acceptance/omnitruck/.acceptance/acceptance-cookbook/recipes/destroy.rb
@@ -0,0 +1 @@
+log "NOOP 'destroy' recipe from the acceptance-cookbook in directory '#{node['chef-acceptance']['suite-dir']}'"
diff --git a/acceptance/omnitruck/.acceptance/acceptance-cookbook/recipes/provision.rb b/acceptance/omnitruck/.acceptance/acceptance-cookbook/recipes/provision.rb
new file mode 100644
index 0000000000..64ef7581ac
--- /dev/null
+++ b/acceptance/omnitruck/.acceptance/acceptance-cookbook/recipes/provision.rb
@@ -0,0 +1 @@
+log "NOOP 'provision' recipe from the acceptance-cookbook in directory '#{node['chef-acceptance']['suite-dir']}'"
diff --git a/acceptance/omnitruck/.acceptance/acceptance-cookbook/recipes/verify.rb b/acceptance/omnitruck/.acceptance/acceptance-cookbook/recipes/verify.rb
new file mode 100644
index 0000000000..7db51450e1
--- /dev/null
+++ b/acceptance/omnitruck/.acceptance/acceptance-cookbook/recipes/verify.rb
@@ -0,0 +1,61 @@
+control_group "omnitruck" do
+ require 'chef/http'
+ require 'chef/json_compat'
+
+ # We do this to be able to reference 'rest' both inside and outside example
+ # blocks
+ rest = Chef::HTTP.new("https://omnitruck.chef.io/chef/metadata", headers: {"Accept" => "application/json"})
+ let(:rest) { rest }
+
+ def request(url)
+ Chef::JSONCompat.parse(rest.get(url))["sha256"]
+ end
+
+ shared_examples "32 matches 64" do |version|
+ it "only returns 32-bit packages" do
+ sha32 = request("?p=windows&pv=2012r2&v=#{version}&m=i386")
+ sha64 = request("?p=windows&pv=2012r2&v=#{version}&m=x86_64")
+ expect(sha32).to eq(sha64)
+ end
+ end
+
+ context "from the current channel" do
+ it "returns both 32-bit and 64-bit packages" do
+ # We cannot verify from the returned URL if the package is 64 or 32 bit because
+ # it is often lying, so we just make sure they are different.
+ # The current channel is often cleaned so only the latest builds are in
+ # it, so we just request the latest version instead of trying to check
+ # old versions
+ sha32 = request("?p=windows&pv=2012r2&m=i386&prerelease=true")
+ sha64 = request("?p=windows&pv=2012r2&m=x86_64&prerelease=true")
+ expect(sha32).to_not eq(sha64)
+ end
+ end
+
+ context "from the stable channel" do
+ %w{11 12.3 12.4.2 12.6.0 12.8.1}.each do |version|
+ describe "with version #{version}" do
+ include_examples "32 matches 64", version
+ end
+ end
+
+ begin
+ rest.get("?p=windows&pv=2012r2&v=12.9")
+ describe "with version 12.9" do
+ it "returns both 32-bit and 64-bit packages" do
+ sha32 = request("?p=windows&pv=2012r2&v=12.9&m=i386")
+ sha64 = request("?p=windows&pv=2012r2&v=12.9&m=x86_64")
+ expect(sha32).to_not eq(sha64)
+ end
+ end
+ rescue Net::HTTPServerException => e
+ # Once 12.9 is released this will stop 404ing and the example
+ # will be executed
+ unless e.response.code == "404"
+ raise
+ end
+ end
+
+ end
+
+end