summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml17
-rw-r--r--kitchen-tests/Berksfile1
-rw-r--r--kitchen-tests/cookbooks/rspec/metadata.rb8
-rw-r--r--kitchen-tests/cookbooks/rspec/recipes/default.rb13
-rw-r--r--kitchen-tests/cookbooks/rspec/templates/run-chef-rspec11
-rw-r--r--kitchen-tests/kitchen.travis.yml9
-rw-r--r--lib/chef/provider/mount/mount.rb1
-rw-r--r--spec/functional/resource/mount_spec.rb2
-rw-r--r--spec/functional/resource/yum_package_spec.rb6
-rw-r--r--spec/unit/provider/package/rubygems_spec.rb19
10 files changed, 81 insertions, 6 deletions
diff --git a/.travis.yml b/.travis.yml
index cade7e5fca..19747762af 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -322,6 +322,23 @@ matrix:
- cat /tmp/out.txt
- sudo cat /var/log/squid3/cache.log
- sudo cat /var/log/squid3/access.log
+ - rvm: 2.4.4
+ services: docker
+ sudo: required
+ gemfile: kitchen-tests/Gemfile
+ before_install:
+ - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2)
+ - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2)
+ before_script:
+ - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
+ - cd kitchen-tests
+ script:
+ - bundle exec kitchen test rspec-centos-7
+ after_failure:
+ - cat .kitchen/logs/kitchen.log
+ env:
+ - RSPEC_CENTOS=7
+ - KITCHEN_YAML=kitchen.travis.yml
notifications:
on_change: true
diff --git a/kitchen-tests/Berksfile b/kitchen-tests/Berksfile
index 50e09ebf3b..d699452ebe 100644
--- a/kitchen-tests/Berksfile
+++ b/kitchen-tests/Berksfile
@@ -1,3 +1,4 @@
source "https://supermarket.chef.io"
cookbook "end_to_end", path: "cookbooks/end_to_end"
+cookbook "rspec", path: "cookbooks/rspec"
diff --git a/kitchen-tests/cookbooks/rspec/metadata.rb b/kitchen-tests/cookbooks/rspec/metadata.rb
new file mode 100644
index 0000000000..f0b5bfba75
--- /dev/null
+++ b/kitchen-tests/cookbooks/rspec/metadata.rb
@@ -0,0 +1,8 @@
+name "rspec"
+license "Apache-2.0"
+description "Runs nothing"
+version "1.0.0"
+
+chef_version ">= 14"
+issues_url "https://github.com/chef/chef/issues"
+source_url "https://github.com/chef/chef"
diff --git a/kitchen-tests/cookbooks/rspec/recipes/default.rb b/kitchen-tests/cookbooks/rspec/recipes/default.rb
new file mode 100644
index 0000000000..4dc1c10d99
--- /dev/null
+++ b/kitchen-tests/cookbooks/rspec/recipes/default.rb
@@ -0,0 +1,13 @@
+# we're using chef-client now as a glorified way to push a file to the remote host
+# if we had a way to turn off chef-client converge and push arbitrary files to the
+# remote this complexity could be removed.
+template "/usr/local/bin/run-chef-rspec" do
+ source "run-chef-rspec"
+ mode 0755
+end
+
+# do NOT even think of trying to add an execute resource here to launch rspec.
+# chefception is proven to be a bad idea, and the rspec tests that really launch
+# chef-client will likely break due to the outer chef-client run. i also do not
+# want to debug rspec's output being filtered through chef-client's logger -- fuck
+# all of that noise.
diff --git a/kitchen-tests/cookbooks/rspec/templates/run-chef-rspec b/kitchen-tests/cookbooks/rspec/templates/run-chef-rspec
new file mode 100644
index 0000000000..54c4297479
--- /dev/null
+++ b/kitchen-tests/cookbooks/rspec/templates/run-chef-rspec
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+# remove ip6 entries for docker
+egrep -v "ip6" /etc/hosts > /etc/hosts.new
+cp /etc/hosts.new /etc/hosts
+
+export PATH=/opt/chef/embedded/bin:$PATH
+cd /opt/chef/embedded/apps/chef
+
+/opt/chef/embedded/bin/bundle install
+/opt/chef/embedded/bin/bundle exec /opt/chef/embedded/bin/rspec --format progress
diff --git a/kitchen-tests/kitchen.travis.yml b/kitchen-tests/kitchen.travis.yml
index 3736fb2fab..9efbf243ca 100644
--- a/kitchen-tests/kitchen.travis.yml
+++ b/kitchen-tests/kitchen.travis.yml
@@ -69,6 +69,9 @@ platforms:
image: dokken/centos-7
pid_one_command: /usr/lib/systemd/systemd
intermediate_instructions:
+ - RUN yum -y install cronie util-linux e2fsprogs
+ - RUN egrep -v '::1' /etc/hosts > /etc/hosts.new
+ - RUN cp /etc/hosts.new /etc/hosts
- RUN sed -i -e "s/Defaults.*requiretty.*/Defaults !requiretty/g" /etc/sudoers
- name: fedora-latest
@@ -108,3 +111,9 @@ suites:
- name: end-to-end
run_list:
- recipe[end_to_end::default]
+ - name: rspec
+ run_list:
+ - recipe[rspec]
+ lifecycle:
+ post_converge:
+ - remote: /usr/local/bin/run-chef-rspec
diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb
index 55be15d8c5..3006b6af07 100644
--- a/lib/chef/provider/mount/mount.rb
+++ b/lib/chef/provider/mount/mount.rb
@@ -53,6 +53,7 @@ class Chef
def enabled?
# Check to see if there is a entry in /etc/fstab. Last entry for a volume wins.
enabled = false
+ return unless ::File.exist?("/etc/fstab")
::File.foreach("/etc/fstab") do |line|
case line
when /^[#\s]/
diff --git a/spec/functional/resource/mount_spec.rb b/spec/functional/resource/mount_spec.rb
index f4e528c755..f6c7f91bcd 100644
--- a/spec/functional/resource/mount_spec.rb
+++ b/spec/functional/resource/mount_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
-# Copyright:: Copyright 2013-2016, Chef Software Inc.
+# Copyright:: Copyright 2013-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/spec/functional/resource/yum_package_spec.rb b/spec/functional/resource/yum_package_spec.rb
index 17e4669255..3735e67cf2 100644
--- a/spec/functional/resource/yum_package_spec.rb
+++ b/spec/functional/resource/yum_package_spec.rb
@@ -443,11 +443,13 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
end
- it "downgrade on a local file raises an error" do
+ it "downgrade on a local file is ignored" do
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
yum_package.version "1.2-1"
yum_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
- expect { yum_package.run_action(:install) }.to raise_error(Mixlib::ShellOut::ShellCommandFailed)
+ yum_package.run_action(:install)
+ expect(yum_package.updated_by_last_action?).to be false
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
end
it "downgrade on a local file with allow_downgrade true works" do
diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb
index 6b33ab97f9..2e9888fb78 100644
--- a/spec/unit/provider/package/rubygems_spec.rb
+++ b/spec/unit/provider/package/rubygems_spec.rb
@@ -27,6 +27,19 @@ module GemspecBackcompatCreator
end
end
+# this is a global variable we construct of the highest rspec-core version which is installed, using APIs which
+# will break out of the bundle -- and done this way so that we can mock all these internal Gem APIs later...
+class RspecVersionString
+ def self.rspec_version_string
+ @rspec_version_string ||= begin
+ stubs = Gem::Specification.send(:installed_stubs, Gem::Specification.dirs, "rspec-core-*.gemspec")
+ stubs.select! { |stub| stub.name == "rspec-core" && Gem::Dependency.new("rspec-core", ">= 0").requirement.satisfied_by?(stub.version) }
+ stubs.max_by(&:version).version.to_s
+ end
+ end
+end
+RspecVersionString.rspec_version_string
+
require "spec_helper"
require "ostruct"
@@ -57,7 +70,7 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
end
it "determines the installed versions of gems from the source index (part2: the unmockening)" do
- expected = ["rspec-core", Gem::Version.new(RSpec::Core::Version::STRING)]
+ expected = ["rspec-core", Gem::Version.new( RspecVersionString.rspec_version_string )]
actual = @gem_env.installed_versions(Gem::Dependency.new("rspec-core", nil)).map { |spec| [spec.name, spec.version] }
expect(actual).to include(expected)
end
@@ -247,7 +260,7 @@ describe Chef::Provider::Package::Rubygems::AlternateGemEnvironment do
end
skip("cant find your gem executable") if path_to_gem.empty?
gem_env = Chef::Provider::Package::Rubygems::AlternateGemEnvironment.new(path_to_gem)
- expected = ["rspec-core", Gem::Version.new(RSpec::Core::Version::STRING)]
+ expected = ["rspec-core", Gem::Version.new( RspecVersionString.rspec_version_string )]
actual = gem_env.installed_versions(Gem::Dependency.new("rspec-core", nil)).map { |s| [s.name, s.version] }
expect(actual).to include(expected)
end
@@ -400,7 +413,7 @@ describe Chef::Provider::Package::Rubygems do
end
describe "when new_resource version is an rspec version" do
- let(:current_version) { RSpec::Core::Version::STRING }
+ let(:current_version) { RspecVersionString.rspec_version_string }
let(:target_version) { current_version }
it "triggers a gem configuration load so a later one will not stomp its config values" do