6
6
describe 'mongodb_replset resource' do
7
7
after :all do
8
8
# Have to drop the DB to disable replsets for further testing
9
- on hosts , %{mongo local --verbose --eval 'db.dropDatabase()'}
9
+ on hosts , %{mongosh local --verbose --eval 'db.dropDatabase()'}
10
10
11
11
pp = <<-EOS
12
12
class { 'mongodb::globals': }
@@ -48,26 +48,26 @@ class { 'mongodb::client': }
48
48
}
49
49
EOS
50
50
apply_manifest_on ( hosts_as ( 'master' ) , pp , catch_failures : true )
51
- on ( hosts_as ( 'master' ) , 'mongo --quiet --eval "EJSON.stringify(rs.conf())"' ) do |r |
51
+ on ( hosts_as ( 'master' ) , 'mongosh --quiet --eval "EJSON.stringify(rs.conf())"' ) do |r |
52
52
expect ( r . stdout ) . to match %r{#{ hosts [ 0 ] } :27017}
53
53
expect ( r . stdout ) . to match %r{#{ hosts [ 1 ] } :27017}
54
54
end
55
55
end
56
56
57
57
it 'inserts data on the master' do
58
58
sleep ( 30 )
59
- on hosts_as ( 'master' ) , %{mongo --verbose --eval 'db.test.save({name:"test1",value:"some value"})'}
59
+ on hosts_as ( 'master' ) , %{mongosh --verbose --eval 'db.test.save({name:"test1",value:"some value"})'}
60
60
end
61
61
62
62
it 'checks the data on the master' do
63
- on hosts_as ( 'master' ) , %{mongo --verbose --eval 'EJSON.stringify(db.test.findOne({name:"test1"}))'} do |r |
63
+ on hosts_as ( 'master' ) , %{mongosh --verbose --eval 'EJSON.stringify(db.test.findOne({name:"test1"}))'} do |r |
64
64
expect ( r . stdout ) . to match %r{some value}
65
65
end
66
66
end
67
67
68
68
it 'checks the data on the slave' do
69
69
sleep ( 10 )
70
- on hosts_as ( 'slave' ) , %{mongo --verbose --eval 'db.getMongo().setReadPref("primaryPreferred"); EJSON.stringify(db.test.findOne({name:"test1"}))'} do |r |
70
+ on hosts_as ( 'slave' ) , %{mongosh --verbose --eval 'db.getMongo().setReadPref("primaryPreferred"); EJSON.stringify(db.test.findOne({name:"test1"}))'} do |r |
71
71
expect ( r . stdout ) . to match %r{some value}
72
72
end
73
73
end
@@ -76,7 +76,7 @@ class { 'mongodb::client': }
76
76
describe 'mongodb_replset resource with auth => true' do
77
77
after :all do
78
78
# Have to drop the DB to disable replsets for further testing
79
- on hosts , %{mongo local --verbose --eval 'db.dropDatabase()'}
79
+ on hosts , %{mongosh local --verbose --eval 'db.dropDatabase()'}
80
80
81
81
pp = <<-EOS
82
82
class { 'mongodb::globals': }
@@ -177,26 +177,26 @@ class { 'mongodb::server':
177
177
EOS
178
178
apply_manifest_on ( hosts_as ( 'master' ) , pp , catch_failures : true )
179
179
apply_manifest_on ( hosts_as ( 'master' ) , pp , catch_changes : true )
180
- on ( hosts_as ( 'master' ) , 'mongo --quiet --eval "load(\'/root/.mongoshrc.js\');EJSON.stringify(rs.conf())"' ) do |r |
180
+ on ( hosts_as ( 'master' ) , 'mongosh --quiet --eval "load(\'/root/.mongoshrc.js\');EJSON.stringify(rs.conf())"' ) do |r |
181
181
expect ( r . stdout ) . to match %r{#{ hosts [ 0 ] } :27017}
182
182
expect ( r . stdout ) . to match %r{#{ hosts [ 1 ] } :27017}
183
183
end
184
184
end
185
185
186
186
it 'inserts data on the master' do
187
187
sleep ( 30 )
188
- on hosts_as ( 'master' ) , %{mongo test --verbose --eval 'load("/root/.mongoshrc.js");db.dummyData.insert({"created_by_puppet": 1})'}
188
+ on hosts_as ( 'master' ) , %{mongosh test --verbose --eval 'load("/root/.mongoshrc.js");db.dummyData.insert({"created_by_puppet": 1})'}
189
189
end
190
190
191
191
it 'checks the data on the master' do
192
- on hosts_as ( 'master' ) , %{mongo test --verbose --eval 'load("/root/.mongoshrc.js");EJSON.stringify(db.dummyData.findOne())'} do |r |
192
+ on hosts_as ( 'master' ) , %{mongosh test --verbose --eval 'load("/root/.mongoshrc.js");EJSON.stringify(db.dummyData.findOne())'} do |r |
193
193
expect ( r . stdout ) . to match %r{created_by_puppet}
194
194
end
195
195
end
196
196
197
197
it 'checks the data on the slave' do
198
198
sleep ( 10 )
199
- on hosts_as ( 'slave' ) , %{mongo test --verbose --eval 'load("/root/.mongoshrc.js");db.getMongo().setReadPref("primaryPreferred");EJSON.stringify(db.dummyData.findOne())'} do |r |
199
+ on hosts_as ( 'slave' ) , %{mongosh test --verbose --eval 'load("/root/.mongoshrc.js");db.getMongo().setReadPref("primaryPreferred");EJSON.stringify(db.dummyData.findOne())'} do |r |
200
200
expect ( r . stdout ) . to match %r{created_by_puppet}
201
201
end
202
202
end
0 commit comments