Skip to content

Commit

Permalink
Adjust rspec tests for retries in openstacklib.
Browse files Browse the repository at this point in the history
A patch in openstacklib[1] broke the some rspec test in keystone.  This
adjust the test to match the new behavior of the lib.

The request_timeout is fixed to 0 so that only one retry is done.
Failure to do that would make the number of retries unknown and the time
spend on the three failing tests around 60 seconds each.

[1] openstack/puppet-openstacklib@701b6fe

Change-Id: I6adc439a806cf209e2fae35446a15b07353a18c2
Closes-Bug: #1529371
  • Loading branch information
sathlan committed Dec 28, 2015
1 parent 6e811ba commit 27e8c1e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions spec/unit/provider/keystone_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ class AnotherKlass < Puppet::Provider::Keystone

describe '#fetch_domain' do
it 'should be false if the domain does not exist' do
# retry only once. Not doing this make the test unnecessary
# long (1 minute) and retry the command ~20times
klass.expects(:request_timeout).returns(0)
klass.expects(:openstack)
.with('domain', 'show', '--format', 'shell', 'no_domain')
.times(2)
.raises(Puppet::ExecutionFailure, "Execution of '/usr/bin/openstack domain show --format shell no_domain' returned 1: No domain with a name or ID of 'no_domain' exists.")
expect(klass.fetch_domain('no_domain')).to be_falsey
end
Expand Down Expand Up @@ -96,8 +100,10 @@ class AnotherKlass < Puppet::Provider::Keystone
end

it 'should be false if the project does not exist' do
klass.expects(:request_timeout).returns(0)
klass.expects(:openstack)
.with('project', 'show', '--format', 'shell', ['no_project', '--domain', 'Default'])
.times(2)
.raises(Puppet::ExecutionFailure, "Execution of '/usr/bin/openstack project show --format shell no_project' returned 1: No project with a name or ID of 'no_project' exists.")
expect(klass.fetch_project('no_project', 'Default')).to be_falsey
end
Expand Down Expand Up @@ -126,8 +132,10 @@ class AnotherKlass < Puppet::Provider::Keystone
end

it 'should be false if the user does not exist' do
klass.expects(:request_timeout).returns(0)
klass.expects(:openstack)
.with('user', 'show', '--format', 'shell', ['no_user', '--domain', 'Default'])
.times(2)
.raises(Puppet::ExecutionFailure, "Execution of '/usr/bin/openstack user show --format shell no_user' returned 1: No user with a name or ID of 'no_user' exists.")
expect(klass.fetch_user('no_user', 'Default')).to be_falsey
end
Expand Down

0 comments on commit 27e8c1e

Please sign in to comment.