Skip to content

Commit f9b6bf8

Browse files
author
Graham Paye
authored
chore(vision): add retry to flakey test (googleapis#7842)
1 parent e17a98a commit f9b6bf8

1 file changed

Lines changed: 22 additions & 7 deletions

File tree

google-cloud-vision/samples/product_search/acceptance/product_search_import_product_images_test.rb

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,31 @@
2727
"fake_product_id_for_testing_2" => "shoes_2.jpg"
2828
}
2929

30-
output = `ruby #{snippet_filepath} #{@project_id} #{@location}`
30+
product_set = nil
31+
error = nil
32+
5.times do
33+
break if product_set
34+
begin
35+
output = `ruby #{snippet_filepath} #{@project_id} #{@location}`
3136

32-
# Verify console output
33-
product_images.values.each do |image_uri|
34-
_(output).must_include image_uri
37+
# Verify console output
38+
product_images.values.each do |image_uri|
39+
_(output).must_include image_uri
40+
end
41+
42+
# Verify project set existence
43+
product_set_path = @client.product_set_path project: @project_id,
44+
location: @location,
45+
product_set: @product_set_id
46+
product_set = @client.get_product_set name: product_set_path
47+
rescue Google::Cloud::NotFoundError => e
48+
error = e
49+
sleep rand(10..60)
50+
end
3551
end
3652

37-
# Verify project set existence
38-
product_set_path = @client.product_set_path project: @project_id, location: @location, product_set: @product_set_id
39-
product_set = @client.get_product_set name: product_set_path
53+
raise error if error && !product_set
54+
4055
assert product_set
4156

4257
# Verify product reference image URIs

0 commit comments

Comments
 (0)