diff --git a/src/steps/da.py b/src/steps/da.py index d65329c..779742b 100644 --- a/src/steps/da.py +++ b/src/steps/da.py @@ -77,13 +77,16 @@ class StepsDataAvailability(StepsCommon): @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: - executor.send_dispersal_request(request) + 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" + @allure.step @retry(stop=stop_after_delay(45), wait=wait_fixed(1), reraise=True) def get_data_range(self, node, app_id, start, end): diff --git a/src/test_data.py b/src/test_data.py index 31cdf31..de36752 100644 --- a/src/test_data.py +++ b/src/test_data.py @@ -33,4 +33,5 @@ DATA_TO_DISPERSE = [ "🚀🌟✨", "Lorem ipsum dolor sit amet", "Hello", + "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF01234", ] diff --git a/tests/networking_privacy/test_networking_privacy.py b/tests/networking_privacy/test_networking_privacy.py index 3804245..30ae389 100644 --- a/tests/networking_privacy/test_networking_privacy.py +++ b/tests/networking_privacy/test_networking_privacy.py @@ -12,22 +12,33 @@ logger = get_custom_logger(__name__) class TestNetworkingPrivacy(StepsDataAvailability): main_nodes = [] - @pytest.mark.parametrize("setup_2_node_cluster", [1024], indirect=True) + @pytest.mark.parametrize("setup_2_node_cluster", [2], indirect=True) def test_consumed_bandwidth_dispersal(self, setup_2_node_cluster): delay(5) net_io = psutil.net_io_counters() prev_total = net_io.bytes_sent + net_io.bytes_recv - self.disperse_data(DATA_TO_DISPERSE[1], to_app_id(1), to_index(0)) + + successful_dispersals = 0 + for i in range(20): + try: + self.disperse_data(DATA_TO_DISPERSE[7], to_app_id(1), to_index(0)) + successful_dispersals += 1 + except Exception as ex: + logger.warning(f"Dispersal #{i} was not successful with error {ex}") + + if successful_dispersals == 10: + break + + delay(0.1) + net_io = psutil.net_io_counters() curr_total = net_io.bytes_sent + net_io.bytes_recv - logger.debug(f"prev_total: {prev_total}") - logger.debug(f"curr_total: {curr_total}") - consumed = curr_total - prev_total - logger.debug(f"consumed: {consumed}") + assert successful_dispersals == 10, "Unable to finish 10 successful dispersals" - delay(5) - rcv_data = self.get_data_range(self.node2, to_app_id(1), to_index(0), to_index(5)) - logger.debug(f"Received data: {rcv_data}") + data_sent = 2 * successful_dispersals * len(DATA_TO_DISPERSE[7]) + overhead = (consumed - data_sent) / data_sent + + assert overhead < 400, "Dispersal overhead is too high"