From 1af07035bf003e706ce90a241344adc949ca5807 Mon Sep 17 00:00:00 2001 From: Mohit Singh Tomar Date: Tue, 10 Oct 2023 17:22:40 +0530 Subject: [PATCH 01/12] Added fixture to update statistics collection of south services Signed-off-by: Mohit Singh Tomar --- tests/system/python/conftest.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/system/python/conftest.py b/tests/system/python/conftest.py index 62c4c37edb..3562fb6e44 100644 --- a/tests/system/python/conftest.py +++ b/tests/system/python/conftest.py @@ -215,6 +215,25 @@ def clone_make_install(): return _add_fledge_north + +@pytest.fixture +def update_stat_collection(fledge_url, wait_time): + """Update the Stat colectioin of all south service to per asset & service""" + + # Wait for the south service to be created + time.sleep(wait_time) + service_response_list = list() + response = utils.get_request(fledge_url, "/fledge/south") + + for service in response["services"]: + put_url = "/fledge/category/{}Advanced".format(service["name"]) + payload = {"statistics": "per asset & service"} + res = utils.put_request(fledge_url, quote(put_url), payload) + service_response_list.append(res) + + return service_response_list + + @pytest.fixture def add_service(): def _add_service(fledge_url, service, service_branch, retries, installation_type = "make", service_name = "svc@123", From 2aeba35768fc5f6160053591850ccc2c0213b8b6 Mon Sep 17 00:00:00 2001 From: Mohit Singh Tomar Date: Tue, 10 Oct 2023 17:39:20 +0530 Subject: [PATCH 02/12] Updated package based tests Signed-off-by: Mohit Singh Tomar --- tests/system/python/packages/test_eds.py | 2 +- tests/system/python/packages/test_filters.py | 2 +- .../python/packages/test_north_azure.py | 26 +++++++++---------- .../python/packages/test_omf_naming_scheme.py | 8 +++--- .../python/packages/test_omf_north_service.py | 24 ++++++++--------- .../system/python/packages/test_pi_webapi.py | 8 +++--- .../test_pi_webapi_linked_data_type.py | 7 +++-- ...st_statistics_history_notification_rule.py | 2 +- 8 files changed, 39 insertions(+), 40 deletions(-) diff --git a/tests/system/python/packages/test_eds.py b/tests/system/python/packages/test_eds.py index 6790f4a7a4..7beeea72f3 100644 --- a/tests/system/python/packages/test_eds.py +++ b/tests/system/python/packages/test_eds.py @@ -171,7 +171,7 @@ def verify_eds_egress_asset_tracking(fledge_url): class TestEDS: - def test_eds(self, check_eds_installed, reset_eds, remove_and_add_pkgs, reset_fledge, start_south_north, fledge_url, + def test_eds(self, check_eds_installed, reset_eds, remove_and_add_pkgs, reset_fledge, start_south_north, update_stat_collection, fledge_url, wait_time): time.sleep(wait_time * 4) diff --git a/tests/system/python/packages/test_filters.py b/tests/system/python/packages/test_filters.py index ec8aab58bb..71c2fc7e5c 100644 --- a/tests/system/python/packages/test_filters.py +++ b/tests/system/python/packages/test_filters.py @@ -120,7 +120,7 @@ def verify_readings(fledge_url, asset_name): class TestPython35: def test_filter_python35_with_uploaded_script(self, clean_setup_fledge_packages, reset_fledge, - add_south_http_with_filter, fledge_url, wait_time): + add_south_http_with_filter, update_stat_collection, fledge_url, wait_time): # Wait until south service is created time.sleep(wait_time * 2) verify_south_added(fledge_url, HTTP_SOUTH_SVC_NAME) diff --git a/tests/system/python/packages/test_north_azure.py b/tests/system/python/packages/test_north_azure.py index 38bc668e31..6ca97ac10c 100644 --- a/tests/system/python/packages/test_north_azure.py +++ b/tests/system/python/packages/test_north_azure.py @@ -218,7 +218,7 @@ def add_expression_filter(add_filter, fledge_url, NORTH_PLUGIN_NAME): class TestNorthAzureIoTHubDevicePlugin: - def test_send(self, clean_setup_fledge_packages, reset_fledge, add_south_north_service, fledge_url, enable_schedule, + def test_send(self, clean_setup_fledge_packages, reset_fledge, add_south_north_service, update_stat_collection, fledge_url, enable_schedule, disable_schedule, azure_host, azure_device, azure_key, wait_time, retries, skip_verify_north_interface, azure_storage_account_url, azure_storage_account_key, azure_storage_container): @@ -260,7 +260,7 @@ def test_send(self, clean_setup_fledge_packages, reset_fledge, add_south_north_s _verify_egress(azure_storage_account_url, azure_storage_account_key, azure_storage_container, wait_time, retries, ASSET) - def test_mqtt_over_websocket_reconfig(self, reset_fledge, add_south_north_service, fledge_url, enable_schedule, disable_schedule, + def test_mqtt_over_websocket_reconfig(self, reset_fledge, add_south_north_service, update_stat_collection, fledge_url, enable_schedule, disable_schedule, azure_host, azure_device, azure_key, azure_storage_account_url, azure_storage_account_key, azure_storage_container, wait_time, retries, skip_verify_north_interface): @@ -306,7 +306,7 @@ def test_mqtt_over_websocket_reconfig(self, reset_fledge, add_south_north_servic _verify_egress(azure_storage_account_url, azure_storage_account_key, azure_storage_container, wait_time, retries, ASSET) - def test_disable_enable(self, reset_fledge, add_south_north_service, fledge_url, enable_schedule, disable_schedule, + def test_disable_enable(self, reset_fledge, add_south_north_service, update_stat_collection, fledge_url, enable_schedule, disable_schedule, azure_host, azure_device, azure_key, azure_storage_account_url, azure_storage_account_key, azure_storage_container, wait_time, retries, skip_verify_north_interface): @@ -349,7 +349,7 @@ def test_disable_enable(self, reset_fledge, add_south_north_service, fledge_url, _verify_egress(azure_storage_account_url, azure_storage_account_key, azure_storage_container, wait_time, retries, ASSET) - def test_send_with_filter(self, reset_fledge, add_south_north_service, fledge_url, enable_schedule, disable_schedule, + def test_send_with_filter(self, reset_fledge, add_south_north_service, update_stat_collection, fledge_url, enable_schedule, disable_schedule, azure_host, azure_device, azure_key, azure_storage_account_url, azure_storage_account_key, azure_storage_container, wait_time, retries, skip_verify_north_interface, add_filter): @@ -407,7 +407,7 @@ def test_send_with_filter(self, reset_fledge, add_south_north_service, fledge_ur class TestNorthAzureIoTHubDevicePluginTask: - def test_send_as_a_task(self, reset_fledge, add_south_north_task, fledge_url, enable_schedule, disable_schedule, + def test_send_as_a_task(self, reset_fledge, add_south_north_task, update_stat_collection, fledge_url, enable_schedule, disable_schedule, azure_host, azure_device, azure_key, azure_storage_account_url, azure_storage_account_key, azure_storage_container, wait_time, retries, skip_verify_north_interface): @@ -448,7 +448,7 @@ def test_send_as_a_task(self, reset_fledge, add_south_north_task, fledge_url, en _verify_egress(azure_storage_account_url, azure_storage_account_key, azure_storage_container, wait_time, retries, ASSET) - def test_mqtt_over_websocket_reconfig_task(self, reset_fledge, add_south_north_task, fledge_url, enable_schedule, disable_schedule, + def test_mqtt_over_websocket_reconfig_task(self, reset_fledge, add_south_north_task, update_stat_collection, fledge_url, enable_schedule, disable_schedule, azure_host, azure_device, azure_key, azure_storage_account_url, azure_storage_account_key, azure_storage_container, wait_time, retries, skip_verify_north_interface): @@ -495,7 +495,7 @@ def test_mqtt_over_websocket_reconfig_task(self, reset_fledge, add_south_north_t _verify_egress(azure_storage_account_url, azure_storage_account_key, azure_storage_container, wait_time, retries, ASSET) - def test_disable_enable_task(self, reset_fledge, add_south_north_task, fledge_url, enable_schedule, disable_schedule, + def test_disable_enable_task(self, reset_fledge, add_south_north_task, update_stat_collection, fledge_url, enable_schedule, disable_schedule, azure_host, azure_device, azure_key, azure_storage_account_url, azure_storage_account_key, azure_storage_container, wait_time, retries, skip_verify_north_interface): @@ -536,7 +536,7 @@ def test_disable_enable_task(self, reset_fledge, add_south_north_task, fledge_ur _verify_egress(azure_storage_account_url, azure_storage_account_key, azure_storage_container, wait_time, retries, ASSET) - def test_send_with_filter_task(self, reset_fledge, add_south_north_task, fledge_url, enable_schedule, disable_schedule, + def test_send_with_filter_task(self, reset_fledge, add_south_north_task, update_stat_collection, fledge_url, enable_schedule, disable_schedule, azure_host, azure_device, azure_key, azure_storage_account_url, azure_storage_account_key, azure_storage_container, wait_time, retries, skip_verify_north_interface, add_filter): @@ -595,7 +595,7 @@ def test_send_with_filter_task(self, reset_fledge, add_south_north_task, fledge_ class TestNorthAzureIoTHubDevicePluginInvalidConfig: - def test_invalid_connstr(self, reset_fledge, add_south, add_north, fledge_url, enable_schedule, disable_schedule, wait_time, retries): + def test_invalid_connstr(self, reset_fledge, add_south, add_north, update_stat_collection, fledge_url, enable_schedule, disable_schedule, wait_time, retries): """ Test that checks connection string of north azure plugin is invalid or not. @@ -618,7 +618,7 @@ def test_invalid_connstr(self, reset_fledge, add_south, add_north, fledge_url, e # Update Asset name ASSET = "test9_FOGL-7352_system" config_south(fledge_url, ASSET) - + update_stat_collection( fledge_url, wait_time) # Enable South Service for 10 Seonds enable_schedule(fledge_url, SOUTH_SERVICE_NAME) time.sleep(wait_time) @@ -630,7 +630,7 @@ def test_invalid_connstr(self, reset_fledge, add_south, add_north, fledge_url, e verify_north_stats_on_invalid_config(fledge_url) - def test_invalid_connstr_sharedkey(self, reset_fledge, add_south, add_north, fledge_url, enable_schedule, disable_schedule, + def test_invalid_connstr_sharedkey(self, reset_fledge, add_south, add_north, update_stat_collection, fledge_url, enable_schedule, disable_schedule, wait_time, retries, azure_host, azure_device, azure_key): """ Test that checks shared key passed to connection string of north azure plugin is invalid or not. @@ -657,7 +657,7 @@ def test_invalid_connstr_sharedkey(self, reset_fledge, add_south, add_north, fle # Update Asset name ASSET = "test10_FOGL-7352_system" config_south(fledge_url, ASSET) - + update_stat_collection(fledge_url, wait_time) # Enable South Service for 10 Seonds enable_schedule(fledge_url, SOUTH_SERVICE_NAME) time.sleep(wait_time) @@ -671,7 +671,7 @@ def test_invalid_connstr_sharedkey(self, reset_fledge, add_south, add_north, fle class TestNorthAzureIoTHubDevicePluginLongRun: - def test_send_long_run(self, clean_setup_fledge_packages, reset_fledge, add_south_north_service, fledge_url, enable_schedule, + def test_send_long_run(self, clean_setup_fledge_packages, reset_fledge, add_south_north_service, update_stat_collection, fledge_url, enable_schedule, disable_schedule, azure_host, azure_device, azure_key, wait_time, retries, skip_verify_north_interface, azure_storage_account_url, azure_storage_account_key, azure_storage_container, run_time): diff --git a/tests/system/python/packages/test_omf_naming_scheme.py b/tests/system/python/packages/test_omf_naming_scheme.py index 2a46ff6a11..ad86e802f2 100644 --- a/tests/system/python/packages/test_omf_naming_scheme.py +++ b/tests/system/python/packages/test_omf_naming_scheme.py @@ -167,7 +167,7 @@ def _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_d class TestOMFNamingScheme: def test_omf_with_concise_naming(self, clean_setup_fledge_packages, reset_fledge, start_south, - start_north_task_omf_web_api, + start_north_task_omf_web_api, update_stat_collection, read_data_from_pi_web_api, skip_verify_north_interface, fledge_url, wait_time, retries, pi_host, pi_port, pi_admin, pi_passwd, pi_db): """ Test OMF with concise naming scheme. @@ -208,7 +208,7 @@ def test_omf_with_concise_naming(self, clean_setup_fledge_packages, reset_fledge _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, recorded_datapoint, pi_asset_name) - def test_omf_with_type_suffix_naming(self, reset_fledge, start_south, start_north_task_omf_web_api, + def test_omf_with_type_suffix_naming(self, reset_fledge, start_south, start_north_task_omf_web_api, update_stat_collection, read_data_from_pi_web_api, skip_verify_north_interface, fledge_url, wait_time, retries, pi_host, pi_port, pi_admin, pi_passwd, pi_db): """ Test OMF with concise naming scheme. @@ -250,7 +250,7 @@ def test_omf_with_type_suffix_naming(self, reset_fledge, start_south, start_nort _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, recorded_datapoint, pi_asset_name) - def test_omf_with_attribute_hash_naming(self, reset_fledge, start_south, start_north_task_omf_web_api, + def test_omf_with_attribute_hash_naming(self, reset_fledge, start_south, start_north_task_omf_web_api, update_stat_collection, read_data_from_pi_web_api, skip_verify_north_interface, fledge_url, wait_time, retries, pi_host, pi_port, pi_admin, pi_passwd, pi_db): """ Test OMF with concise naming scheme. @@ -292,7 +292,7 @@ def test_omf_with_attribute_hash_naming(self, reset_fledge, start_south, start_n _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, recorded_datapoint, pi_asset_name) - def test_omf_with_backward_compatibility_naming(self, reset_fledge, start_south, start_north_task_omf_web_api, + def test_omf_with_backward_compatibility_naming(self, reset_fledge, start_south, start_north_task_omf_web_api, update_stat_collection, read_data_from_pi_web_api, skip_verify_north_interface, fledge_url, wait_time, retries, pi_host, pi_port, pi_admin, pi_passwd, pi_db): """ Test OMF with concise naming scheme. diff --git a/tests/system/python/packages/test_omf_north_service.py b/tests/system/python/packages/test_omf_north_service.py index f62e0ce042..55c97071a4 100644 --- a/tests/system/python/packages/test_omf_north_service.py +++ b/tests/system/python/packages/test_omf_north_service.py @@ -179,7 +179,7 @@ def _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_d class TestOMFNorthService: - def test_omf_service_with_restart(self, clean_setup_fledge_packages, reset_fledge, start_south_north, + def test_omf_service_with_restart(self, clean_setup_fledge_packages, reset_fledge, start_south_north, update_stat_collection, read_data_from_pi_web_api, skip_verify_north_interface, fledge_url, wait_time, retries, pi_host, pi_port, pi_admin, pi_passwd, pi_db): """ Test OMF as a North service before and after restarting fledge. @@ -227,7 +227,7 @@ def test_omf_service_with_restart(self, clean_setup_fledge_packages, reset_fledg _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, south_asset_name) - def test_omf_service_with_enable_disable(self, reset_fledge, start_south_north, read_data_from_pi_web_api, + def test_omf_service_with_enable_disable(self, reset_fledge, start_south_north, update_stat_collection, read_data_from_pi_web_api, skip_verify_north_interface, fledge_url, wait_time, retries, pi_host, pi_port, pi_admin, pi_passwd, pi_db): @@ -279,8 +279,8 @@ def test_omf_service_with_enable_disable(self, reset_fledge, start_south_north, _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, south_asset_name) - def test_omf_service_with_delete_add(self, reset_fledge, start_south_north, read_data_from_pi_web_api, - start_north_omf_as_a_service, + def test_omf_service_with_delete_add(self, reset_fledge, start_south_north, update_stat_collection, + read_data_from_pi_web_api, start_north_omf_as_a_service, skip_verify_north_interface, fledge_url, wait_time, retries, pi_host, pi_port, pi_admin, pi_passwd, pi_db): """ Test OMF as a North service by deleting and adding north service. @@ -331,8 +331,8 @@ def test_omf_service_with_delete_add(self, reset_fledge, start_south_north, read _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, south_asset_name) - def test_omf_service_with_reconfig(self, reset_fledge, start_south_north, read_data_from_pi_web_api, - skip_verify_north_interface, fledge_url, + def test_omf_service_with_reconfig(self, reset_fledge, start_south_north, update_stat_collection, + read_data_from_pi_web_api, skip_verify_north_interface, fledge_url, wait_time, retries, pi_host, pi_port, pi_admin, pi_passwd, pi_db): """ Test OMF as a North service by reconfiguring it. reset_fledge: Fixture to reset fledge @@ -397,7 +397,7 @@ def test_omf_service_with_reconfig(self, reset_fledge, start_south_north, read_d class TestOMFNorthServicewithFilters: - def test_omf_service_with_filter(self, reset_fledge, start_south_north, add_configure_filter, + def test_omf_service_with_filter(self, reset_fledge, start_south_north, update_stat_collection, add_configure_filter, read_data_from_pi_web_api, skip_verify_north_interface, fledge_url, wait_time, retries, pi_host, pi_port, pi_admin, pi_passwd, pi_db): @@ -438,7 +438,7 @@ def test_omf_service_with_filter(self, reset_fledge, start_south_north, add_conf _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, south_asset_name) - def test_omf_service_with_disable_enable_filter(self, reset_fledge, start_south_north, add_configure_filter, + def test_omf_service_with_disable_enable_filter(self, reset_fledge, start_south_north, update_stat_collection, add_configure_filter, read_data_from_pi_web_api, skip_verify_north_interface, fledge_url, wait_time, retries, pi_host, pi_port, pi_admin, pi_passwd, pi_db): @@ -491,7 +491,7 @@ def test_omf_service_with_disable_enable_filter(self, reset_fledge, start_south_ _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, south_asset_name) - def test_omf_service_with_filter_reconfig(self, reset_fledge, start_south_north, add_configure_filter, + def test_omf_service_with_filter_reconfig(self, reset_fledge, start_south_north, update_stat_collection, add_configure_filter, read_data_from_pi_web_api, skip_verify_north_interface, fledge_url, wait_time, retries, pi_host, pi_port, pi_admin, pi_passwd, pi_db): @@ -539,7 +539,7 @@ def test_omf_service_with_filter_reconfig(self, reset_fledge, start_south_north, _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, south_asset_name) - def test_omf_service_with_delete_add(self, reset_fledge, start_south_north, add_configure_filter, add_filter, + def test_omf_service_with_delete_add(self, reset_fledge, start_south_north, update_stat_collection, add_configure_filter, add_filter, read_data_from_pi_web_api, start_north_omf_as_a_service, skip_verify_north_interface, fledge_url, wait_time, retries, pi_host, pi_port, pi_admin, pi_passwd, pi_db): @@ -600,7 +600,7 @@ def test_omf_service_with_delete_add(self, reset_fledge, start_south_north, add_ _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, south_asset_name) - def test_omf_service_with_delete_add_filter(self, reset_fledge, start_south_north, add_configure_filter, add_filter, + def test_omf_service_with_delete_add_filter(self, reset_fledge, start_south_north, update_stat_collection, add_configure_filter, add_filter, read_data_from_pi_web_api, skip_verify_north_interface, fledge_url, wait_time, retries, pi_host, pi_port, pi_admin, pi_passwd, pi_db): @@ -658,7 +658,7 @@ def test_omf_service_with_delete_add_filter(self, reset_fledge, start_south_nort _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, south_asset_name) - def test_omf_service_with_filter_reorder(self, reset_fledge, start_south_north, add_configure_filter, add_filter, + def test_omf_service_with_filter_reorder(self, reset_fledge, start_south_north, update_stat_collection, add_configure_filter, add_filter, read_data_from_pi_web_api, skip_verify_north_interface, fledge_url, wait_time, retries, pi_host, pi_port, pi_admin, pi_passwd, pi_db): diff --git a/tests/system/python/packages/test_pi_webapi.py b/tests/system/python/packages/test_pi_webapi.py index a4180a8298..f89f301b83 100644 --- a/tests/system/python/packages/test_pi_webapi.py +++ b/tests/system/python/packages/test_pi_webapi.py @@ -164,9 +164,9 @@ def start_south_north(add_south, start_north_task_omf_web_api, remove_data_file, class TestPackagesCoAP_PI_WebAPI: - def test_omf_task(self, clean_setup_fledge_packages, reset_fledge, start_south_north, read_data_from_pi_web_api, - fledge_url, pi_host, pi_admin, pi_passwd, pi_db, fogbench_host, fogbench_port, - wait_time, retries, skip_verify_north_interface, asset_name=ASSET): + def test_omf_task(self, clean_setup_fledge_packages, reset_fledge, start_south_north, update_stat_collection, + read_data_from_pi_web_api, fledge_url, pi_host, pi_admin, pi_passwd, pi_db, fogbench_host, + fogbench_port, wait_time, retries, skip_verify_north_interface, asset_name=ASSET): """ Test that data is inserted in Fledge and sent to PI start_south_north: Fixture that add south and north instance read_data_from_pi: Fixture to read data from PI @@ -196,7 +196,7 @@ def test_omf_task(self, clean_setup_fledge_packages, reset_fledge, start_south_n _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, asset_name) - def test_omf_task_with_reconfig(self, reset_fledge, start_south_north, read_data_from_pi_web_api, + def test_omf_task_with_reconfig(self, reset_fledge, start_south_north, update_stat_collection, read_data_from_pi_web_api, skip_verify_north_interface, fledge_url, fogbench_host, fogbench_port, wait_time, retries, pi_host, pi_port, pi_admin, pi_passwd, pi_db, asset_name=ASSET): diff --git a/tests/system/python/packages/test_pi_webapi_linked_data_type.py b/tests/system/python/packages/test_pi_webapi_linked_data_type.py index 46f19a937e..ec7ff17134 100644 --- a/tests/system/python/packages/test_pi_webapi_linked_data_type.py +++ b/tests/system/python/packages/test_pi_webapi_linked_data_type.py @@ -208,8 +208,7 @@ def start_south_north(add_south, start_north_task_omf_web_api, add_filter, remov service_name=NORTH_INSTANCE_NAME, default_af_location=AF_HIERARCHY_LEVEL) class Test_linked_data_PIWebAPI: - # @pytest.mark.skip(reason="no way of currently testing this") - def test_linked_data(self, clean_setup_fledge_packages, reset_fledge, start_south_north, fledge_url, + def test_linked_data(self, clean_setup_fledge_packages, reset_fledge, start_south_north, update_stat_collection, fledge_url, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, pi_port, enable_schedule, disable_schedule, verify_hierarchy_and_get_datapoints_from_pi_web_api, clear_pi_system_through_pi_web_api, skip_verify_north_interface, asset_name=ASSET): @@ -252,7 +251,7 @@ def test_linked_data(self, clean_setup_fledge_packages, reset_fledge, start_sout verify_data_between_fledge_and_piwebapi(fledge_url, pi_host, pi_admin, pi_passwd, pi_db, AF_HIERARCHY_LEVEL, ASSET, SOUTH_PLUGINS_LIST, verify_hierarchy_and_get_datapoints_from_pi_web_api, wait_time) # @pytest.mark.skip(reason="no way of currently testing this") - def test_linked_data_with_filter(self, reset_fledge, start_south_north, fledge_url, pi_host, pi_admin, pi_passwd, add_filter, pi_db, wait_time, + def test_linked_data_with_filter(self, reset_fledge, start_south_north, update_stat_collection, fledge_url, pi_host, pi_admin, pi_passwd, add_filter, pi_db, wait_time, retries, pi_port, enable_schedule, disable_schedule, verify_hierarchy_and_get_datapoints_from_pi_web_api, clear_pi_system_through_pi_web_api, skip_verify_north_interface, asset_name=ASSET): @@ -295,7 +294,7 @@ def test_linked_data_with_filter(self, reset_fledge, start_south_north, fledge_u verify_data_between_fledge_and_piwebapi(fledge_url, pi_host, pi_admin, pi_passwd, pi_db, AF_HIERARCHY_LEVEL, ASSET, ASSET_DICT[ASSET], verify_hierarchy_and_get_datapoints_from_pi_web_api, wait_time) # @pytest.mark.skip(reason="no way of currently testing this") - def test_linked_data_with_onoff_filter(self, reset_fledge, start_south_north, fledge_url, pi_host, pi_admin, pi_passwd, add_filter, pi_db, wait_time, + def test_linked_data_with_onoff_filter(self, reset_fledge, start_south_north, update_stat_collection, fledge_url, pi_host, pi_admin, pi_passwd, add_filter, pi_db, wait_time, retries, pi_port, enable_schedule, disable_schedule, verify_hierarchy_and_get_datapoints_from_pi_web_api, clear_pi_system_through_pi_web_api, skip_verify_north_interface, asset_name=ASSET): diff --git a/tests/system/python/packages/test_statistics_history_notification_rule.py b/tests/system/python/packages/test_statistics_history_notification_rule.py index 83619eb3d2..e7dca40e35 100644 --- a/tests/system/python/packages/test_statistics_history_notification_rule.py +++ b/tests/system/python/packages/test_statistics_history_notification_rule.py @@ -144,7 +144,7 @@ def _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_d class TestStatisticsHistoryBasedNotificationRuleOnIngress: - def test_stats_readings_south(self, clean_setup_fledge_packages, reset_fledge, start_south, start_notification, fledge_url, + def test_stats_readings_south(self, clean_setup_fledge_packages, reset_fledge, start_south, update_stat_collection, start_notification, fledge_url, skip_verify_north_interface, wait_time, retries): """ Test NTFSN triggered or not with source as statistics history and name as READINGS in threshold rule. clean_setup_fledge_packages: Fixture to remove and install latest fledge packages From eb6bb2deec51a4450b3bee1305532000df6bb859 Mon Sep 17 00:00:00 2001 From: Mohit Singh Tomar Date: Tue, 10 Oct 2023 18:53:49 +0530 Subject: [PATCH 03/12] Updated pair based system test Signed-off-by: Mohit Singh Tomar --- .../system/python/pair/test_c_north_service_pair.py | 7 +++++-- tests/system/python/pair/test_e2e_fledge_pair.py | 12 ++++++++---- .../python/pair/test_pyton_north_service_pair.py | 7 ++++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/tests/system/python/pair/test_c_north_service_pair.py b/tests/system/python/pair/test_c_north_service_pair.py index 8f1cf5ddb5..1659e80241 100644 --- a/tests/system/python/pair/test_c_north_service_pair.py +++ b/tests/system/python/pair/test_c_north_service_pair.py @@ -54,11 +54,12 @@ def reset_fledge_local(wait_time): @pytest.fixture -def setup_local(reset_fledge_local, add_south, add_north, fledge_url, remote_ip): +def setup_local(reset_fledge_local, add_south, add_north, update_stat_collection, fledge_url, remote_ip, wait_time): local_south_config = {"assetName": {"value": remote_south_asset_name}} add_south(local_south_plugin, None, fledge_url, config=local_south_config, service_name="{}".format(local_south_service_name), installation_type='package') + update_stat_collection(fledge_url, wait_time) # Change name of variables such as service_name, plugin_type global north_schedule_id local_north_config = {"URL": {"value": "http://{}:6683/sensor-reading".format(remote_ip)}} @@ -121,7 +122,7 @@ def clean_install_fledge_packages_remote(remote_user, remote_ip, key_path, remot @pytest.fixture def setup_remote(reset_fledge_remote, remote_user, remote_ip, start_north_omf_as_a_service, - pi_host, pi_port, pi_admin, pi_passwd, + pi_host, pi_port, pi_admin, pi_passwd, update_stat_collection, clear_pi_system_through_pi_web_api, pi_db): """Fixture that setups remote machine reset_fledge_remote: Fixture that kills fledge, reset database and starts fledge again on a remote @@ -156,6 +157,8 @@ def setup_remote(reset_fledge_remote, remote_user, remote_ip, start_north_omf_as retval = json.loads(r) assert remote_south_service_name == retval["name"] + update_stat_collection(fledge_url, wait_time) + # Configure pi north plugin on remote machine global remote_north_schedule_id response = start_north_omf_as_a_service(fledge_url, pi_host, pi_port, pi_user=pi_admin, pi_pwd=pi_passwd, diff --git a/tests/system/python/pair/test_e2e_fledge_pair.py b/tests/system/python/pair/test_e2e_fledge_pair.py index 4d9e2cf41e..ef4e874e98 100644 --- a/tests/system/python/pair/test_e2e_fledge_pair.py +++ b/tests/system/python/pair/test_e2e_fledge_pair.py @@ -95,8 +95,8 @@ def reset_and_start_fledge_remote(self, storage_plugin, remote_user, remote_ip, @pytest.fixture def start_south_north_remote(self, reset_and_start_fledge_remote, use_pip_cache, remote_user, - key_path, remote_fledge_path, remote_ip, south_branch, - start_north_pi_server_c, pi_host, pi_port, pi_token, + key_path, remote_fledge_path, remote_ip, south_branch, update_stat_collection, + start_north_pi_server_c, pi_host, pi_port, pi_token, wait_time, clear_pi_system_through_pi_web_api, pi_admin, pi_passwd, pi_db): """Fixture that starts south and north plugins on remote machine reset_and_start_fledge_remote: Fixture that kills fledge, reset database and starts fledge again on a remote machine @@ -152,6 +152,8 @@ def start_south_north_remote(self, reset_and_start_fledge_remote, use_pip_cache, retval = json.loads(r) assert south_service == retval["name"] + update_stat_collection(fledge_url, wait_time) + # Configure pi north plugin on remote machine start_north_pi_server_c(fledge_url, pi_host, pi_port, pi_token) @@ -188,8 +190,8 @@ def configure_and_start_north_http(self, north_branch, fledge_url, remote_ip, ta @pytest.fixture def start_south_north_local(self, reset_and_start_fledge, add_south, enable_schedule, remove_directories, - remove_data_file, south_branch, north_branch, fledge_url, remote_ip, - add_filter, filter_branch): + remove_data_file, south_branch, north_branch, fledge_url, remote_ip, wait_time, + add_filter, filter_branch, update_stat_collection): """ This fixture clone a south and north repo and starts both south and north instance reset_and_start_fledge: Fixture that resets and starts fledge, no explicit invocation, called at start @@ -247,6 +249,8 @@ def start_south_north_local(self, reset_and_start_fledge, add_south, enable_sche enable_schedule(fledge_url, "fogpair_sine") enable_schedule(fledge_url, "NorthReadingsToHTTP") + update_stat_collection(fledge_url, wait_time) + yield self.start_south_north_local # Cleanup diff --git a/tests/system/python/pair/test_pyton_north_service_pair.py b/tests/system/python/pair/test_pyton_north_service_pair.py index 818372fef6..260b7273fc 100644 --- a/tests/system/python/pair/test_pyton_north_service_pair.py +++ b/tests/system/python/pair/test_pyton_north_service_pair.py @@ -54,11 +54,12 @@ def reset_fledge_local(wait_time): @pytest.fixture -def setup_local(reset_fledge_local, add_south, add_north, fledge_url, remote_ip): +def setup_local(reset_fledge_local, add_south, add_north, update_stat_collection, wait_time, fledge_url, remote_ip): local_south_config = {"assetName": {"value": local_south_asset_name}} add_south(local_south_plugin, None, fledge_url, config=local_south_config, service_name="{}".format(local_south_service_name), installation_type='package') + update_stat_collection(fledge_url, wait_time) # Change name of variables such as service_name, plugin_type global north_schedule_id local_north_config = {"url": {"value": "http://{}:6683/sensor-reading".format(remote_ip)}} @@ -122,7 +123,7 @@ def clean_install_fledge_packages_remote(remote_user, remote_ip, key_path, remot @pytest.fixture def setup_remote(reset_fledge_remote, remote_user, remote_ip, start_north_omf_as_a_service, - pi_host, pi_port, pi_admin, pi_passwd, + pi_host, pi_port, pi_admin, pi_passwd, update_stat_collection, wait_time, clear_pi_system_through_pi_web_api, pi_db): """Fixture that setups remote machine reset_fledge_remote: Fixture that kills fledge, reset database and starts fledge again on a remote @@ -156,7 +157,7 @@ def setup_remote(reset_fledge_remote, remote_user, remote_ip, start_north_omf_as r = r.read().decode() retval = json.loads(r) assert remote_south_service_name == retval["name"] - + update_stat_collection(fledge_url, wait_time) # Configure pi north plugin on remote machine global remote_north_schedule_id response = start_north_omf_as_a_service(fledge_url, pi_host, pi_port, pi_user=pi_admin, pi_pwd=pi_passwd, From c95e6568a9a4b56366e87f1e33d9d0114d48ddad Mon Sep 17 00:00:00 2001 From: Mohit Singh Tomar Date: Wed, 11 Oct 2023 13:09:42 +0530 Subject: [PATCH 04/12] Updated nightly test Signed-off-by: Mohit Singh Tomar --- tests/system/python/api/test_statistics.py | 2 +- tests/system/python/e2e/test_e2e_csv_PI.py | 2 +- tests/system/python/e2e/test_e2e_csv_multi_filter_pi.py | 2 +- tests/system/python/e2e/test_e2e_expr_pi.py | 2 +- tests/system/python/e2e/test_e2e_filter_fft_threshold.py | 2 +- tests/system/python/e2e/test_e2e_kafka.py | 2 +- tests/system/python/e2e/test_e2e_modbus_c_pi.py | 2 +- tests/system/python/e2e/test_e2e_pi_scaleset.py | 2 +- tests/system/python/e2e/test_e2e_vary_asset_http_pi.py | 2 +- tests/system/python/smoke/test_smoke.py | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/system/python/api/test_statistics.py b/tests/system/python/api/test_statistics.py index 17baf5a6c9..f529400eab 100644 --- a/tests/system/python/api/test_statistics.py +++ b/tests/system/python/api/test_statistics.py @@ -122,7 +122,7 @@ def test_statistics_history_with_params(self, fledge_url, request_params, keys): assert 1 == len(jdoc['statistics']) assert Counter(keys) == Counter(jdoc['statistics'][0].keys()) - def test_statistics_history_with_service_enabled(self, start_south_coap, fledge_url, wait_time): + def test_statistics_history_with_service_enabled(self, start_south_coap, update_stat_collection, fledge_url, wait_time): # Allow CoAP listener to start time.sleep(wait_time) diff --git a/tests/system/python/e2e/test_e2e_csv_PI.py b/tests/system/python/e2e/test_e2e_csv_PI.py index 98f8fcf3bb..038ff56a97 100644 --- a/tests/system/python/e2e/test_e2e_csv_PI.py +++ b/tests/system/python/e2e/test_e2e_csv_PI.py @@ -131,7 +131,7 @@ def _verify_egress(read_data_from_pi, pi_host, pi_admin, pi_passwd, pi_db, wait_ class TestE2E_CSV_PI: - def test_e2e_csv_pi(self, start_south_north, read_data_from_pi, fledge_url, pi_host, pi_admin, pi_passwd, pi_db, + def test_e2e_csv_pi(self, start_south_north, update_stat_collection, read_data_from_pi, fledge_url, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, skip_verify_north_interface, asset_name="end_to_end_csv"): """ Test that data is inserted in Fledge and sent to PI start_south_north: Fixture that starts Fledge with south and north instance diff --git a/tests/system/python/e2e/test_e2e_csv_multi_filter_pi.py b/tests/system/python/e2e/test_e2e_csv_multi_filter_pi.py index 48dbf9cba7..213480cb9d 100644 --- a/tests/system/python/e2e/test_e2e_csv_multi_filter_pi.py +++ b/tests/system/python/e2e/test_e2e_csv_multi_filter_pi.py @@ -140,7 +140,7 @@ def start_south_north(self, reset_and_start_fledge, add_south, enable_schedule, remove_data_file(csv_file_path) - def test_end_to_end(self, start_south_north, disable_schedule, fledge_url, read_data_from_pi, pi_host, pi_admin, + def test_end_to_end(self, start_south_north, update_stat_collection, disable_schedule, fledge_url, read_data_from_pi, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, skip_verify_north_interface): """ Test that data is inserted in Fledge using playback south plugin & Delta, RMS, Rate, Scale, Asset & Metadata filters, and sent to PI diff --git a/tests/system/python/e2e/test_e2e_expr_pi.py b/tests/system/python/e2e/test_e2e_expr_pi.py index f4ba453340..78b072874d 100644 --- a/tests/system/python/e2e/test_e2e_expr_pi.py +++ b/tests/system/python/e2e/test_e2e_expr_pi.py @@ -97,7 +97,7 @@ def start_south_north(self, reset_and_start_fledge, add_south, enable_schedule, remove_directories("/tmp/fledge-south-{}".format(SOUTH_PLUGIN.lower())) remove_directories("/tmp/fledge-filter-{}".format(filter_plugin)) - def test_end_to_end(self, start_south_north, disable_schedule, fledge_url, read_data_from_pi, pi_host, pi_admin, + def test_end_to_end(self, start_south_north, update_stat_collection, disable_schedule, fledge_url, read_data_from_pi, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, skip_verify_north_interface): """ Test that data is inserted in Fledge using expression south plugin & metadata filter, and sent to PI start_south_north: Fixture that starts Fledge with south service, add filter and north instance diff --git a/tests/system/python/e2e/test_e2e_filter_fft_threshold.py b/tests/system/python/e2e/test_e2e_filter_fft_threshold.py index 0040005035..beef6ca79a 100644 --- a/tests/system/python/e2e/test_e2e_filter_fft_threshold.py +++ b/tests/system/python/e2e/test_e2e_filter_fft_threshold.py @@ -128,7 +128,7 @@ def start_south_north(self, reset_and_start_fledge, add_south, enable_schedule, remove_data_file(csv_dest) - def test_end_to_end(self, start_south_north, disable_schedule, fledge_url, read_data_from_pi, pi_host, pi_admin, + def test_end_to_end(self, start_south_north, update_stat_collection, disable_schedule, fledge_url, read_data_from_pi, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, skip_verify_north_interface): """ Test that data is inserted in Fledge using playback south plugin & FFT filter, and sent to PI after passing through threshold filter diff --git a/tests/system/python/e2e/test_e2e_kafka.py b/tests/system/python/e2e/test_e2e_kafka.py index 23362ed566..90d1ff90cb 100644 --- a/tests/system/python/e2e/test_e2e_kafka.py +++ b/tests/system/python/e2e/test_e2e_kafka.py @@ -118,7 +118,7 @@ def start_south_north(self, reset_and_start_fledge, add_south, remove_data_file, remove_directories("/tmp/fledge-south-{}".format(SOUTH_PLUGIN_NAME)) remove_directories("/tmp/fledge-north-{}".format(NORTH_PLUGIN_NAME.lower())) - def test_end_to_end(self, start_south_north, fledge_url, wait_time, kafka_host, kafka_rest_port, kafka_topic, + def test_end_to_end(self, start_south_north, update_stat_collection, fledge_url, wait_time, kafka_host, kafka_rest_port, kafka_topic, skip_verify_north_interface): """ Test that data is inserted in Fledge and sent to Kafka start_south_north: Fixture that starts Fledge with south and north instance diff --git a/tests/system/python/e2e/test_e2e_modbus_c_pi.py b/tests/system/python/e2e/test_e2e_modbus_c_pi.py index 89991de4d6..a81afbbec4 100644 --- a/tests/system/python/e2e/test_e2e_modbus_c_pi.py +++ b/tests/system/python/e2e/test_e2e_modbus_c_pi.py @@ -99,7 +99,7 @@ def start_south_north(self, reset_and_start_fledge, add_south, remove_directorie remove_directories("/tmp/fledge-south-{}".format(SOUTH_PLUGIN.lower())) - def test_end_to_end(self, start_south_north, enable_schedule, disable_schedule, fledge_url, read_data_from_pi, + def test_end_to_end(self, start_south_north, update_stat_collection, enable_schedule, disable_schedule, fledge_url, read_data_from_pi, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, skip_verify_north_interface, modbus_host, modbus_port): """ Test that data is inserted in Fledge using modbus-c south plugin and sent to PI diff --git a/tests/system/python/e2e/test_e2e_pi_scaleset.py b/tests/system/python/e2e/test_e2e_pi_scaleset.py index bf97e9105d..7d68f01a74 100644 --- a/tests/system/python/e2e/test_e2e_pi_scaleset.py +++ b/tests/system/python/e2e/test_e2e_pi_scaleset.py @@ -121,7 +121,7 @@ def start_south_north_with_filter(self, reset_and_start_fledge, add_south, south remove_directories("/tmp/fledge-south-{}".format(ASSET_NAME.lower())) remove_directories("/tmp/fledge-filter-{}".format(FILTER_PLUGIN)) - def test_end_to_end(self, start_south_north_with_filter, read_data_from_pi, fledge_url, pi_host, pi_admin, + def test_end_to_end(self, start_south_north_with_filter, update_stat_collection, read_data_from_pi, fledge_url, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, skip_verify_north_interface): subprocess.run(["cd $FLEDGE_ROOT/extras/python; python3 -m fogbench -t ../../data/template.json -p http; cd -"] diff --git a/tests/system/python/e2e/test_e2e_vary_asset_http_pi.py b/tests/system/python/e2e/test_e2e_vary_asset_http_pi.py index 8267cf3515..67fcb52c35 100644 --- a/tests/system/python/e2e/test_e2e_vary_asset_http_pi.py +++ b/tests/system/python/e2e/test_e2e_vary_asset_http_pi.py @@ -120,7 +120,7 @@ def start_south_north(self, reset_and_start_fledge, add_south, start_north_pi_se # Cleanup code that runs after the caller test is over remove_directories("/tmp/fledge-south-{}".format(south_plugin)) - def test_end_to_end(self, start_south_north, read_data_from_pi, fledge_url, pi_host, pi_admin, pi_passwd, pi_db, + def test_end_to_end(self, start_south_north, update_stat_collection, read_data_from_pi, fledge_url, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, skip_verify_north_interface): """ Test that data is inserted in Fledge and sent to PI start_south_north: Fixture that starts Fledge with south and north instance diff --git a/tests/system/python/smoke/test_smoke.py b/tests/system/python/smoke/test_smoke.py index eb2c0a3a4b..1a40a09a17 100644 --- a/tests/system/python/smoke/test_smoke.py +++ b/tests/system/python/smoke/test_smoke.py @@ -72,7 +72,7 @@ def start_south_coap(reset_and_start_fledge, add_south, remove_data_file, remove remove_directories("/tmp/fledge-south-{}".format(south_plugin)) -def test_smoke(start_south_coap, fledge_url, wait_time, asset_name="smoke"): +def test_smoke(start_south_coap, update_stat_collection, fledge_url, wait_time, asset_name="smoke"): """ Test that data is inserted in Fledge start_south_coap: Fixture that starts Fledge with south coap plugin Assertions: From 7b89fe141c30efe3478ab9d09b3b1c27d9143785 Mon Sep 17 00:00:00 2001 From: Mohit Singh Tomar Date: Wed, 11 Oct 2023 13:22:18 +0530 Subject: [PATCH 05/12] Updated e2e/test_e2e_coap_PI.py test Signed-off-by: Mohit Singh Tomar --- tests/system/python/e2e/test_e2e_coap_PI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/python/e2e/test_e2e_coap_PI.py b/tests/system/python/e2e/test_e2e_coap_PI.py index bfc70cf069..302f084def 100644 --- a/tests/system/python/e2e/test_e2e_coap_PI.py +++ b/tests/system/python/e2e/test_e2e_coap_PI.py @@ -106,7 +106,7 @@ def start_south_north(reset_and_start_fledge, add_south, start_north_pi_server_c class TestE2E_CoAP_PI: - def test_end_to_end(self, start_south_north, read_data_from_pi, fledge_url, pi_host, pi_admin, pi_passwd, pi_db, + def test_end_to_end(self, start_south_north, update_stat_collection, read_data_from_pi, fledge_url, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, skip_verify_north_interface, asset_name=ASSET_NAME): """ Test that data is inserted in Fledge and sent to PI start_south_north: Fixture that starts Fledge with south and north instance From 2ffdbf76779687b1e7a6e058d388ed4b892f4eb5 Mon Sep 17 00:00:00 2001 From: Mohit Singh Tomar Date: Wed, 11 Oct 2023 16:10:52 +0530 Subject: [PATCH 06/12] Added code for updating stat collection of remote system properly Signed-off-by: Mohit Singh Tomar --- .../python/pair/test_c_north_service_pair.py | 32 ++++++++++++----- .../python/pair/test_e2e_fledge_pair.py | 36 +++++++++++++------ .../pair/test_pyton_north_service_pair.py | 34 +++++++++++++----- 3 files changed, 75 insertions(+), 27 deletions(-) diff --git a/tests/system/python/pair/test_c_north_service_pair.py b/tests/system/python/pair/test_c_north_service_pair.py index 1659e80241..7e903a0e1c 100644 --- a/tests/system/python/pair/test_c_north_service_pair.py +++ b/tests/system/python/pair/test_c_north_service_pair.py @@ -15,6 +15,7 @@ import time import urllib.parse from pathlib import Path +from urllib.parse import quote import pytest import utils @@ -44,6 +45,22 @@ AF_HIERARCHY_LEVEL = "Cservicepair/Cservicepairlvl1/Cservicepairlvl2" +def update_stat_collection_remote(fledge_url, wait_time): + """Update the Stat colectioin of all south service to per asset & service""" + + # Wait for the south service to be created + time.sleep(wait_time) + service_response_list = list() + response = utils.get_request(fledge_url, "/fledge/south") + + for service in response["services"]: + put_url = "/fledge/category/{}Advanced".format(service["name"]) + payload = {"statistics": "per asset & service"} + res = utils.put_request(fledge_url, quote(put_url), payload) + service_response_list.append(res) + + return service_response_list + @pytest.fixture def reset_fledge_local(wait_time): try: @@ -54,12 +71,11 @@ def reset_fledge_local(wait_time): @pytest.fixture -def setup_local(reset_fledge_local, add_south, add_north, update_stat_collection, fledge_url, remote_ip, wait_time): +def setup_local(reset_fledge_local, add_south, add_north, fledge_url, remote_ip): local_south_config = {"assetName": {"value": remote_south_asset_name}} add_south(local_south_plugin, None, fledge_url, config=local_south_config, service_name="{}".format(local_south_service_name), installation_type='package') - update_stat_collection(fledge_url, wait_time) # Change name of variables such as service_name, plugin_type global north_schedule_id local_north_config = {"URL": {"value": "http://{}:6683/sensor-reading".format(remote_ip)}} @@ -122,7 +138,7 @@ def clean_install_fledge_packages_remote(remote_user, remote_ip, key_path, remot @pytest.fixture def setup_remote(reset_fledge_remote, remote_user, remote_ip, start_north_omf_as_a_service, - pi_host, pi_port, pi_admin, pi_passwd, update_stat_collection, + pi_host, pi_port, pi_admin, pi_passwd, wait_time, clear_pi_system_through_pi_web_api, pi_db): """Fixture that setups remote machine reset_fledge_remote: Fixture that kills fledge, reset database and starts fledge again on a remote @@ -156,9 +172,9 @@ def setup_remote(reset_fledge_remote, remote_user, remote_ip, start_north_omf_as r = r.read().decode() retval = json.loads(r) assert remote_south_service_name == retval["name"] - - update_stat_collection(fledge_url, wait_time) + update_stat_collection_remote(fledge_url, wait_time) + # Configure pi north plugin on remote machine global remote_north_schedule_id response = start_north_omf_as_a_service(fledge_url, pi_host, pi_port, pi_user=pi_admin, pi_pwd=pi_passwd, @@ -276,7 +292,7 @@ def _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_d class TestCNorthService: def test_north_C_service_with_restart(self, clean_setup_fledge_packages, clean_install_fledge_packages_remote, - setup_local, setup_remote, skip_verify_north_interface, fledge_url, + setup_local, setup_remote, update_stat_collection, skip_verify_north_interface, fledge_url, wait_time, retries, remote_ip, read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_db): """ Test C plugin as a North service before and after restarting fledge. @@ -341,7 +357,7 @@ def test_north_C_service_with_restart(self, clean_setup_fledge_packages, clean_i _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, remote_south_asset_name) - def test_north_C_service_with_enable_disable(self, setup_local, setup_remote, read_data_from_pi_web_api, + def test_north_C_service_with_enable_disable(self, setup_local, setup_remote, update_stat_collection, read_data_from_pi_web_api, remote_ip, skip_verify_north_interface, fledge_url, wait_time, retries, pi_host, @@ -760,4 +776,4 @@ def test_north_C_service_with_filter_reorder(self, setup_local, setup_remote, re assert old_ping_result['dataSent'] < new_ping_result['dataSent'] assert old_ping_result_remote['dataSent'] < new_ping_result_remote['dataSent'] _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, - remote_south_asset_name) + remote_south_asset_name) \ No newline at end of file diff --git a/tests/system/python/pair/test_e2e_fledge_pair.py b/tests/system/python/pair/test_e2e_fledge_pair.py index ef4e874e98..c5377a6870 100644 --- a/tests/system/python/pair/test_e2e_fledge_pair.py +++ b/tests/system/python/pair/test_e2e_fledge_pair.py @@ -18,7 +18,7 @@ import pytest from collections import Counter import utils - +from urllib.parse import quote __author__ = "Vaibhav Singhal" __copyright__ = "Copyright (c) 2019 Dianomic Systems" @@ -36,6 +36,22 @@ class TestE2eFogPairPi: + def update_stat_collection_remote(fledge_url, wait_time): + """Update the Stat colectioin of all south service to per asset & service""" + + # Wait for the south service to be created + time.sleep(wait_time) + service_response_list = list() + response = utils.get_request(fledge_url, "/fledge/south") + + for service in response["services"]: + put_url = "/fledge/category/{}Advanced".format(service["name"]) + payload = {"statistics": "per asset & service"} + res = utils.put_request(fledge_url, quote(put_url), payload) + service_response_list.append(res) + + return service_response_list + def get_asset_list(self, fledge_url): _connection = http.client.HTTPConnection(fledge_url) _connection.request("GET", '/fledge/asset') @@ -95,8 +111,8 @@ def reset_and_start_fledge_remote(self, storage_plugin, remote_user, remote_ip, @pytest.fixture def start_south_north_remote(self, reset_and_start_fledge_remote, use_pip_cache, remote_user, - key_path, remote_fledge_path, remote_ip, south_branch, update_stat_collection, - start_north_pi_server_c, pi_host, pi_port, pi_token, wait_time, + key_path, remote_fledge_path, remote_ip, south_branch, wait_time, + start_north_pi_server_c, pi_host, pi_port, pi_token, clear_pi_system_through_pi_web_api, pi_admin, pi_passwd, pi_db): """Fixture that starts south and north plugins on remote machine reset_and_start_fledge_remote: Fixture that kills fledge, reset database and starts fledge again on a remote machine @@ -151,9 +167,9 @@ def start_south_north_remote(self, reset_and_start_fledge_remote, use_pip_cache, r = r.read().decode() retval = json.loads(r) assert south_service == retval["name"] - - update_stat_collection(fledge_url, wait_time) + update_stat_collection_remote(fledge_url, wait_time) + # Configure pi north plugin on remote machine start_north_pi_server_c(fledge_url, pi_host, pi_port, pi_token) @@ -190,8 +206,8 @@ def configure_and_start_north_http(self, north_branch, fledge_url, remote_ip, ta @pytest.fixture def start_south_north_local(self, reset_and_start_fledge, add_south, enable_schedule, remove_directories, - remove_data_file, south_branch, north_branch, fledge_url, remote_ip, wait_time, - add_filter, filter_branch, update_stat_collection): + remove_data_file, south_branch, north_branch, fledge_url, remote_ip, + add_filter, filter_branch): """ This fixture clone a south and north repo and starts both south and north instance reset_and_start_fledge: Fixture that resets and starts fledge, no explicit invocation, called at start @@ -249,8 +265,6 @@ def start_south_north_local(self, reset_and_start_fledge, add_south, enable_sche enable_schedule(fledge_url, "fogpair_sine") enable_schedule(fledge_url, "NorthReadingsToHTTP") - update_stat_collection(fledge_url, wait_time) - yield self.start_south_north_local # Cleanup @@ -285,7 +299,7 @@ def _verify_egress(self, read_data_from_pi, pi_host, pi_admin, pi_passwd, pi_db, assert Counter(data_from_pi[CSV_HEADERS][-len(expected_read_values):]) == Counter(expected_read_values) - def test_end_to_end(self, start_south_north_remote, start_south_north_local, + def test_end_to_end(self, start_south_north_remote, start_south_north_local, update_stat_collection, read_data_from_pi, retries, pi_host, pi_admin, pi_passwd, pi_db, fledge_url, remote_ip, wait_time, skip_verify_north_interface): """ Test that data is inserted in Fledge (local instance) using playback south plugin, @@ -367,4 +381,4 @@ def test_end_to_end(self, start_south_north_remote, start_south_north_local, if not skip_verify_north_interface: self._verify_egress(read_data_from_pi, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, - expected_read_values) + expected_read_values) \ No newline at end of file diff --git a/tests/system/python/pair/test_pyton_north_service_pair.py b/tests/system/python/pair/test_pyton_north_service_pair.py index 260b7273fc..523bc17e08 100644 --- a/tests/system/python/pair/test_pyton_north_service_pair.py +++ b/tests/system/python/pair/test_pyton_north_service_pair.py @@ -15,6 +15,7 @@ import time import urllib.parse from pathlib import Path +from urllib.parse import quote import pytest import utils @@ -44,6 +45,22 @@ AF_HIERARCHY_LEVEL = "pythonnorthservicepair/pythonnorthservicepairlvl2/pythonnorthservicepairlvl3" +def update_stat_collection_remote(fledge_url, wait_time): + """Update the Stat colectioin of all south service to per asset & service""" + + # Wait for the south service to be created + time.sleep(wait_time) + service_response_list = list() + response = utils.get_request(fledge_url, "/fledge/south") + + for service in response["services"]: + put_url = "/fledge/category/{}Advanced".format(service["name"]) + payload = {"statistics": "per asset & service"} + res = utils.put_request(fledge_url, quote(put_url), payload) + service_response_list.append(res) + + return service_response_list + @pytest.fixture def reset_fledge_local(wait_time): try: @@ -54,12 +71,11 @@ def reset_fledge_local(wait_time): @pytest.fixture -def setup_local(reset_fledge_local, add_south, add_north, update_stat_collection, wait_time, fledge_url, remote_ip): +def setup_local(reset_fledge_local, add_south, add_north, fledge_url, remote_ip): local_south_config = {"assetName": {"value": local_south_asset_name}} add_south(local_south_plugin, None, fledge_url, config=local_south_config, service_name="{}".format(local_south_service_name), installation_type='package') - update_stat_collection(fledge_url, wait_time) # Change name of variables such as service_name, plugin_type global north_schedule_id local_north_config = {"url": {"value": "http://{}:6683/sensor-reading".format(remote_ip)}} @@ -123,7 +139,7 @@ def clean_install_fledge_packages_remote(remote_user, remote_ip, key_path, remot @pytest.fixture def setup_remote(reset_fledge_remote, remote_user, remote_ip, start_north_omf_as_a_service, - pi_host, pi_port, pi_admin, pi_passwd, update_stat_collection, wait_time, + pi_host, pi_port, pi_admin, pi_passwd, wait_time, clear_pi_system_through_pi_web_api, pi_db): """Fixture that setups remote machine reset_fledge_remote: Fixture that kills fledge, reset database and starts fledge again on a remote @@ -157,7 +173,9 @@ def setup_remote(reset_fledge_remote, remote_user, remote_ip, start_north_omf_as r = r.read().decode() retval = json.loads(r) assert remote_south_service_name == retval["name"] - update_stat_collection(fledge_url, wait_time) + + update_stat_collection_remote(fledge_url, wait_time) + # Configure pi north plugin on remote machine global remote_north_schedule_id response = start_north_omf_as_a_service(fledge_url, pi_host, pi_port, pi_user=pi_admin, pi_pwd=pi_passwd, @@ -275,7 +293,7 @@ def _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_d class TestPythonNorthService: def test_north_python_service_with_restart(self, clean_setup_fledge_packages, clean_install_fledge_packages_remote, - setup_local, setup_remote, skip_verify_north_interface, fledge_url, + setup_local, setup_remote, update_stat_collection, skip_verify_north_interface, fledge_url, wait_time, retries, remote_ip, read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_db): """ Test python plugin as a North service before and after restarting fledge. @@ -340,8 +358,8 @@ def test_north_python_service_with_restart(self, clean_setup_fledge_packages, cl _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, remote_south_asset_name) - def test_north_python_service_with_enable_disable(self, setup_local, setup_remote, read_data_from_pi_web_api, - remote_ip, + def test_north_python_service_with_enable_disable(self, setup_local, setup_remote, update_stat_collection, read_data_from_pi_web_api, + remote_ip, skip_verify_north_interface, fledge_url, wait_time, retries, pi_host, pi_admin, pi_passwd, pi_db): @@ -760,4 +778,4 @@ def test_north_python_service_with_filter_reorder(self, setup_local, setup_remot assert old_ping_result['dataSent'] < new_ping_result['dataSent'] assert old_ping_result_remote['dataSent'] < new_ping_result_remote['dataSent'] _verify_egress(read_data_from_pi_web_api, pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, - remote_south_asset_name) + remote_south_asset_name) \ No newline at end of file From 40817d5d96fb4f68a724d42c2fec50350a3f36c9 Mon Sep 17 00:00:00 2001 From: Mohit Singh Tomar Date: Wed, 11 Oct 2023 20:17:33 +0530 Subject: [PATCH 07/12] Minor fix Signed-off-by: Mohit Singh Tomar --- tests/system/python/pair/test_e2e_fledge_pair.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/python/pair/test_e2e_fledge_pair.py b/tests/system/python/pair/test_e2e_fledge_pair.py index c5377a6870..5a820bb768 100644 --- a/tests/system/python/pair/test_e2e_fledge_pair.py +++ b/tests/system/python/pair/test_e2e_fledge_pair.py @@ -168,7 +168,7 @@ def start_south_north_remote(self, reset_and_start_fledge_remote, use_pip_cache, retval = json.loads(r) assert south_service == retval["name"] - update_stat_collection_remote(fledge_url, wait_time) + self.update_stat_collection_remote(fledge_url, wait_time) # Configure pi north plugin on remote machine start_north_pi_server_c(fledge_url, pi_host, pi_port, pi_token) From d34b7d4fdf04e22b3d3925cd433c88b948db258f Mon Sep 17 00:00:00 2001 From: Mohit Singh Tomar Date: Thu, 12 Oct 2023 14:06:14 +0530 Subject: [PATCH 08/12] Refactored Code Signed-off-by: Mohit Singh Tomar --- tests/system/python/e2e/test_e2e_csv_PI.py | 5 +++-- .../system/python/e2e/test_e2e_csv_multi_filter_pi.py | 10 +++++----- .../system/python/e2e/test_e2e_filter_fft_threshold.py | 10 +++++----- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/tests/system/python/e2e/test_e2e_csv_PI.py b/tests/system/python/e2e/test_e2e_csv_PI.py index 038ff56a97..04321ccd7f 100644 --- a/tests/system/python/e2e/test_e2e_csv_PI.py +++ b/tests/system/python/e2e/test_e2e_csv_PI.py @@ -104,7 +104,7 @@ def start_south_north(reset_and_start_fledge, add_south, start_north_pi_server_c _data_str[_head] = tmp_list south_plugin = "playback" - add_south(south_plugin, south_branch, fledge_url, config=south_config) + add_south(south_plugin, south_branch, fledge_url, config=south_config, start_service=False) start_north_pi_server_c(fledge_url, pi_host, pi_port, pi_token) yield start_south_north @@ -132,7 +132,7 @@ def _verify_egress(read_data_from_pi, pi_host, pi_admin, pi_passwd, pi_db, wait_ class TestE2E_CSV_PI: def test_e2e_csv_pi(self, start_south_north, update_stat_collection, read_data_from_pi, fledge_url, pi_host, pi_admin, pi_passwd, pi_db, - wait_time, retries, skip_verify_north_interface, asset_name="end_to_end_csv"): + enable_schedule, wait_time, retries, skip_verify_north_interface, asset_name="end_to_end_csv"): """ Test that data is inserted in Fledge and sent to PI start_south_north: Fixture that starts Fledge with south and north instance read_data_from_pi: Fixture to read data from PI @@ -143,6 +143,7 @@ def test_e2e_csv_pi(self, start_south_north, update_stat_collection, read_data_f data received from PI is same as data sent""" conn = http.client.HTTPConnection(fledge_url) + enable_schedule(fledge_url, "play") # Time to wait until north schedule runs time.sleep(wait_time * math.ceil(15/wait_time) + 15) diff --git a/tests/system/python/e2e/test_e2e_csv_multi_filter_pi.py b/tests/system/python/e2e/test_e2e_csv_multi_filter_pi.py index 213480cb9d..102e906cc1 100644 --- a/tests/system/python/e2e/test_e2e_csv_multi_filter_pi.py +++ b/tests/system/python/e2e/test_e2e_csv_multi_filter_pi.py @@ -125,10 +125,6 @@ def start_south_north(self, reset_and_start_fledge, add_south, enable_schedule, filter_cfg_meta = {"enable": "true"} add_filter("metadata", filter_branch, "fmeta", filter_cfg_meta, fledge_url, SVC_NAME) - # Since playback plugin reads all csv data at once, we cant keep it in enable mode before filter add - # enable service when all filters all applied - enable_schedule(fledge_url, SVC_NAME) - start_north_pi_server_c(fledge_url, pi_host, pi_port, pi_token) yield self.start_south_north @@ -141,7 +137,7 @@ def start_south_north(self, reset_and_start_fledge, add_south, enable_schedule, remove_data_file(csv_file_path) def test_end_to_end(self, start_south_north, update_stat_collection, disable_schedule, fledge_url, read_data_from_pi, pi_host, pi_admin, - pi_passwd, pi_db, wait_time, retries, skip_verify_north_interface): + enable_schedule, pi_passwd, pi_db, wait_time, retries, skip_verify_north_interface): """ Test that data is inserted in Fledge using playback south plugin & Delta, RMS, Rate, Scale, Asset & Metadata filters, and sent to PI start_south_north: Fixture that starts Fledge with south service, add filter and north instance @@ -151,6 +147,10 @@ def test_end_to_end(self, start_south_north, update_stat_collection, disable_sch on endpoint GET /fledge/asset/ with applied data processing filter value data received from PI is same as data sent""" + # Since playback plugin reads all csv data at once, we cant keep it in enable mode before filter add + # enable service when all filters all applied + enable_schedule(fledge_url, SVC_NAME) + # Time to wait until north schedule runs time.sleep(wait_time * math.ceil(15/wait_time) + 15) conn = http.client.HTTPConnection(fledge_url) diff --git a/tests/system/python/e2e/test_e2e_filter_fft_threshold.py b/tests/system/python/e2e/test_e2e_filter_fft_threshold.py index beef6ca79a..ab7d9bf765 100644 --- a/tests/system/python/e2e/test_e2e_filter_fft_threshold.py +++ b/tests/system/python/e2e/test_e2e_filter_fft_threshold.py @@ -106,10 +106,6 @@ def start_south_north(self, reset_and_start_fledge, add_south, enable_schedule, filter_cfg_fft = {"asset": ASSET, "lowPass": "10", "highPass": "30", "enable": "true"} add_filter("fft", filter_branch, "FFT Filter", filter_cfg_fft, fledge_url, SVC_NAME) - # Since playback plugin reads all csv data at once, we cant keep it in enable mode before filter add - # enable service when all filters all applied - enable_schedule(fledge_url, SVC_NAME) - start_north_pi_server_c(fledge_url, pi_host, pi_port, pi_token, taskname=NORTH_TASK_NAME, start_task=False) @@ -129,7 +125,7 @@ def start_south_north(self, reset_and_start_fledge, add_south, enable_schedule, remove_data_file(csv_dest) def test_end_to_end(self, start_south_north, update_stat_collection, disable_schedule, fledge_url, read_data_from_pi, pi_host, pi_admin, - pi_passwd, pi_db, wait_time, retries, skip_verify_north_interface): + enable_schedule, pi_passwd, pi_db, wait_time, retries, skip_verify_north_interface): """ Test that data is inserted in Fledge using playback south plugin & FFT filter, and sent to PI after passing through threshold filter start_south_north: Fixture that starts Fledge with south service, add filter and north instance @@ -139,6 +135,10 @@ def test_end_to_end(self, start_south_north, update_stat_collection, disable_sch on endpoint GET /fledge/asset/ with applied data processing filter value data received from PI is same as data sent""" + # Since playback plugin reads all csv data at once, we cant keep it in enable mode before filter add + # enable service when all filters all applied + enable_schedule(fledge_url, SVC_NAME) + # Time to wait until north schedule runs time.sleep(wait_time * math.ceil(15/wait_time) + 15) conn = http.client.HTTPConnection(fledge_url) From 61a096a375388397fd666c463c8d41c276612ab0 Mon Sep 17 00:00:00 2001 From: Mohit Singh Tomar Date: Thu, 12 Oct 2023 15:07:34 +0530 Subject: [PATCH 09/12] Refactored Code -2 Signed-off-by: Mohit Singh Tomar --- tests/system/python/e2e/test_e2e_kafka.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/python/e2e/test_e2e_kafka.py b/tests/system/python/e2e/test_e2e_kafka.py index 90d1ff90cb..a0df9a49ab 100644 --- a/tests/system/python/e2e/test_e2e_kafka.py +++ b/tests/system/python/e2e/test_e2e_kafka.py @@ -83,7 +83,7 @@ def _configure_and_start_north_kafka(self, north_branch, fledge_url, host, port, "schedule_type": 3, "schedule_day": 0, "schedule_time": 0, - "schedule_repeat": 0, + "schedule_repeat": 5, "schedule_enabled": "true", "config": {"topic": {"value": topic}, "brokers": {"value": "{}:{}".format(host, port)}} From 92a53d01b9949e016bb3e2be3dd1852a7128a387 Mon Sep 17 00:00:00 2001 From: Mohit Singh Tomar Date: Thu, 12 Oct 2023 16:41:38 +0530 Subject: [PATCH 10/12] Feedback changes Signed-off-by: Mohit Singh Tomar --- tests/system/python/packages/test_filters.py | 2 +- tests/system/python/pair/test_e2e_fledge_pair.py | 2 +- tests/system/python/smoke/test_smoke.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/system/python/packages/test_filters.py b/tests/system/python/packages/test_filters.py index 71c2fc7e5c..ec8aab58bb 100644 --- a/tests/system/python/packages/test_filters.py +++ b/tests/system/python/packages/test_filters.py @@ -120,7 +120,7 @@ def verify_readings(fledge_url, asset_name): class TestPython35: def test_filter_python35_with_uploaded_script(self, clean_setup_fledge_packages, reset_fledge, - add_south_http_with_filter, update_stat_collection, fledge_url, wait_time): + add_south_http_with_filter, fledge_url, wait_time): # Wait until south service is created time.sleep(wait_time * 2) verify_south_added(fledge_url, HTTP_SOUTH_SVC_NAME) diff --git a/tests/system/python/pair/test_e2e_fledge_pair.py b/tests/system/python/pair/test_e2e_fledge_pair.py index 5a820bb768..0b7452f983 100644 --- a/tests/system/python/pair/test_e2e_fledge_pair.py +++ b/tests/system/python/pair/test_e2e_fledge_pair.py @@ -36,7 +36,7 @@ class TestE2eFogPairPi: - def update_stat_collection_remote(fledge_url, wait_time): + def update_stat_collection_remote(self, fledge_url, wait_time): """Update the Stat colectioin of all south service to per asset & service""" # Wait for the south service to be created diff --git a/tests/system/python/smoke/test_smoke.py b/tests/system/python/smoke/test_smoke.py index 1a40a09a17..eb2c0a3a4b 100644 --- a/tests/system/python/smoke/test_smoke.py +++ b/tests/system/python/smoke/test_smoke.py @@ -72,7 +72,7 @@ def start_south_coap(reset_and_start_fledge, add_south, remove_data_file, remove remove_directories("/tmp/fledge-south-{}".format(south_plugin)) -def test_smoke(start_south_coap, update_stat_collection, fledge_url, wait_time, asset_name="smoke"): +def test_smoke(start_south_coap, fledge_url, wait_time, asset_name="smoke"): """ Test that data is inserted in Fledge start_south_coap: Fixture that starts Fledge with south coap plugin Assertions: From 923582a103369e54587ebb8c3bf478db76ddc735 Mon Sep 17 00:00:00 2001 From: Mohit Singh Tomar Date: Fri, 13 Oct 2023 13:41:26 +0530 Subject: [PATCH 11/12] Feedback changes Signed-off-by: Mohit Singh Tomar --- tests/system/python/conftest.py | 4 ++-- .../python/pair/test_c_north_service_pair.py | 5 ++--- tests/system/python/pair/test_e2e_fledge_pair.py | 15 +++++++++------ .../python/pair/test_pyton_north_service_pair.py | 5 ++--- tests/system/python/smoke/test_smoke.py | 2 +- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/tests/system/python/conftest.py b/tests/system/python/conftest.py index 3562fb6e44..a622d67976 100644 --- a/tests/system/python/conftest.py +++ b/tests/system/python/conftest.py @@ -218,9 +218,9 @@ def clone_make_install(): @pytest.fixture def update_stat_collection(fledge_url, wait_time): - """Update the Stat colectioin of all south service to per asset & service""" + """Update the Statistics Collection of all south service to per asset & service""" - # Wait for the south service to be created + # Wait for the south service and advanced category to be created time.sleep(wait_time) service_response_list = list() response = utils.get_request(fledge_url, "/fledge/south") diff --git a/tests/system/python/pair/test_c_north_service_pair.py b/tests/system/python/pair/test_c_north_service_pair.py index 7e903a0e1c..1d4810890b 100644 --- a/tests/system/python/pair/test_c_north_service_pair.py +++ b/tests/system/python/pair/test_c_north_service_pair.py @@ -15,7 +15,6 @@ import time import urllib.parse from pathlib import Path -from urllib.parse import quote import pytest import utils @@ -46,7 +45,7 @@ def update_stat_collection_remote(fledge_url, wait_time): - """Update the Stat colectioin of all south service to per asset & service""" + """Update the Statistics Collection of all south service to per asset & service""" # Wait for the south service to be created time.sleep(wait_time) @@ -56,7 +55,7 @@ def update_stat_collection_remote(fledge_url, wait_time): for service in response["services"]: put_url = "/fledge/category/{}Advanced".format(service["name"]) payload = {"statistics": "per asset & service"} - res = utils.put_request(fledge_url, quote(put_url), payload) + res = utils.put_request(fledge_url, urllib.parse.quote(put_url), payload) service_response_list.append(res) return service_response_list diff --git a/tests/system/python/pair/test_e2e_fledge_pair.py b/tests/system/python/pair/test_e2e_fledge_pair.py index 0b7452f983..4542383472 100644 --- a/tests/system/python/pair/test_e2e_fledge_pair.py +++ b/tests/system/python/pair/test_e2e_fledge_pair.py @@ -37,7 +37,7 @@ class TestE2eFogPairPi: def update_stat_collection_remote(self, fledge_url, wait_time): - """Update the Stat colectioin of all south service to per asset & service""" + """Update the Statistics Collection of all south service to per asset & service""" # Wait for the south service to be created time.sleep(wait_time) @@ -259,10 +259,8 @@ def start_south_north_local(self, reset_and_start_fledge, add_south, enable_sche "defaultAction": "exclude"}, "enable": "true"} add_filter("asset", filter_branch, "fasset", filter_cfg_asset, fledge_url, "NorthReadingsToHTTP") - # Enable all south and north schedules - enable_schedule(fledge_url, "fogpair_playbk") - enable_schedule(fledge_url, "fogpair_expr") - enable_schedule(fledge_url, "fogpair_sine") + + # Enable north schedule enable_schedule(fledge_url, "NorthReadingsToHTTP") yield self.start_south_north_local @@ -300,7 +298,7 @@ def _verify_egress(self, read_data_from_pi, pi_host, pi_admin, pi_passwd, pi_db, assert Counter(data_from_pi[CSV_HEADERS][-len(expected_read_values):]) == Counter(expected_read_values) def test_end_to_end(self, start_south_north_remote, start_south_north_local, update_stat_collection, - read_data_from_pi, retries, pi_host, pi_admin, pi_passwd, pi_db, + read_data_from_pi, retries, pi_host, pi_admin, pi_passwd, pi_db, enable_schedule, fledge_url, remote_ip, wait_time, skip_verify_north_interface): """ Test that data is inserted in Fledge (local instance) using playback south plugin, sinusoid south plugin and expression south plugin and sent to http north (filter only playback data), @@ -322,6 +320,11 @@ def test_end_to_end(self, start_south_north_remote, start_south_north_local, upd on endpoint GET /fledge/asset/ with applied data processing filter value data received from PI is same as data sent""" + # Enable all south schedules + enable_schedule(fledge_url, "fogpair_playbk") + enable_schedule(fledge_url, "fogpair_expr") + enable_schedule(fledge_url, "fogpair_sine") + # Wait for data to be sent to Fledge instance 2 and then to PI time.sleep(wait_time * 3) diff --git a/tests/system/python/pair/test_pyton_north_service_pair.py b/tests/system/python/pair/test_pyton_north_service_pair.py index 523bc17e08..307736dfb2 100644 --- a/tests/system/python/pair/test_pyton_north_service_pair.py +++ b/tests/system/python/pair/test_pyton_north_service_pair.py @@ -15,7 +15,6 @@ import time import urllib.parse from pathlib import Path -from urllib.parse import quote import pytest import utils @@ -46,7 +45,7 @@ def update_stat_collection_remote(fledge_url, wait_time): - """Update the Stat colectioin of all south service to per asset & service""" + """Update the Statistics Collection of all south service to per asset & service""" # Wait for the south service to be created time.sleep(wait_time) @@ -56,7 +55,7 @@ def update_stat_collection_remote(fledge_url, wait_time): for service in response["services"]: put_url = "/fledge/category/{}Advanced".format(service["name"]) payload = {"statistics": "per asset & service"} - res = utils.put_request(fledge_url, quote(put_url), payload) + res = utils.put_request(fledge_url, urllib.parse.quote(put_url), payload) service_response_list.append(res) return service_response_list diff --git a/tests/system/python/smoke/test_smoke.py b/tests/system/python/smoke/test_smoke.py index eb2c0a3a4b..fd689b64c6 100644 --- a/tests/system/python/smoke/test_smoke.py +++ b/tests/system/python/smoke/test_smoke.py @@ -91,8 +91,8 @@ def test_smoke(start_south_coap, fledge_url, wait_time, asset_name="smoke"): assert 0 == ping_response["dataSent"] actual_stats_map = get_statistics_map(fledge_url) - assert 1 == actual_stats_map[asset_name.upper()] assert 1 == actual_stats_map['READINGS'] + assert asset_name.upper() not in actual_stats_map conn.request("GET", '/fledge/asset') r = conn.getresponse() From 35fe1970cd1c88189f6ae9f41ea5ab91671bf59a Mon Sep 17 00:00:00 2001 From: Mohit Singh Tomar Date: Fri, 13 Oct 2023 13:56:46 +0530 Subject: [PATCH 12/12] Minor fix Signed-off-by: Mohit Singh Tomar --- tests/system/python/pair/test_e2e_fledge_pair.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/python/pair/test_e2e_fledge_pair.py b/tests/system/python/pair/test_e2e_fledge_pair.py index 4542383472..067352330b 100644 --- a/tests/system/python/pair/test_e2e_fledge_pair.py +++ b/tests/system/python/pair/test_e2e_fledge_pair.py @@ -326,7 +326,7 @@ def test_end_to_end(self, start_south_north_remote, start_south_north_local, upd enable_schedule(fledge_url, "fogpair_sine") # Wait for data to be sent to Fledge instance 2 and then to PI - time.sleep(wait_time * 3) + time.sleep(wait_time * 4) # Fledge Instance 1 (Local) verification expected_asset_list = ["Expression", "fogpair_playback", "sinusoid"]