File tree Expand file tree Collapse file tree
optional-container-engine/tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414
1515import os
1616import re
17- import time
1817
1918from bs4 import BeautifulSoup
2019import pytest
2120import requests
21+ from retrying import retry
2222
2323
2424@pytest .mark .e2e
@@ -50,10 +50,10 @@ def test_end_to_end():
5050 book_url = response .request .url
5151 book_id = book_url .rsplit ('/' , 1 ).pop ()
5252
53- # Wait 30 seconds for pubsub messages to be processed.
54- time . sleep ( 30 )
55-
56- try :
53+ # Use retry because it will take some indeterminate time for the pub/sub
54+ # message to be processed.
55+ @ retry ( wait_exponential_multiplier = 1000 , stop_max_attempt_number = 15 )
56+ def check_for_updated_data () :
5757 # Check that the book's information was updated.
5858 response = requests .get (book_url )
5959 assert response .status_code == 200
@@ -72,6 +72,9 @@ def test_end_to_end():
7272 image_src = soup .find ('img' , 'book-image' )['src' ]
7373 image = requests .get (image_src )
7474 assert image .status_code == 200
75+
76+ try :
77+ check_for_updated_data ()
7578 finally :
7679 # Delete the book we created.
7780 requests .get (base_url + '/books/{}/delete' .format (book_id ))
Original file line number Diff line number Diff line change 1414
1515import os
1616import re
17- import time
1817
1918from bs4 import BeautifulSoup
2019import pytest
2120import requests
21+ from retrying import retry
2222
2323
2424@pytest .mark .e2e
@@ -50,10 +50,10 @@ def test_end_to_end():
5050 book_url = response .request .url
5151 book_id = book_url .rsplit ('/' , 1 ).pop ()
5252
53- # Wait 30 seconds for pubsub messages to be processed.
54- time . sleep ( 30 )
55-
56- try :
53+ # Use retry because it will take some indeterminate time for the pub/sub
54+ # message to be processed.
55+ @ retry ( wait_exponential_multiplier = 1000 , stop_max_attempt_number = 15 )
56+ def check_for_updated_data () :
5757 # Check that the book's information was updated.
5858 response = requests .get (book_url )
5959 assert response .status_code == 200
@@ -72,6 +72,9 @@ def test_end_to_end():
7272 image_src = soup .find ('img' , 'book-image' )['src' ]
7373 image = requests .get (image_src )
7474 assert image .status_code == 200
75+
76+ try :
77+ check_for_updated_data ()
7578 finally :
7679 # Delete the book we created.
7780 requests .get (base_url + '/books/{}/delete' .format (book_id ))
Original file line number Diff line number Diff line change 1818 '7-gce' ]
1919
2020
21- def session_reqcheck (session ):
21+ def session_check_requirements (session ):
2222 session .install (REPO_TOOLS_REQ )
2323
2424 if 'update' in session .posargs :
Original file line number Diff line number Diff line change 1414
1515import os
1616import re
17- import time
1817
1918from bs4 import BeautifulSoup
2019import pytest
2120import requests
21+ from retrying import retry
2222
2323
2424@pytest .mark .e2e
@@ -50,10 +50,10 @@ def test_end_to_end():
5050 book_url = response .request .url
5151 book_id = book_url .rsplit ('/' , 1 ).pop ()
5252
53- # Wait 30 seconds for pubsub messages to be processed.
54- time . sleep ( 30 )
55-
56- try :
53+ # Use retry because it will take some indeterminate time for the pub/sub
54+ # message to be processed.
55+ @ retry ( wait_exponential_multiplier = 1000 , stop_max_attempt_number = 15 )
56+ def check_for_updated_data () :
5757 # Check that the book's information was updated.
5858 response = requests .get (book_url )
5959 assert response .status_code == 200
@@ -72,6 +72,9 @@ def test_end_to_end():
7272 image_src = soup .find ('img' , 'book-image' )['src' ]
7373 image = requests .get (image_src )
7474 assert image .status_code == 200
75+
76+ try :
77+ check_for_updated_data ()
7578 finally :
7679 # Delete the book we created.
7780 requests .get (base_url + '/books/{}/delete' .format (book_id ))
You can’t perform that action at this time.
0 commit comments