|
1 | 1 | require 'spec_helper_acceptance' |
2 | 2 |
|
3 | 3 | 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 |
12 | 9 |
|
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 |
14 | 21 |
|
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 |
38 | 25 |
|
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 |
50 | 29 |
|
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 |
54 | 33 |
|
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 |
58 | 38 |
|
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 |
62 | 42 |
|
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 |
67 | 46 |
|
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 |
71 | 71 |
|
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 |
75 | 75 |
|
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 |
79 | 80 |
|
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 } |
83 | 83 | end |
84 | 84 |
|
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 } |
102 | 87 | end |
103 | 88 | end |
104 | | - |
105 | | - it_behaves_like 'normal tests', false |
106 | | - it_behaves_like 'normal tests', true |
107 | 89 | end |
0 commit comments