fix: add optional timeout to disperse and get range

This commit is contained in:
Roman 2025-02-25 16:39:55 +11:00
parent bf7644bcf4
commit 48847ce5cc
No known key found for this signature in database
GPG Key ID: B8FE070B54E11B75
2 changed files with 23 additions and 21 deletions

View File

@ -75,28 +75,30 @@ class StepsDataAvailability(StepsCommon):
return executor
@allure.step
@retry(stop=stop_after_delay(65), wait=wait_fixed(1), reraise=True)
def disperse_data(self, data, app_id, index):
response = []
request = prepare_dispersal_request(data, app_id, index)
executor = self.find_executor_node()
try:
response = executor.send_dispersal_request(request)
except Exception as ex:
assert "Bad Request" in str(ex) or "Internal Server Error" in str(ex)
def disperse_data(self, data, app_id, index, timeout_duration=65):
@retry(stop=stop_after_delay(timeout_duration), wait=wait_fixed(1), reraise=True)
def disperse(my_self=self):
response = []
request = prepare_dispersal_request(data, app_id, index)
executor = my_self.find_executor_node()
try:
response = executor.send_dispersal_request(request)
except Exception as ex:
assert "Bad Request" in str(ex) or "Internal Server Error" in str(ex)
assert response.status_code == 200, "Send dispersal finished with unexpected response code"
assert response.status_code == 200, "Send dispersal finished with unexpected response code"
@allure.step
@retry(stop=stop_after_delay(45), wait=wait_fixed(1), reraise=True)
def get_data_range(self, node, app_id, start, end):
response = []
query = prepare_get_range_request(app_id, start, end)
try:
response = node.send_get_data_range_request(query)
except Exception as ex:
assert "Bad Request" in str(ex) or "Internal Server Error" in str(ex)
def get_data_range(self, node, app_id, start, end, timeout_duration=45):
@retry(stop=stop_after_delay(timeout_duration), wait=wait_fixed(1), reraise=True)
def get_range():
response = []
query = prepare_get_range_request(app_id, start, end)
try:
response = node.send_get_data_range_request(query)
except Exception as ex:
assert "Bad Request" in str(ex) or "Internal Server Error" in str(ex)
assert response_contains_data(response), "Get data range response is empty"
assert response_contains_data(response), "Get data range response is empty"
return response
return response

View File

@ -17,7 +17,7 @@ class TestDosRobustness(StepsDataAvailability):
successful_dispersals = 0
for i in range(1000):
try:
self.disperse_data(DATA_TO_DISPERSE[0], to_app_id(1), to_index(0))
self.disperse_data(DATA_TO_DISPERSE[0], to_app_id(1), to_index(0), timeout_duration=0)
successful_dispersals = i
except Exception as ex:
logger.debug(f"Dispersal #{i} was not successful with error {ex}")