Skip to content

Commit 1e48c12

Browse files
committed
Fix acceptance tests
1 parent 59b796e commit 1e48c12

7 files changed

Lines changed: 344 additions & 515 deletions

File tree

.sync.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# the mongodb tests currently do not work on centos 7 or ubuntu 14.04
1+
# the mongodb tests currently do not work on MongoDB 3.x or newer
22
---
33
.travis.yml:
44
secure: "TcZjuTP5ooDXZNRnG1M+wqmT/Lqcg8CwZfLljGlDSjDEN2siUhflHf9A81q5XL17oN4BkQtPmLvu7d/7xijUOiqDWXG9PC/Xr3QsTTmjtEo5l2Ne7jO+HrXO0Ron6LjEy47PeUWVQs7JcLRQL1SpxlNkt/Xe7oSoL10PmP2GYJc="
5-
docker_sets: []
5+
docker_sets:
6+
- centos7
67
appveyor.yml:
78
delete: true
89
spec/spec_helper.rb:

.travis.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ matrix:
2525
- rvm: 2.4.4
2626
bundler_args: --without system_tests development release
2727
env: PUPPET_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes
28+
- rvm: 2.5.1
29+
bundler_args: --without development release
30+
dist: trusty
31+
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos7-64{hypervisor=docker\,hostname=centos7-64.example.com} CHECK=beaker
32+
services: docker
33+
sudo: required
34+
- rvm: 2.5.1
35+
bundler_args: --without development release
36+
dist: trusty
37+
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos7-64{hypervisor=docker\,hostname=centos7-64.example.com} CHECK=beaker
38+
services: docker
39+
sudo: required
2840
branches:
2941
only:
3042
- master

spec/acceptance/database_spec.rb

Lines changed: 45 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,54 @@
11
require 'spec_helper_acceptance'
22

