22
33require 'spec_helper_acceptance'
44
5- if hosts . length > 1
5+ repo_version = ENV . fetch ( 'BEAKER_FACTER_mongodb_repo_version' , nil )
6+ repo_ver_param = "repo_version => '#{ repo_version } '" if repo_version
7+
8+ if hosts . length > 1 && supported_version? ( default [ :platform ] , repo_version )
69 describe 'mongodb_replset resource' do
710 after :all do
811 # Have to drop the DB to disable replsets for further testing
912 on hosts , %{mongo local --verbose --eval 'db.dropDatabase()'}
1013
1114 pp = <<-EOS
12- class { 'mongodb::globals': }
15+ class { 'mongodb::globals':
16+ #{ repo_ver_param }
17+ }
1318 -> class { 'mongodb::server':
1419 ensure => absent,
1520 package_ensure => absent,
@@ -27,7 +32,9 @@ class { 'mongodb::client':
2732
2833 it 'configures mongo on both nodes' do
2934 pp = <<-EOS
30- class { 'mongodb::globals': }
35+ class { 'mongodb::globals':
36+ #{ repo_ver_param }
37+ }
3138 -> class { 'mongodb::server':
3239 bind_ip => '0.0.0.0',
3340 replset => 'test',
@@ -79,7 +86,9 @@ class { 'mongodb::client': }
7986 on hosts , %{mongo local --verbose --eval 'db.dropDatabase()'}
8087
8188 pp = <<-EOS
82- class { 'mongodb::globals': }
89+ class { 'mongodb::globals':
90+ #{ repo_ver_param }
91+ }
8392 -> class { 'mongodb::server':
8493 ensure => absent,
8594 package_ensure => absent,
@@ -97,18 +106,17 @@ class { 'mongodb::client':
97106
98107 it 'configures mongo on both nodes' do
99108 pp = <<~EOS
100- class { 'mongodb::globals':
101- version => '2.6.9-1',
102- manage_package_repo => true
103- } ->
104- class { 'mongodb::server':
105- admin_username => 'admin',
106- admin_password => 'password',
107- auth => true,
108- bind_ip => '0.0.0.0',
109- replset => 'test',
110- keyfile => '/var/lib/mongodb/mongodb-keyfile',
111- key => '+dxlTrury7xtD0FRqFf3YWGnKqWAtlyauuemxuYuyz9POPUuX1Uj3chGU8MFMHa7
109+ class { 'mongodb::globals':
110+ #{ repo_ver_param }
111+ } ->
112+ class { 'mongodb::server':
113+ admin_username => 'admin',
114+ admin_password => 'password',
115+ auth => true,
116+ bind_ip => '0.0.0.0',
117+ replset => 'test',
118+ keyfile => '/var/lib/mongodb/mongodb-keyfile',
119+ key => '+dxlTrury7xtD0FRqFf3YWGnKqWAtlyauuemxuYuyz9POPUuX1Uj3chGU8MFMHa7
112120 UxASqex7NLMALQXHL+Th4T3dyb6kMZD7KiMcJObO4M+JLiX9drcTiifsDEgGMi7G
113121 vYn3pWSm5TTDrHJw7RNWfMHw3sHk0muGQcO+0dWv3sDJ6SiU8yOKRtYcTEA15GbP
114122 ReDZuHFy1T1qhk5NIt6pTtPGsZKSm2wAWIOa2f2IXvpeQHhjxP8aDFb3fQaCAqOD
@@ -124,11 +132,10 @@ class { 'mongodb::server':
124132 YG/QX0BmltAni8owgymFuyJgvr/gaRX4WHbKFD+9nKpqJ3ocuVNuCDsxDqLsJEME
125133 nc1ohyB0lNt8lHf1U00mtgDSV3fwo5LkwhRi6d+bDBTL/C6MZETMLdyCqDlTdUWG
126134 YXIsJ0gYcu9XG3mx10LbdPJvxSMg'
127-
128- }
129- if $::osfamily == 'RedHat' {
130- include mongodb::client
131- }
135+ }
136+ if $::osfamily == 'RedHat' {
137+ include mongodb::client
138+ }
132139 EOS
133140
134141 apply_manifest_on ( hosts . reverse , pp , catch_failures : true )
@@ -137,43 +144,11 @@ class { 'mongodb::server':
137144
138145 it 'sets up the replset with puppet' do
139146 pp = <<~EOS
140- class { 'mongodb::globals':
141- version => '2.6.9-1',
142- manage_package_repo => true
143- } ->
144- class { 'mongodb::server':
145- create_admin => true,
146- admin_username => 'admin',
147- admin_password => 'password',
148- auth => true,
149- bind_ip => '0.0.0.0',
150- replset => 'test',
151- keyfile => '/var/lib/mongodb/mongodb-keyfile',
152- key => '+dxlTrury7xtD0FRqFf3YWGnKqWAtlyauuemxuYuyz9POPUuX1Uj3chGU8MFMHa7
153- UxASqex7NLMALQXHL+Th4T3dyb6kMZD7KiMcJObO4M+JLiX9drcTiifsDEgGMi7G
154- vYn3pWSm5TTDrHJw7RNWfMHw3sHk0muGQcO+0dWv3sDJ6SiU8yOKRtYcTEA15GbP
155- ReDZuHFy1T1qhk5NIt6pTtPGsZKSm2wAWIOa2f2IXvpeQHhjxP8aDFb3fQaCAqOD
156- R7hrimqq0Nickfe8RLA89iPXyadr/YeNBB7w7rySatQBzwIbBUVGNNA5cxCkwyx9
157- E5of3xi7GL9xNxhQ8l0JEpofd4H0y0TOfFDIEjc7cOnYlKAHzBgog4OcFSILgUaF
158- kHuTMtv0pj+MMkW2HkeXETNII9XE1+JiZgHY08G7yFEJy87ttUoeKmpbI6spFz5U
159- 4K0amj+N6SOwXaS8uwp6kCqay0ERJLnw+7dKNKZIZdGCrrBxcZ7wmR/wLYrxvHhZ
160- QpeXTxgD5ebwCR0cf3Xnb5ql5G/HHKZDq8LTFHwELNh23URGPY7K7uK+IF6jSEhq
161- V2H3HnWV9teuuJ5he9BB/pLnyfjft6KUUqE9HbaGlX0f3YBk/0T3S2ESN4jnfRTQ
162- ysAKvQ6NasXkzqXktu8X4fS5QNqrFyqKBZSWxttfJBKXnT0TxamCKLRx4AgQglYo
163- 3KRoyfxXx6G+AjP1frDJxFAFEIgEFqRk/FFuT/y9LpU+3cXYX1Gt6wEatgmnBM3K
164- g+Bybk5qHv1b7M8Tv9/I/BRXcpLHeIkMICMY8sVPGmP8xzL1L3i0cws8p5h0zPBa
165- YG/QX0BmltAni8owgymFuyJgvr/gaRX4WHbKFD+9nKpqJ3ocuVNuCDsxDqLsJEME
166- nc1ohyB0lNt8lHf1U00mtgDSV3fwo5LkwhRi6d+bDBTL/C6MZETMLdyCqDlTdUWG
167- YXIsJ0gYcu9XG3mx10LbdPJvxSMg'
168- }
169- if $::osfamily == 'RedHat' {
170- include mongodb::client
171- }
172- mongodb_replset { 'test':
173- auth_enabled => true,
174- members => [#{ hosts . map { |x | "'#{ x } :27017'" } . join ( ',' ) } ],
175- before => Mongodb_user['admin']
176- }
147+ mongodb_replset { 'test':
148+ auth_enabled => true,
149+ members => [#{ hosts . map { |x | "'#{ x } :27017'" } . join ( ',' ) } ],
150+ before => Mongodb_user['admin']
151+ }
177152 EOS
178153 apply_manifest_on ( hosts_as ( 'master' ) , pp , catch_failures : true )
179154 apply_manifest_on ( hosts_as ( 'master' ) , pp , catch_changes : true )
0 commit comments