summaryrefslogtreecommitdiff
path: root/buildscripts
diff options
context:
space:
mode:
Diffstat (limited to 'buildscripts')
-rw-r--r--buildscripts/package_test/recipes/install_mongodb.rb21
-rw-r--r--buildscripts/package_test/test/recipes/service/install_mongodb_spec.rb5
2 files changed, 23 insertions, 3 deletions
diff --git a/buildscripts/package_test/recipes/install_mongodb.rb b/buildscripts/package_test/recipes/install_mongodb.rb
index 28a2462afc7..cc26434e65c 100644
--- a/buildscripts/package_test/recipes/install_mongodb.rb
+++ b/buildscripts/package_test/recipes/install_mongodb.rb
@@ -94,3 +94,24 @@ if platform_family? 'suse'
cwd homedir
end
end
+
+inspec_wait = <<HEREDOC
+#!/bin/bash
+for i in {1..60}
+do
+ mongo --eval "db.smoke.insert({answer: 42})"
+ if [ $? -eq 0 ]
+ then
+ exit 0
+ else
+ echo "sleeping"
+ sleep 1
+ fi
+done
+exit 1
+HEREDOC
+
+file '/inspec_wait.sh' do
+ content inspec_wait
+ mode '0755'
+end
diff --git a/buildscripts/package_test/test/recipes/service/install_mongodb_spec.rb b/buildscripts/package_test/test/recipes/service/install_mongodb_spec.rb
index bb5cd0d7585..e974e4bd54c 100644
--- a/buildscripts/package_test/test/recipes/service/install_mongodb_spec.rb
+++ b/buildscripts/package_test/test/recipes/service/install_mongodb_spec.rb
@@ -35,9 +35,8 @@ describe service('mongod') do
it { should be_running }
end
-# wait for a few seconds so that we are sure mongod has
-# written to its log and is ready to accept writes and reads
-describe command("sleep 5") do
+# wait to make sure mongod is ready
+describe command("/inspec_wait.sh") do
its('exit_status') { should eq 0 }
end