33
describe 'mongodb_database' do
4-
case fact('osfamily')
5-
when 'RedHat'
6-
version = "'2.6.6-1'"
7-
when 'Debian'
8-
version = "'2.6.6'"
9-
end
10-
shared_examples 'normal tests' do |tengen, ver|
11-
context "when manage_package_repo is #{tengen} and version is #{ver}" do
12-
describe 'creating a database' do
13-
context 'with default port' do
14-
after :all do
15-
puts "XXX uninstalls mongodb because changing the port with tengen doesn't work because they have a crappy init script"
16-
pp = <<-EOS
17-
class {'mongodb::globals': manage_package_repo => #{tengen}, }
18-
-> class { 'mongodb::server':
19-
ensure => absent,
20-
package_ensure => absent,
21-
service_ensure => stopped,
22-
service_enable => false
23-
}
24-
-> class { 'mongodb::client': ensure => absent, }
25-
EOS
26-
apply_manifest(pp, catch_failures: true)
27-
end
28-
it 'compiles with no errors' do
29-
pp = <<-EOS
30-
class { 'mongodb::globals': manage_package_repo => #{tengen}, version => #{ver.nil? ? 'undef' : ver} }
31-
-> class { 'mongodb::server': }
32-
-> class { 'mongodb::client': }
33-
-> mongodb::db { 'testdb1':
34-
user => 'testuser',
35-
password => 'testpass',
36-
}
37-
-> mongodb::db { 'testdb2':
38-
user => 'testuser',
39-
password => 'testpass',
40-
}
41-
EOS
42-
apply_manifest(pp, catch_failures: true)
43-
end
44-
pending('setting password is broken, non idempotent') do
45-
apply_manifest(pp, catch_changes: true)
46-
end
47-
it 'creates the databases' do
48-
shell("mongo testdb1 --eval 'printjson(db.getMongo().getDBs())'")
49-
shell("mongo testdb2 --eval 'printjson(db.getMongo().getDBs())'")
50-
end
51-
end
4+
describe 'creating a database' do
5+
context 'with default port' do
6+
it 'compiles with no errors' do
7+
pp = <<-EOS
8+
class { 'mongodb::server': }
9+
-> class { 'mongodb::client': }
10+
-> mongodb::db { 'testdb1':
11+
user => 'testuser',
12+
password => 'testpass',
13+
}
14+
-> mongodb::db { 'testdb2':
15+
user => 'testuser',
16+
password => 'testpass',
17+
}
18+
EOS
19+
apply_manifest(pp, catch_failures: true)
20+
apply_manifest(pp, catch_changes: true)
21+
end
22+
it 'creates the databases' do
23+
shell("mongo testdb1 --eval 'printjson(db.getMongo().getDBs())'")
24+
shell("mongo testdb2 --eval 'printjson(db.getMongo().getDBs())'")
25+
end
26+
end
5227

53-
# MODULES-878
54-
context 'with custom port' do
55-
after :all do
56-
puts "XXX uninstalls mongodb because changing the port with tengen doesn't work because they have a crappy init script"
57-
pp = <<-EOS
58-
class {'mongodb::globals': manage_package_repo => #{tengen}, }
59-
-> class { 'mongodb::server':
60-
ensure => absent,
61-
package_ensure => absent,
62-
service_ensure => stopped,
63-
service_enable => false
64-
}
65-
-> class { 'mongodb::client': ensure => absent, }
66-
EOS
67-
apply_manifest(pp, catch_failures: true)
68-
end
69-
it 'works with no errors' do
70-
pp = <<-EOS
71-
class { 'mongodb::globals': manage_package_repo => #{tengen}, }
72-
-> class { 'mongodb::server': port => 27018 }
73-
-> class { 'mongodb::client': }
74-
-> mongodb::db { 'testdb1':
75-
user => 'testuser',
76-
password => 'testpass',
77-
}
78-
-> mongodb::db { 'testdb2':
79-
user => 'testuser',
80-
password => 'testpass',
81-
}
82-
EOS
28+
context 'with custom port' do
29+
it 'works with no errors' do
30+
pp = <<-EOS
31+
class { 'mongodb::server':
32+
port => 27018,
33+
}
34+
-> class { 'mongodb::client': }
35+
-> mongodb::db { 'testdb1':
36+
user => 'testuser',
37+
password => 'testpass',
38+
}
39+
-> mongodb::db { 'testdb2':
40+
user => 'testuser',
41+
password => 'testpass',
42+
}
43+
EOS
8344

84-
apply_manifest(pp, catch_failures: true)
85-
end
86-
pending('setting password is broken, non idempotent') do
87-
apply_manifest(pp, catch_changes: true)
88-
end
89-
it 'creates the database' do
90-
shell("mongo testdb1 --port 27018 --eval 'printjson(db.getMongo().getDBs())'")
91-
shell("mongo testdb2 --port 27018 --eval 'printjson(db.getMongo().getDBs())'")
92-
end
93-
end
45+
apply_manifest(pp, catch_failures: true)
46+
apply_manifest(pp, catch_changes: true)
47+
end
48+
it 'creates the database' do
49+
shell("mongo testdb1 --port 27018 --eval 'printjson(db.getMongo().getDBs())'")
50+
shell("mongo testdb2 --port 27018 --eval 'printjson(db.getMongo().getDBs())'")
9451
end
9552
end
9653
end
97-
98-
it_behaves_like 'normal tests', false, nil
99-
it_behaves_like 'normal tests', true, nil # This will give a key-value config file even though the version will be 2.6
100-
it_behaves_like 'normal tests', true, version # This will give the YAML config file for 2.6
10154
end

spec/acceptance/mongos_spec.rb

Lines changed: 70 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,89 @@
11
require 'spec_helper_acceptance'
22

33
describe 'mongodb::mongos class' do
4-
shared_examples 'normal tests' do |tengen|
5-
package_name = if tengen
6-
'mongodb-org-mongos'
7-
else
8-
'mongodb-server'
9-
end
10-
service_name = 'mongos'
11-
config_file = '/etc/mongodb-shard.conf'
4+
config_file = if fact('osfamily') == 'RedHat'
5+
'/etc/mongos.conf'
6+
else
7+
'/etc/mongodb-shard.conf'
8+
end
129

13-
client_name = 'mongo --version'
10+
describe 'installation' do
11+
it 'works with no errors' do
12+
pp = <<-EOS
13+
class { 'mongodb::server':
14+
configsvr => true,
15+
}
16+
-> class { 'mongodb::client': }
17+
-> class { 'mongodb::mongos':
18+
configdb => ['127.0.0.1:27019'],
19+
}
20+
EOS
1421

15-
context "default parameters with 10gen => #{tengen}" do
16-
after :all do
17-
if tengen
18-
puts "XXX uninstalls mongodb and mongos because changing the port with tengen doesn't work because they have a crappy init script"
19-
pp = <<-EOS
20-
class {'mongodb::globals': manage_package_repo => #{tengen}, }
21-
-> class { 'mongodb::server':
22-
ensure => absent,
23-
package_ensure => absent,
24-
service_ensure => stopped,
25-
service_enable => false
26-
}
27-
-> class { 'mongodb::client': ensure => absent, }
28-
-> class { 'mongodb::mongos':
29-
ensure => absent,
30-
package_ensure => absent,
31-
service_ensure => stopped,
32-
service_enable => false
33-
}
34-
EOS
35-
apply_manifest(pp, catch_failures: true)
36-
end
37-
end
22+
apply_manifest(pp, catch_failures: true)
23+
apply_manifest(pp, catch_changes: true)
24+
end
3825

39-
it 'works with no errors' do
40-
pp = <<-EOS
41-
class { 'mongodb::globals': manage_package_repo => #{tengen},
42-
} -> class { 'mongodb::server':
43-
configsvr => true,
44-
}
45-
-> class { 'mongodb::client': }
46-
-> class { 'mongodb::mongos':
47-
configdb => ['127.0.0.1:27019'],
48-
}
49-
EOS
26+
describe package('mongodb-server') do
27+
it { is_expected.to be_installed }
28+
end
5029

51-
apply_manifest(pp, catch_failures: true)
52-
apply_manifest(pp, catch_changes: true)
53-
end
30+
describe file(config_file) do
31+
it { is_expected.to be_file }
32+
end
5433

55-
describe package(package_name) do
56-
it { is_expected.to be_installed }
57-
end
34+
describe service('mongos') do
35+
it { is_expected.to be_enabled }
36+
it { is_expected.to be_running }
37+
end
5838

59-
describe file(config_file) do
60-
it { is_expected.to be_file }
61-
end
39+
describe port(27_017) do
40+
it { is_expected.to be_listening }
41+
end
6242

63-
describe service(service_name) do
64-
it { is_expected.to be_enabled }
65-
it { is_expected.to be_running }
66-
end
43+
describe port(27_019) do
44+
it { is_expected.to be_listening }
45+
end
6746

68-
describe port(27_017) do
69-
it { is_expected.to be_listening }
70-
end
47+
describe command('mongo --version') do
48+
its(:exit_status) { is_expected.to eq 0 }
49+
end
50+
end
51+
52+
describe 'uninstalling' do
53+
it 'uninstalls mongodb' do
54+
pp = <<-EOS
55+
class { 'mongodb::server':
56+
ensure => absent,
57+
package_ensure => absent,
58+
service_ensure => stopped,
59+
service_enable => false
60+
}
61+
-> class { 'mongodb::client':
62+
ensure => absent,
63+
}
64+
-> class { 'mongodb::mongos':
65+
package_ensure => 'purged',
66+
}
67+
EOS
68+
apply_manifest(pp, catch_failures: true)
69+
apply_manifest(pp, catch_changes: true)
70+
end
7171

72-
describe port(27_019) do
73-
it { is_expected.to be_listening }
74-
end
72+
describe package('mongodb-server') do
73+
it { is_expected.not_to be_installed }
74+
end
7575

76-
describe command(client_name) do
77-
describe '#exit_status' do
78-
subject { super().exit_status }
76+
describe service('mongos') do
77+
it { is_expected.not_to be_enabled }
78+
it { is_expected.not_to be_running }
79+
end
7980

80-
it { is_expected.to eq 0 }
81-
end
82-
end
81+
describe port(27_017) do
82+
it { is_expected.not_to be_listening }
8383
end
8484

85-
describe "uninstalling with 10gen => #{tengen}" do
86-
it 'uninstalls mongodb' do
87-
pp = <<-EOS
88-
class {'mongodb::globals': manage_package_repo => #{tengen}, }
89-
-> class { 'mongodb::server':
90-
ensure => absent,
91-
package_ensure => absent,
92-
service_ensure => stopped,
93-
service_enable => false
94-
}
95-
-> class { 'mongodb::client': ensure => absent, }
96-
-> class { 'mongodb::mongos':
97-
package_ensure => 'purged',
98-
}
99-
EOS
100-
apply_manifest(pp, catch_failures: true)
101-
end
85+
describe port(27_019) do
86+
it { is_expected.not_to be_listening }
10287
end
10388
end
104-
105-
it_behaves_like 'normal tests', false
106-
it_behaves_like 'normal tests', true
10789
end

0 commit comments

Comments
 (0)