Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MT: Fix snmpuser teardown loop #465

Merged
merged 5 commits into from
Aug 12, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions tests/test_snmpuser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,25 @@ def destroy_user(user)
end

def teardown
# This teardown tries to preserve any non-test snmp-server user entries
# and only teardown the entries added by this test.
unless @test_users.empty?
cfg = @test_users.collect { |name| "no snmp-server user #{name}" }
config(*cfg)
end
super
delta = SnmpUser.users.keys - @@existing_users
# User deletion can take some time, for some reason
unless delta.empty?
sleep(5)
node.cache_flush
delta = SnmpUser.users.keys - @@existing_users
# Some platforms are slow, wait for snmp-server user entries to be deleted
15.times do
sleep(1)
node.cache_flush
delta = SnmpUser.users.keys - @@existing_users
break if delta.empty?
end
end
@@existing_users = SnmpUser.users.keys # rubocop:disable Style/ClassVars
assert_empty(delta, 'Users not deleted after test!')
assert_empty(delta, 'teardown method did not clean up all users')
end

def user_pat(name, group='network-admin')
Expand Down