Add tests for mysql cookbook
authorTom Hughes <tom@compton.nu>
Thu, 27 Oct 2016 18:31:48 +0000 (19:31 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 27 Oct 2016 19:44:40 +0000 (20:44 +0100)
.kitchen.yml
cookbooks/mysql/metadata.rb
cookbooks/mysql/recipes/default.rb
test/integration/mysql/serverspec/mysql_spec.rb [new file with mode: 0644]

index e1328af..fede9d8 100644 (file)
@@ -34,6 +34,9 @@ suites:
   - name: munin-server
     run_list:
       - recipe[munin::server]
+  - name: mysql
+    run_list:
+      - recipe[mysql::default]
   - name: networking
     run_list:
       - recipe[networking::default]
index 547f5e4..18b2492 100644 (file)
@@ -5,6 +5,7 @@ license           "Apache 2.0"
 description       "Installs and configures mysql"
 long_description  IO.read(File.join(File.dirname(__FILE__), "README.md"))
 version           "1.0.0"
+depends           "munin"
 
 attribute "mysql",
   :display_name => "MySQL",
index bda0065..49087e6 100644 (file)
@@ -22,7 +22,7 @@ package "mysql-client"
 
 service "mysql" do
   action [:enable, :start]
-  supports :status => true, :restart => true, :reload => true
+  supports :status => true, :restart => true
 end
 
 template "/etc/mysql/conf.d/chef.cnf" do
@@ -30,7 +30,7 @@ template "/etc/mysql/conf.d/chef.cnf" do
   owner "root"
   group "root"
   mode 0o644
-  notifies :reload, "service[mysql]"
+  notifies :restart, "service[mysql]"
 end
 
 package "libdbd-mysql-perl"
diff --git a/test/integration/mysql/serverspec/mysql_spec.rb b/test/integration/mysql/serverspec/mysql_spec.rb
new file mode 100644 (file)
index 0000000..68e6358
--- /dev/null
@@ -0,0 +1,17 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe package("mysql-server") do
+  it { should be_installed }
+end
+
+describe service("mysql") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe port(3306) do
+  it { should be_listening }
+end