2025-01-17 14:23:52 +08:00
|
|
|
import allure
|
|
|
|
|
|
2025-01-21 16:57:23 +08:00
|
|
|
from src.env_vars import NOMOS_EXECUTOR
|
2025-01-17 14:23:52 +08:00
|
|
|
from src.steps.common import StepsCommon
|
|
|
|
|
|
|
|
|
|
|
2025-01-17 19:27:43 +08:00
|
|
|
def prepare_dispersal_request(data, app_id, index):
|
2025-01-17 15:04:02 +08:00
|
|
|
data_bytes = data.encode("utf-8")
|
2025-01-17 19:49:53 +08:00
|
|
|
dispersal_data = {"data": list(data_bytes), "metadata": {"app_id": app_id, "index": index}}
|
2025-01-17 14:23:52 +08:00
|
|
|
return dispersal_data
|
|
|
|
|
|
|
|
|
|
|
2025-01-17 19:27:43 +08:00
|
|
|
def prepare_get_range_request(app_id, start_index, end_index):
|
|
|
|
|
query_data = {"app_id": app_id, "range": {"start": start_index, "end": end_index}}
|
|
|
|
|
return query_data
|
|
|
|
|
|
|
|
|
|
|
2025-01-17 14:23:52 +08:00
|
|
|
class StepsDataAvailability(StepsCommon):
|
|
|
|
|
|
2025-01-21 16:57:23 +08:00
|
|
|
def find_executor_node(self):
|
|
|
|
|
executor = {}
|
|
|
|
|
for node in self.main_nodes:
|
|
|
|
|
if node.node_type() == NOMOS_EXECUTOR:
|
|
|
|
|
executor = node
|
|
|
|
|
return executor
|
|
|
|
|
|
2025-01-17 14:23:52 +08:00
|
|
|
@allure.step
|
2025-01-17 19:27:43 +08:00
|
|
|
def disperse_data(self, data, app_id, index):
|
2025-01-17 19:49:53 +08:00
|
|
|
request = prepare_dispersal_request(data, app_id, index)
|
2025-01-21 16:57:23 +08:00
|
|
|
executor = self.find_executor_node()
|
2025-01-17 19:27:43 +08:00
|
|
|
try:
|
2025-01-21 16:57:23 +08:00
|
|
|
executor.send_dispersal_request(request)
|
2025-01-17 19:27:43 +08:00
|
|
|
except Exception as ex:
|
|
|
|
|
assert "Bad Request" in str(ex) or "Internal Server Error" in str(ex)
|
|
|
|
|
|
|
|
|
|
@allure.step
|
2025-01-22 14:47:33 +08:00
|
|
|
def get_data_range(self, node, app_id, start, end):
|
2025-01-20 14:32:19 +08:00
|
|
|
response = []
|
2025-01-17 19:27:43 +08:00
|
|
|
query = prepare_get_range_request(app_id, start, end)
|
2025-01-17 14:23:52 +08:00
|
|
|
try:
|
2025-01-22 14:47:33 +08:00
|
|
|
response = node.send_get_data_range_request(query)
|
2025-01-17 14:23:52 +08:00
|
|
|
except Exception as ex:
|
|
|
|
|
assert "Bad Request" in str(ex) or "Internal Server Error" in str(ex)
|
2025-01-20 13:48:12 +08:00
|
|
|
|
2025-01-20 14:34:48 +08:00
|
|
|
return response
|