Skip to content

Commit

Permalink
replset integration tests: Manage server and replset in one puppet run.
Browse files Browse the repository at this point in the history
  • Loading branch information
h-haaks committed Apr 21, 2024
1 parent 1d32b19 commit f8b2735
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions spec/acceptance/replset_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,22 @@ class { 'mongodb::globals':
class { 'mongodb::globals':
#{repo_ver_param}
}
-> class { 'mongodb::client': }
-> class { 'mongodb::server':
bind_ip => ['0.0.0.0'],
replset => 'test',
}
-> class { 'mongodb::client': }
-> mongodb_replset { 'test':
members => [#{hosts.map { |x| "'#{x}:27017'" }.join(',')}],
}
EOS

apply_manifest_on(hosts.reverse, pp, catch_failures: true)
apply_manifest_on(hosts.reverse, pp, catch_changes: true)
apply_manifest_on(hosts, pp, catch_failures: true)
apply_manifest_on(hosts, pp, catch_changes: true)
end

it 'sets up the replset with puppet' do
pp = <<-EOS
mongodb_replset { 'test':
members => [#{hosts.map { |x| "'#{x}:27017'" }.join(',')}],
}
EOS
sleep(10)
apply_manifest_on(hosts_as('master'), pp, catch_failures: true)
on(hosts_as('master'), 'mongosh --quiet --eval "EJSON.stringify(rs.conf())"') do |r|
expect(r.stdout).to match %r{#{hosts[0]}:27017}
expect(r.stdout).to match %r{#{hosts[1]}:27017}
Expand Down Expand Up @@ -102,12 +99,12 @@ class { 'mongodb::globals':
class { 'mongodb::globals':
#{repo_ver_param}
}
-> class { 'mongodb::client': }
-> class { 'mongodb::server':
bind_ip => ['0.0.0.0'],
replset => 'test',
replset_members => [#{hosts.map { |x| "'#{x}:27017'" }.join(',')}],
}
-> class { 'mongodb::client': }
EOS

apply_manifest_on(hosts, pp, catch_failures: true)
Expand Down Expand Up @@ -177,6 +174,7 @@ class { 'mongodb::globals':
class { 'mongodb::globals':
#{repo_ver_param}
}
-> class { 'mongodb::client': }
-> class { 'mongodb::server':
admin_username => 'admin',
admin_password => 'password',
Expand All @@ -202,16 +200,7 @@ class { 'mongodb::globals':
nc1ohyB0lNt8lHf1U00mtgDSV3fwo5LkwhRi6d+bDBTL/C6MZETMLdyCqDlTdUWG
YXIsJ0gYcu9XG3mx10LbdPJvxSMg',
}
-> class { 'mongodb::client': }
EOS

apply_manifest_on(hosts.reverse, pp, catch_failures: true)
apply_manifest_on(hosts.reverse, pp, catch_changes: true)
end

it 'sets up the replset with puppet' do
pp = <<~EOS
mongodb_replset { 'test':
-> mongodb_replset { 'test':
members => [#{hosts.map { |x| "'#{x}:27017'" }.join(',')}],
}
-> mongodb_user { "User admin on db admin":
Expand All @@ -224,9 +213,12 @@ class { 'mongodb::globals':
'clusterManager', 'clusterMonitor', 'hostManager', 'root', 'restore',],
}
EOS
sleep(10)
apply_manifest_on(hosts_as('master'), pp, catch_failures: true)
apply_manifest_on(hosts_as('master'), pp, catch_changes: true)

apply_manifest_on(hosts, pp, catch_failures: true)
apply_manifest_on(hosts, pp, catch_changes: true)
end

it 'sets up the replset with puppet' do
on(hosts_as('master'), 'mongosh --quiet --eval "load(\'/root/.mongoshrc.js\');EJSON.stringify(rs.conf())"') do |r|
expect(r.stdout).to match %r{#{hosts[0]}:27017}
expect(r.stdout).to match %r{#{hosts[1]}:27017}
Expand Down

0 comments on commit f8b2735

Please sign in to comment.