summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaustubh-d <kaustubh@clogeny.com>2014-11-26 16:36:01 +0530
committerLamont Granquist <lamont@scriptkiddie.org>2015-01-27 11:58:41 -0800
commitf445869cfa26b17e22a4266c58907b3619b749ae (patch)
tree8928634b5bf502628d8188ab7312a51388a75954
parentc92bbfc90a99eb99578962e9ec3579f83647d495 (diff)
downloadchef-f445869cfa26b17e22a4266c58907b3619b749ae.tar.gz
userdel functional test fix
-rw-r--r--spec/functional/resource/user/useradd_spec.rb23
1 files changed, 18 insertions, 5 deletions
diff --git a/spec/functional/resource/user/useradd_spec.rb b/spec/functional/resource/user/useradd_spec.rb
index 6b962c19aa..3cef705a69 100644
--- a/spec/functional/resource/user/useradd_spec.rb
+++ b/spec/functional/resource/user/useradd_spec.rb
@@ -82,12 +82,25 @@ describe Chef::Provider::User::Useradd, metadata do
end
after do
- begin
- pw_entry # will raise if the user doesn't exist
- shell_out!("userdel", "-r", username, :returns => [0,12])
- rescue UserNotFound
- # nothing to remove
+ max_retries = 3
+ while max_retries > 0
+ begin
+ pw_entry # will raise if the user doesn't exist
+ status = shell_out!("userdel", "-r", username, :returns => [0,8,12])
+
+ # Error code 8 during userdel indicates that the user is logged in.
+ # This occurs randomly because the accounts daemon holds a lock due to which userdel fails.
+ # The work around is to retry userdel for 3 times.
+ break if status.exitstatus != 8
+
+ sleep 1
+ max_retries = max_retries -1
+ rescue UserNotFound
+ break
+ end
end
+
+ statur.error! if max_retries == 0
end
let(:node) do