summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-05-06 21:05:57 -0700
committerGitHub <noreply@github.com>2020-05-06 21:05:57 -0700
commit7ddcca60462afa39b1b397db1b87c32bf5282083 (patch)
tree131ede67b1da3bd002073522469b5547f9991bc3
parent0e8ca79610516a77cd0ccccd1ae33098e9ff2468 (diff)
parent1ce6b162bf112bf2da2aba4280780d2f2959b865 (diff)
downloadchef-7ddcca60462afa39b1b397db1b87c32bf5282083.tar.gz
Merge pull request #9816 from chef/more_kitchen_testing
Expand our sudo, sysctl, execute, apt_update and apt_preference testing
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/_apt.rb (renamed from kitchen-tests/cookbooks/end_to_end/recipes/_apt_preference.rb)12
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/_sudo.rb63
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/_sysctl.rb9
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/_yum.rb16
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/default.rb44
-rwxr-xr-xscripts/bk_tests/bk_linux_exec.sh1
6 files changed, 115 insertions, 30 deletions
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/_apt_preference.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_apt.rb
index 6b492230f1..901cd8c36c 100644
--- a/kitchen-tests/cookbooks/end_to_end/recipes/_apt_preference.rb
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/_apt.rb
@@ -3,12 +3,22 @@
# Recipe:: apt_preference
#
+apt_update "periodic apt update" do
+ frequency 86400
+ action :periodic
+end
+
apt_preference "dotdeb" do
glob "*"
pin "origin packages.dotdeb.org"
pin_priority "700"
end
+apt_preference "a_fake_package" do
+ pin "version 5.1.49-3"
+ pin_priority "700"
+end
+
apt_preference "libmysqlclient16" do
action :remove
-end \ No newline at end of file
+end
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/_sudo.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_sudo.rb
new file mode 100644
index 0000000000..4f08405ae9
--- /dev/null
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/_sudo.rb
@@ -0,0 +1,63 @@
+#
+# Cookbook:: end_to_end
+# Recipe:: sudo
+#
+
+sudo "sysadmins" do
+ users "bob_bobberson"
+ groups "sysadmins, superusers"
+ nopasswd true
+end
+
+sudo "tomcat" do
+ user "%tomcat"
+ runas "app_user"
+ commands ["/etc/init.d/tomcat restart", "/etc/init.d/tomcat stop", "/etc/init.d/tomcat start"]
+ defaults ["!requiretty", "env_reset"]
+end
+
+sudo "bob" do
+ user "bob"
+end
+
+sudo "invalid.user" do
+ user "bob"
+end
+
+sudo "tilde-invalid~user" do
+ user "bob"
+ action :create
+end
+
+# Like above, but ensure the tilde at the front gets munged as well
+sudo "~bob" do
+ user "bob"
+end
+
+sudo "alice" do
+ user "alice"
+ command_aliases [{ name: "STARTSSH", command_list: ["/etc/init.d/ssh start", "/etc/init.d/ssh restart", "! /etc/init.d/ssh stop"] }]
+ commands ["STARTSSH"]
+end
+
+sudo "git" do
+ user "git"
+ runas "phabricator"
+ nopasswd true
+ setenv true
+ commands ["/usr/bin/git-upload-pack", "/usr/bin/git-receive-pack"]
+end
+
+sudo "jane" do
+ user "jane"
+ noexec true
+ commands ["/usr/bin/less"]
+end
+
+sudo "rbenv" do
+ env_keep_add %w{PATH RBENV_ROOT RBENV_VERSION}
+end
+
+sudo "java_home" do
+ env_keep_subtract ["JAVA_HOME"]
+end
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/_sysctl.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_sysctl.rb
index 8c644e01c6..b5943180d0 100644
--- a/kitchen-tests/cookbooks/end_to_end/recipes/_sysctl.rb
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/_sysctl.rb
@@ -8,5 +8,14 @@ sysctl "vm.swappiness" do
end
sysctl "kernel.msgmax" do
+ value 9000
+end
+
+sysctl "kernel.msgmax" do
+ action :remove
+end
+
+sysctl_param "bogus.sysctl_val" do
+ value 9000
action :remove
end \ No newline at end of file
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/_yum.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_yum.rb
new file mode 100644
index 0000000000..f6f48a89c9
--- /dev/null
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/_yum.rb
@@ -0,0 +1,16 @@
+bash "disable yum metadata caching" do
+ code <<-EOH
+ echo http_caching=packages >> /etc/yum.conf
+ EOH
+ only_if { File.exist?("/etc/yum.conf") && File.readlines("/etc/yum.conf").grep(/http_caching=packages/).empty? }
+end
+
+yum_repository "epel" do
+ enabled true
+ description "Extra Packages for Enterprise Linux #{node["platform_version"].to_i} - $basearch"
+ failovermethod "priority"
+ gpgkey "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-#{node["platform_version"].to_i}"
+ gpgcheck true
+ mirrorlist "https://mirrors.fedoraproject.org/metalink?repo=epel-#{node["platform_version"].to_i}&arch=$basearch"
+ only_if { rhel? }
+end \ No newline at end of file
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/default.rb b/kitchen-tests/cookbooks/end_to_end/recipes/default.rb
index b8ab746f55..f175474d46 100644
--- a/kitchen-tests/cookbooks/end_to_end/recipes/default.rb
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/default.rb
@@ -11,27 +11,24 @@ apt_update
chef_sleep "2"
-timezone "UTC"
+execute "sleep 1"
-if platform_family?("rhel", "fedora", "amazon")
- include_recipe "selinux::disabled"
+execute "sleep 1 second" do
+ command "sleep 1"
+ live_stream true
end
-bash "disable yum metadata caching" do
- code <<-EOH
- echo http_caching=packages >> /etc/yum.conf
- EOH
- only_if { File.exist?("/etc/yum.conf") && File.readlines("/etc/yum.conf").grep(/http_caching=packages/).empty? }
+execute "sensitive sleep" do
+ command "sleep 1"
+ sensitive true
end
-yum_repository "epel" do
- enabled true
- description "Extra Packages for Enterprise Linux #{node["platform_version"].to_i} - $basearch"
- failovermethod "priority"
- gpgkey "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-#{node["platform_version"].to_i}"
- gpgcheck true
- mirrorlist "https://mirrors.fedoraproject.org/metalink?repo=epel-#{node["platform_version"].to_i}&arch=$basearch"
- only_if { rhel? }
+timezone "UTC"
+
+include_recipe "::_yum" if platform_family?("rhel")
+
+if platform_family?("rhel", "fedora", "amazon")
+ include_recipe "selinux::disabled"
end
build_essential do
@@ -51,18 +48,6 @@ end
ssh_known_hosts_entry "github.com"
-sudo "sysadmins" do
- group ["sysadmin", "%superadmin"]
- nopasswd true
-end
-
-sudo "some_person" do
- nopasswd true
- user "some_person"
- commands ["/opt/chef/bin/chef-client"]
- env_keep_add %w{PATH RBENV_ROOT RBENV_VERSION}
-end
-
include_recipe "chef-client::delete_validation"
include_recipe "chef-client::config"
@@ -122,9 +107,10 @@ locale "set system locale" do
only_if { debian? }
end
+include_recipe "::_apt" if platform_family?("debian")
include_recipe "::_chef-vault" unless includes_recipe?("end_to_end::chef-vault")
+include_recipe "::_sudo"
include_recipe "::_sysctl"
-include_recipe "::_apt_preference"
include_recipe "::_alternatives"
include_recipe "::_cron"
include_recipe "::_ohai_hint"
diff --git a/scripts/bk_tests/bk_linux_exec.sh b/scripts/bk_tests/bk_linux_exec.sh
index d7a1c12320..a09b121000 100755
--- a/scripts/bk_tests/bk_linux_exec.sh
+++ b/scripts/bk_tests/bk_linux_exec.sh
@@ -33,6 +33,7 @@ echo "--- Installing Ruby 2.7.1"
/opt/asdf/bin/asdf global ruby 2.7.1
# Update Gems
+echo "--- Installing Gems"
echo 'gem: --no-document' >> ~/.gemrc
gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2)
gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2) --force