From b8615676b30e11b047c9857eb343416990a42d6e Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Mon, 13 Jun 2016 08:50:24 -0700 Subject: [PATCH] Add polling for image list tests 10 seconds might not be long enough for an image to upload, but we don't want to wait forever either. Have the image upload beaker tests poll the image list for up to 60 seconds while it is saving before checking whether the image ever became active. Change-Id: If9c6ba60a18aac30bbb12d106cbbeddb1f126460 --- spec/acceptance/allinone_spec.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/spec/acceptance/allinone_spec.rb b/spec/acceptance/allinone_spec.rb index c14624a..67bc68d 100644 --- a/spec/acceptance/allinone_spec.rb +++ b/spec/acceptance/allinone_spec.rb @@ -113,10 +113,16 @@ describe 'allinone', :if => os[:family] == 'ubuntu' do cirros' result = shell("#{credentials} #{command}") expect(result.exit_code).to eq(0) - sleep(10) # command returns immediately but image needs time to upload - result = shell("#{credentials} openstack image list --long") - expect(result.stdout).to match(/cirros.*active/) - expect(result.exit_code).to eq(0) + list_command = "#{credentials} openstack image list --long" + timeout = 60 + end_time = Time.now + timeout + image_list = shell(list_command) + while image_list.stdout =~ /saving/ && Time.now() < end_time + sleep(10) + image_list = shell(list_command) + end + expect(image_list.stdout).to match(/cirros.*active/) + expect(image_list.exit_code).to eq(0) end it 'should be able to upload a keypair' do