@@ -145,13 +145,14 @@ def get_number_of_containers(self, filename):
145145 yml = yaml .load (f )
146146 return len (yml ["services" ])
147147
148- def wait_for_containers (self , count , label = None , name = None ):
148+ def wait_for_containers (self , count , label = None , name = None , timeout = 300 ):
149149 '''
150150 NOTE: This helper method can only be used for `compose up` scenarios where self.project_name is defined
151151 '''
152152 start = time .time ()
153153 end = start
154- while end - start < 300 :
154+ # Wait
155+ while end - start < timeout :
155156 filters = {}
156157 if name :
157158 filters ["name" ] = name
@@ -182,8 +183,8 @@ def wait_for_containers(self, count, label=None, name=None):
182183 return True
183184
184185 def handle_request_retry (self , method , url , kwargs ):
185- RETRIES = 6
186- IMPLICIT_WAIT = 3
186+ RETRIES = 10
187+ IMPLICIT_WAIT = 6
187188 for n in range (RETRIES ):
188189 try :
189190 self .logger .info ("Attempt #{}: running {} against {} with kwargs {}" .format (n + 1 , method , url , kwargs ))
@@ -2125,7 +2126,7 @@ def test_compose_1idx3sh1cm1dep(self):
21252126 container_count , rc = self .compose_up ()
21262127 assert rc == 0
21272128 # Wait for containers to come up
2128- assert self .wait_for_containers (container_count , label = "com.docker.compose.project={}" .format (self .project_name ))
2129+ assert self .wait_for_containers (container_count , label = "com.docker.compose.project={}" .format (self .project_name ), timeout = 600 )
21292130 # Get container logs
21302131 container_mapping = {"sh1" : "sh" , "sh2" : "sh" , "sh3" : "sh" , "cm1" : "cm" , "idx1" : "idx" , "dep1" : "dep" }
21312132 for container in container_mapping :
@@ -2169,11 +2170,23 @@ def test_compose_1idx3sh1cm1dep(self):
21692170 status , content = self .handle_request_retry ("GET" , url , kwargs )
21702171 assert json .loads (content )["entry" ][0 ]["content" ]["preferred_captain" ] == "1"
21712172 # Search results won't return the correct results immediately :(
2172- time .sleep (15 )
2173- search_providers , distinct_hosts = self .search_internal_distinct_hosts ("sh1" , password = self .password )
2174- assert len (search_providers ) == 2
2175- assert "idx1" in search_providers and "sh1" in search_providers
2176- assert distinct_hosts == 6
2173+ time .sleep (30 )
2174+ RETRIES = 10
2175+ IMPLICIT_WAIT = 6
2176+ for n in range (RETRIES ):
2177+ try :
2178+ self .logger .info ("Attempt #{}: checking internal search host count" .format (n + 1 ))
2179+ search_providers , distinct_hosts = self .search_internal_distinct_hosts ("sh1" , password = self .password )
2180+ assert len (search_providers ) == 2
2181+ assert "idx1" in search_providers and "sh1" in search_providers
2182+ assert distinct_hosts == 6
2183+ break
2184+ except Exception as e :
2185+ self .logger .error ("Attempt #{} error: {}" .format (n + 1 , str (e )))
2186+ if n < RETRIES - 1 :
2187+ time .sleep (IMPLICIT_WAIT )
2188+ continue
2189+ raise e
21772190 except Exception as e :
21782191 self .logger .error (e )
21792192 raise e
0 commit comments