summaryrefslogtreecommitdiff
path: root/buildscripts/package_test
diff options
context:
space:
mode:
authorBrian Samek <brian.samek@mongodb.com>2016-12-14 16:16:58 -0500
committerBrian Samek <brian.samek@mongodb.com>2016-12-16 09:20:07 -0500
commit7f74694a21f4e9c0a75e69e715133cfb590129b7 (patch)
tree2becf6e09f213e9eb6a66118e24e22d7d16aa1f1 /buildscripts/package_test
parentcb40ec2d0a42fe2f818e58d64f64bab36496258a (diff)
downloadmongo-7f74694a21f4e9c0a75e69e715133cfb590129b7.tar.gz
SERVER-27441 Reduce spurious failures in Linux package smoke testing
- Ensure that mongod is ready to accept writes before testing - Re-run converge step because instance may not yet be ready
Diffstat (limited to 'buildscripts/package_test')
-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