Skip to content

Commit 04e505a

Browse files
authored
Merge pull request #716 from StatensPensjonskasse/beakertest-different-repo-versions
Test supported repo versions with gha
2 parents a240721 + a955038 commit 04e505a

File tree

10 files changed

+130
-84
lines changed

10 files changed

+130
-84
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ jobs:
1919
puppet:
2020
name: Puppet
2121
uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v2
22+
with:
23+
beaker_facter: 'mongodb_repo_version:MongoDB:4.4,5.0'

.sync.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
---
22
appveyor.yml:
33
delete: true
4+
.github/workflows/ci.yml:
5+
beaker_facter: 'mongodb_repo_version:MongoDB:4.4,5.0'

spec/acceptance/database_spec.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22

33
require 'spec_helper_acceptance'
44

5-
describe 'mongodb_database' do
5+
repo_version = ENV.fetch('BEAKER_FACTER_mongodb_repo_version', nil)
6+
repo_ver_param = "repo_version => '#{repo_version}'" if repo_version
7+
8+
describe 'mongodb_database', if: supported_version?(default[:platform], repo_version) do
69
describe 'creating a database' do
710
context 'with default port' do
811
it 'compiles with no errors' do
912
pp = <<-EOS
10-
class { 'mongodb::server': }
13+
class { 'mongodb::globals':
14+
#{repo_ver_param}
15+
}
16+
-> class { 'mongodb::server': }
1117
-> class { 'mongodb::client': }
1218
-> mongodb::db { 'testdb1':
1319
user => 'testuser',
@@ -31,7 +37,10 @@ class { 'mongodb::server': }
3137
context 'with custom port' do
3238
it 'works with no errors' do
3339
pp = <<-EOS
34-
class { 'mongodb::server':
40+
class { 'mongodb::globals':
41+
#{repo_ver_param}
42+
}
43+
-> class { 'mongodb::server':
3544
port => 27018,
3645
}
3746
-> class { 'mongodb::client': }

spec/acceptance/mongos_spec.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22

33
require 'spec_helper_acceptance'
44

5-
describe 'mongodb::mongos class' do
5+
repo_version = ENV.fetch('BEAKER_FACTER_mongodb_repo_version', nil)
6+
repo_ver_param = "repo_version => '#{repo_version}'" if repo_version
7+
8+
describe 'mongodb::mongos class', if: supported_version?(default[:platform], repo_version) do
69
package_name = 'mongodb-org-server'
710
config_file = '/etc/mongos.conf'
811

912
describe 'installation' do
1013
it 'works with no errors' do
1114
pp = <<-EOS
12-
class { 'mongodb::server':
15+
class { 'mongodb::globals':
16+
#{repo_ver_param}
17+
}
18+
-> class { 'mongodb::server':
1319
configsvr => true,
1420
replset => 'test',
1521
replset_members => ['127.0.0.1:27019'],

spec/acceptance/replset_spec.rb

Lines changed: 33 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22

33
require '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)

spec/acceptance/server_spec.rb

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@
22

33
require 'spec_helper_acceptance'
44

5-
describe 'mongodb::server class' do
5+
repo_version = ENV.fetch('BEAKER_FACTER_mongodb_repo_version', nil)
6+
repo_ver_param = "repo_version => '#{repo_version}'" if repo_version
7+
8+
describe 'mongodb::server class', if: supported_version?(default[:platform], repo_version) do
69
config_file = '/etc/mongod.conf'
710
service_name = 'mongod'
811
package_name = 'mongodb-org-server'
912

1013
describe 'installation' do
1114
it 'works with no errors' do
1215
pp = <<-EOS
13-
class { 'mongodb::server': }
16+
class { 'mongodb::globals':
17+
#{repo_ver_param}
18+
}
19+
-> class { 'mongodb::server': }
1420
-> class { 'mongodb::client': }
1521
EOS
1622

@@ -43,7 +49,10 @@ class { 'mongodb::server': }
4349
describe 'installation using custom port' do
4450
it 'change port to 27018' do
4551
pp = <<-EOS
46-
class { 'mongodb::server':
52+
class { 'mongodb::globals':
53+
#{repo_ver_param}
54+
}
55+
-> class { 'mongodb::server':
4756
port => 27018,
4857
}
4958
-> class { 'mongodb::client': }
@@ -78,7 +87,10 @@ class { 'mongodb::server':
7887
describe 'installation using authentication' do
7988
it 'works with no errors' do
8089
pp = <<-EOS
81-
class { 'mongodb::server':
90+
class { 'mongodb::globals':
91+
#{repo_ver_param}
92+
}
93+
-> class { 'mongodb::server':
8294
auth => true,
8395
create_admin => false,
8496
handle_creds => true,
@@ -88,7 +100,7 @@ class { 'mongodb::server':
88100
restart => true,
89101
set_parameter => ['enableLocalhostAuthBypass: true']
90102
}
91-
class { 'mongodb::client': }
103+
-> class { 'mongodb::client': }
92104
93105
mongodb_user { "User admin on db admin":
94106
ensure => present,
@@ -146,11 +158,11 @@ class { 'mongodb::client': }
146158
it 'uninstalls mongodb' do
147159
pp = <<-EOS
148160
class { 'mongodb::server':
149-
ensure => absent,
150-
package_ensure => absent,
151-
service_ensure => stopped,
152-
service_enable => false
153-
}
161+
ensure => absent,
162+
package_ensure => absent,
163+
service_ensure => stopped,
164+
service_enable => false
165+
}
154166
-> class { 'mongodb::client': ensure => absent, }
155167
EOS
156168
apply_manifest(pp, catch_failures: true)

spec/acceptance/sharding_spec.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22

33
require '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_shard resource' do
710
it 'configures the shard server' do
811
pp = <<-EOS
9-
class { 'mongodb::globals': }
12+
class { 'mongodb::globals':
13+
#{repo_ver_param}
14+
}
1015
-> class { 'mongodb::server':
1116
bind_ip => '0.0.0.0',
1217
replset => 'foo',
@@ -26,7 +31,9 @@ class { 'mongodb::client': }
2631

2732
it 'configures the router server' do
2833
pp = <<-EOS
29-
class { 'mongodb::globals': }
34+
class { 'mongodb::globals':
35+
#{repo_ver_param}
36+
}
3037
-> class { 'mongodb::server':
3138
bind_ip => '0.0.0.0',
3239
configsvr => true,

spec/acceptance/user_spec.rb

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22

33
require 'spec_helper_acceptance'
44

5-
describe 'mongodb_database' do
6-
context 'with default port' do
5+
repo_version = ENV.fetch('BEAKER_FACTER_mongodb_repo_version', nil)
6+
repo_ver_param = "repo_version => '#{repo_version}'" if repo_version
7+
8+
describe 'mongodb_user', if: supported_version?(default[:platform], repo_version) do
9+
context 'with default server port' do
710
it 'compiles with no errors' do
811
pp = <<-EOS
9-
class { 'mongodb::server': }
12+
class { 'mongodb::globals':
13+
#{repo_ver_param}
14+
}
15+
-> class { 'mongodb::server': }
1016
-> class { 'mongodb::client': }
1117
-> mongodb_database { 'testdb': ensure => present }
1218
->
@@ -29,7 +35,10 @@ class { 'mongodb::server': }
2935

3036
it 'removes a user with no errors' do
3137
pp = <<-EOS
32-
class { 'mongodb::server': }
38+
class { 'mongodb::globals':
39+
#{repo_ver_param}
40+
}
41+
-> class { 'mongodb::server': }
3342
-> class { 'mongodb::client': }
3443
-> mongodb_database { 'testdb': ensure => present }
3544
->
@@ -51,10 +60,13 @@ class { 'mongodb::server': }
5160
end
5261
end
5362

54-
context 'with custom port' do
63+
context 'with custom server port' do
5564
it 'works with no errors' do
5665
pp = <<-EOS
57-
class { 'mongodb::server': port => 27018 }
66+
class { 'mongodb::globals':
67+
#{repo_ver_param}
68+
}
69+
-> class { 'mongodb::server': port => 27018 }
5870
-> class { 'mongodb::client': }
5971
-> mongodb_database { 'testdb': ensure => present }
6072
->
@@ -79,7 +91,10 @@ class { 'mongodb::server': port => 27018 }
7991
context 'with the basic roles syntax' do
8092
it 'compiles with no errors' do
8193
pp = <<-EOS
82-
class { 'mongodb::server': }
94+
class { 'mongodb::globals':
95+
#{repo_ver_param}
96+
}
97+
-> class { 'mongodb::server': }
8398
-> class { 'mongodb::client': }
8499
-> mongodb_database { 'testdb': ensure => present }
85100
->
@@ -105,7 +120,10 @@ class { 'mongodb::server': }
105120
context 'with the new multidb role syntax' do
106121
it 'compiles with no errors' do
107122
pp = <<-EOS
108-
class { 'mongodb::server': }
123+
class { 'mongodb::globals':
124+
#{repo_ver_param}
125+
}
126+
-> class { 'mongodb::server': }
109127
-> class { 'mongodb::client': }
110128
-> mongodb_database { 'testdb': ensure => present }
111129
-> mongodb_database { 'testdb2': ensure => present }

spec/spec_helper_acceptance.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# frozen_string_literal: true
22

33
require 'voxpupuli/acceptance/spec_helper_acceptance'
4+
require 'support/acceptance/supported_version'
45

56
configure_beaker(modules: :metadata)

0 commit comments

Comments
 (0)