summaryrefslogtreecommitdiff
path: root/kitchen-tests/test
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-05-24 13:50:05 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2016-05-24 13:50:05 -0700
commit040e7473b458d1c917291d9857c15848a647e126 (patch)
tree4f97d2561899e9ff854a66facb763658a36949e4 /kitchen-tests/test
parent37668e4b9a96b60c0a7ea5e7f9843c935163974a (diff)
downloadchef-040e7473b458d1c917291d9857c15848a647e126.tar.gz
convert kitchen tests to docker + other fixes
- use kitchen-dokken instead of kitchen-ec2 - add tests for gem metadata + chef-sugar - convert to inspec and add some tests this disables the webapp stuff completely and its testing for now, that needs to be updated to more modern httpd/mysql cookbooks and have its testing converted to inspec. more O/S distros are also in the pipeline.
Diffstat (limited to 'kitchen-tests/test')
-rw-r--r--kitchen-tests/test/integration/webapp/default_spec.rb125
-rw-r--r--kitchen-tests/test/integration/webapp/serverspec/Gemfile4
-rw-r--r--kitchen-tests/test/integration/webapp/serverspec/Gemfile.lock19
-rw-r--r--kitchen-tests/test/integration/webapp/serverspec/localhost/default_spec.rb127
4 files changed, 125 insertions, 150 deletions
diff --git a/kitchen-tests/test/integration/webapp/default_spec.rb b/kitchen-tests/test/integration/webapp/default_spec.rb
new file mode 100644
index 0000000000..fbd1e0e782
--- /dev/null
+++ b/kitchen-tests/test/integration/webapp/default_spec.rb
@@ -0,0 +1,125 @@
+#describe port(80) do
+# it { should be_listening }
+# its('processes') {should include 'http'}
+#end
+#
+#describe command("curl http://localhost/index.html") do
+# its("stdout") { should match /Hello, World!/ }
+#end
+
+case os[:family]
+when "debian", "ubuntu"
+ ssh_package = "openssh-client"
+ ssh_service = "ssh"
+ ntp_service = "ntp"
+when "centos", "redhat", "fedora"
+ ssh_package = "openssh-clients"
+ ssh_service = "sshd"
+ ntp_service = "ntpd"
+else
+ raise "i don't know the family #{os[:family]}"
+end
+
+describe package("nscd") do
+ it { should be_installed }
+end
+
+describe service("nscd") do
+ # broken?
+ # it { should be_enabled }
+ it { should be_installed }
+ it { should be_running }
+end
+
+describe package(ssh_package) do
+ it { should be_installed }
+end
+
+describe service(ssh_service) do
+ it { should be_enabled }
+ it { should be_installed }
+ it { should be_running }
+end
+
+describe sshd_config do
+ its("Protocol") { should cmp 2 }
+ its("GssapiAuthentication") { should cmp "no" }
+ its("UseDns") { should cmp "no" }
+end
+
+describe ssh_config do
+ its("StrictHostKeyChecking") { should cmp "no" }
+ its("GssapiAuthentication") { should cmp "no" }
+end
+
+describe package("ntp") do
+ it { should be_installed }
+end
+
+describe service(ntp_service) do
+ # broken?
+ # it { should be_enabled }
+ it { should be_installed }
+ it { should be_running }
+end
+
+describe service("chef-client") do
+ it { should be_enabled }
+ it { should be_installed }
+ it { should be_running }
+end
+
+describe file("/etc/resolv.conf") do
+ its("content") { should match /search\s+chef.io/ }
+ its("content") { should match /nameserver\s+8.8.8.8/ }
+ its("content") { should match /nameserver\s+8.8.4.4/ }
+end
+
+describe package("gcc") do
+ it { should be_installed }
+end
+
+describe package("flex") do
+ it { should be_installed }
+end
+
+describe package("bison") do
+ it { should be_installed }
+end
+
+describe package("autoconf") do
+ it { should be_installed }
+end
+
+%w{lsof tcpdump strace zsh dmidecode ltrace bc curl wget telnet subversion git traceroute htop tmux s3cmd sysbench }.each do |pkg|
+ describe package pkg do
+ it { should be_installed }
+ end
+end
+
+if %w{debian ubuntu}.include?(os[:family])
+ describe apt("http://us-west-2.ec2.archive.ubuntu.com/ubuntu") do
+ it { should be_enabled }
+ it { should exist }
+ end
+end
+
+describe etc_group.where(group_name: "sysadmin") do
+ its("users") { should include "adam" }
+ its("gids") { should eq [2300] }
+end
+
+describe passwd.users("adam") do
+ its("uids") { should eq ["666"] }
+end
+
+describe ntp_conf do
+ its("server") { should_not eq nil }
+end
+
+# busted inside of docker containers?
+describe port(22) do
+ it { should be_listening }
+ its("protocols") { should include "tcp" }
+ its("processes") { should eq ["sshd"] }
+end
diff --git a/kitchen-tests/test/integration/webapp/serverspec/Gemfile b/kitchen-tests/test/integration/webapp/serverspec/Gemfile
deleted file mode 100644
index eef1450f7a..0000000000
--- a/kitchen-tests/test/integration/webapp/serverspec/Gemfile
+++ /dev/null
@@ -1,4 +0,0 @@
-# This Gemfile is only needed so that busser will install gems it needs for serverspec_helper.rb to work
-source "https://rubygems.org"
-
-gem "ffi-yajl", "~> 1.1" # Go away, JSON gem
diff --git a/kitchen-tests/test/integration/webapp/serverspec/Gemfile.lock b/kitchen-tests/test/integration/webapp/serverspec/Gemfile.lock
deleted file mode 100644
index ac6c11f28c..0000000000
--- a/kitchen-tests/test/integration/webapp/serverspec/Gemfile.lock
+++ /dev/null
@@ -1,19 +0,0 @@
-GEM
- remote: https://rubygems.org/
- specs:
- ffi (1.9.10)
- ffi (1.9.10-x86-mingw32)
- ffi-yajl (1.4.0)
- ffi (~> 1.5)
- libyajl2 (~> 1.2)
- libyajl2 (1.2.0)
-
-PLATFORMS
- ruby
- x86-mingw32
-
-DEPENDENCIES
- ffi-yajl (~> 1.1)
-
-BUNDLED WITH
- 1.11.2
diff --git a/kitchen-tests/test/integration/webapp/serverspec/localhost/default_spec.rb b/kitchen-tests/test/integration/webapp/serverspec/localhost/default_spec.rb
deleted file mode 100644
index 992e4f7683..0000000000
--- a/kitchen-tests/test/integration/webapp/serverspec/localhost/default_spec.rb
+++ /dev/null
@@ -1,127 +0,0 @@
-
-require "net/http"
-require "uri"
-
-require "#{ENV['BUSSER_ROOT']}/../kitchen/data/serverspec_helper"
-
-describe "webapp::default", :end_to_end => true do
-
- describe "installed packages" do
- shared_examples_for "a package" do
- it "is installed" do
- expect(package(package_name)).to be_installed
- end
- end
-
- describe "#{property[:apache][:package]} package" do
- include_examples "a package" do
- let(:package_name) { property[:apache][:package] }
- end
- end
-
- describe "#{property[:mysql][:server_package]} package" do
- include_examples "a package" do
- let(:package_name) { property[:mysql][:server_package] }
- end
- end
-
- describe "#{property[:mysql][:client_package]} package" do
- include_examples "a package" do
- let(:package_name) { property[:mysql][:client_package] }
- end
- end
-
- describe "php package" do
- include_examples "a package" do
- let(:package_name) { property[:php][:package] }
- end
- end
- end
-
- describe "enabled/running services" do
- shared_examples_for "a service" do
- it "is enabled" do
- expect(service(service_name)).to be_enabled
- end
-
- it "is running" do
- expect(service(service_name)).to be_enabled
- end
- end
-
- describe "#{property[:apache][:service_name]} service" do
- include_examples "a service" do
- let(:service_name) { property[:apache][:service_name] }
- end
- end
-
- describe "mysql service" do
- include_examples "a service" do
- let(:service_name) { property[:mysql][:service_name] }
- end
- end
-
- end
-
- describe "mysql database" do
- let(:db_query) { "mysql -u root -pilikerandompasswordstoo -e \"#{statement}\"" }
- let(:statement) { "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='webapp'" }
- it "creates a database called 'webapp'" do
- expect(command(db_query).stdout).to match /webapp/
- end
-
- describe "mysql database user 'webapp'" do
- let(:statement) { "SELECT Host, Db FROM mysql.db WHERE User='webapp'\\G" }
- it "adds user 'webapp' to database 'webapp@localhost'" do
- expect(command(db_query).stdout).to match /Host: localhost\n Db: webapp/
- end
-
- describe "grants" do
- shared_examples_for "a privilege" do |priv|
- let(:statement) {
- "SELECT #{priv_query}" \
- " FROM mysql.db" \
- " WHERE Host='localhost' AND Db='webapp' AND User='webapp'\\G"
- }
- let(:priv_query) { "#{priv.capitalize}_priv" }
-
- it "has privilege #{priv} on 'webapp@localhost'" do
- expect(command(db_query).stdout).to match /#{priv_query}: Y/
- end
- end
-
- %w{select update insert delete create}.each do |priv|
- include_examples "a privilege", priv do
- end
- end
- end
- end
- end
-
- describe "generated webpages" do
- let(:get_response) { Net::HTTP.get_response(uri) }
- shared_examples_for "a webpage" do
- it "exists" do
- expect(get_response).to be_kind_of(Net::HTTPSuccess)
- end
-
- it "displays content" do
- expect(get_response.body).to include(content)
- end
- end
-
- describe "http://localhost/index.html" do
- include_examples "a webpage" do
- let(:uri) { URI.parse("http://localhost/index.html") }
- let(:content) { "Hello, World!" }
- end
- end
-
- describe "http://localhost/index.php" do
- include_examples "a webpage" do
- let(:uri) { URI.parse("http://localhost/index.php") }
- let(:content) { "Hello, World!" }
- end
- end
- end
-end