From 27e8c1e9c3ee5a89638d9f343c109c17f06a4e08 Mon Sep 17 00:00:00 2001 From: Sofer Athlan-Guyot Date: Mon, 28 Dec 2015 13:29:53 +0100 Subject: [PATCH] Adjust rspec tests for retries in openstacklib. 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] https://github.com/openstack/puppet-openstacklib/commit/701b6fe0acf56e9132e9b0a448f28670c714cedb Change-Id: I6adc439a806cf209e2fae35446a15b07353a18c2 Closes-Bug: #1529371 --- spec/unit/provider/keystone_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/unit/provider/keystone_spec.rb b/spec/unit/provider/keystone_spec.rb index 683e185e2..5561a62ca 100644 --- a/spec/unit/provider/keystone_spec.rb +++ b/spec/unit/provider/keystone_spec.rb @@ -35,8 +35,12 @@ describe Puppet::Provider::Keystone do 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 @@ -96,8 +100,10 @@ id="the_domain_id" 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 @@ -126,8 +132,10 @@ id="the_project_id" 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