Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit 621b86c

Browse files
committed
Merge pull request #107 from patcon/feature/107-postgresql-test-suite
Add postgresql test suite
2 parents a0dc0f1 + 82fa409 commit 621b86c

File tree

12 files changed

+124
-1
lines changed

12 files changed

+124
-1
lines changed

.kitchen.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ default_attributes: &DEFAULT_ATTRIBUTES
3838
accept_oracle_download_terms: true
3939

4040
suites:
41-
- name: default # mysql
41+
- name: mysql # default
4242
run_list:
4343
- recipe[test-helper]
4444
- recipe[java]
@@ -49,3 +49,16 @@ suites:
4949
server_root_password: iloverandompasswordsbutthiswilldo
5050
server_repl_password: iloverandompasswordsbutthiswilldo
5151
server_debian_password: iloverandompasswordsbutthiswilldo
52+
- name: postgresql
53+
run_list:
54+
- recipe[test-helper]
55+
- recipe[java]
56+
- recipe[stash]
57+
attributes:
58+
<<: *DEFAULT_ATTRIBUTES
59+
stash:
60+
database:
61+
type: postgresql
62+
postgresql:
63+
password:
64+
postgres: iloverandompasswordsbutthiswilldo

test/integration/helpers/serverspec/spec_helper.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,26 @@
77

88
shared_examples_for 'stash' do
99
end
10+
11+
shared_examples_for 'database' do
12+
possible_bins = ['psql', 'mysql']
13+
14+
case $node['stash']['database']['type']
15+
when 'mysql'
16+
installed_bin = possible_bins.delete 'mysql'
17+
when 'postgresql'
18+
installed_bin = possible_bins.delete 'psql'
19+
end
20+
21+
# Correct DB should be available
22+
describe command("command -v #{installed_bin}") do
23+
its(:exit_status) { should eq 0 }
24+
end
25+
26+
# Other DBs should not be available
27+
possible_bins.each do |uninstalled_bin|
28+
describe command("command -v #{uninstalled_bin}") do
29+
its(:exit_status) { should_not eq 0 }
30+
end
31+
end
32+
end
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require 'spec_helper'
2+
3+
# Default tests are in spec_helper.
4+
describe 'mysql' do
5+
it_behaves_like 'stash'
6+
end
7+
8+
# Insert suite-specific tests below this line.
9+
describe file("#{$node['stash']['home_path']}/shared/stash-config.properties") do
10+
it { should be_file }
11+
it { should exist }
12+
end
13+
14+
describe file("#{$node['apache']['dir']}/sites-available/#{$node['stash']['apache2']['virtual_host_name']}.conf") do
15+
it { should be_file }
16+
it { should exist }
17+
end
18+
19+
describe service($node['apache']['service_name']) do
20+
it { should be_enabled }
21+
it { should be_running }
22+
end
23+
24+
describe port($node['stash']['apache2']['port']) do
25+
it { should be_listening }
26+
end
27+
28+
describe port($node['stash']['apache2']['ssl']['port']) do
29+
it { should be_listening }
30+
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require 'spec_helper'
2+
3+
# Default tests are in spec_helper.
4+
describe 'mysql' do
5+
it_behaves_like 'stash'
6+
end
7+
8+
# Insert suite-specific tests below this line.
9+
describe file("#{$node['stash']['home_path']}/shared/stash-config.properties") do
10+
it { should be_file }
11+
it { should exist }
12+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require 'spec_helper'
2+
3+
# Default tests are in spec_helper.
4+
describe 'mysql' do
5+
it_behaves_like 'database'
6+
end

test/integration/default/serverspec/linux_standalone_spec.rb renamed to test/integration/mysql/serverspec/linux_standalone_spec.rb

File renamed without changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
require 'spec_helper'
2+
3+
# Default tests are in spec_helper.
4+
describe 'mysql' do
5+
it_behaves_like 'stash'
6+
end
7+
8+
# Insert suite-specific tests below this line.
9+
describe service('stash') do
10+
it { should be_enabled }
11+
it { should be_running }
12+
end
13+
14+
describe port($node['stash']['tomcat']['port']) do
15+
it { should be_listening }
16+
end
17+
18+
describe port($node['stash']['tomcat']['ssl_port']) do
19+
it { should be_listening }
20+
end
File renamed without changes.

test/integration/default/serverspec/configuration_spec.rb renamed to test/integration/postgresql/serverspec/configuration_spec.rb

File renamed without changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require 'spec_helper'
2+
3+
# Default tests are in spec_helper.
4+
describe 'postgresql' do
5+
it_behaves_like 'database'
6+
end

0 commit comments

Comments
 (0)