Tests: fix test get crawl loop (#967)
* tests: add sleep() between all looping get_crawl() calls to avoid tight request loop, also remove unneeded loop will likely fix occasional '504 timeout' test failures where frontend is overwhelmed with /replay.json requests
This commit is contained in:
		
							parent
							
								
									d9e73fcbc3
								
							
						
					
					
						commit
						a640f58657
					
				@ -49,6 +49,7 @@ def test_cancel_crawl(default_org_id, crawler_auth_headers):
 | 
			
		||||
    data = get_crawl(default_org_id, crawler_auth_headers, crawl_id)
 | 
			
		||||
 | 
			
		||||
    while data["state"] in ("running", "waiting_capacity"):
 | 
			
		||||
        time.sleep(5)
 | 
			
		||||
        data = get_crawl(default_org_id, crawler_auth_headers, crawl_id)
 | 
			
		||||
 | 
			
		||||
    assert data["state"] == "canceled"
 | 
			
		||||
@ -88,6 +89,7 @@ def test_start_crawl_and_stop_immediately(
 | 
			
		||||
    assert r.json()["lastCrawlStopping"] == True
 | 
			
		||||
 | 
			
		||||
    while data["state"] in ("starting", "running", "waiting_capacity"):
 | 
			
		||||
        time.sleep(5)
 | 
			
		||||
        data = get_crawl(default_org_id, crawler_auth_headers, crawl_id)
 | 
			
		||||
 | 
			
		||||
    assert data["state"] in ("canceled", "partial_complete")
 | 
			
		||||
@ -148,6 +150,7 @@ def test_stop_crawl_partial(
 | 
			
		||||
    assert r.json()["lastCrawlStopping"] == True
 | 
			
		||||
 | 
			
		||||
    while data["state"] == "running":
 | 
			
		||||
        time.sleep(5)
 | 
			
		||||
        data = get_crawl(default_org_id, crawler_auth_headers, crawl_id)
 | 
			
		||||
 | 
			
		||||
    assert data["state"] in ("partial_complete", "complete")
 | 
			
		||||
 | 
			
		||||
@ -99,7 +99,6 @@ def run_crawl(org_id, headers):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_crawl_status(org_id, crawl_id, headers):
 | 
			
		||||
    while True:
 | 
			
		||||
    r = requests.get(
 | 
			
		||||
        f"{API_PREFIX}/orgs/{org_id}/crawls/{crawl_id}/replay.json",
 | 
			
		||||
        headers=headers,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user