diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index 5ccb3f662..49b0085d7 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -32,8 +32,13 @@ jobs: - name: Run exclusion list class test run: pytest -s plugins/pdr_deterministic_plugin/tests/exclude_list_class_tests.py -# - name: Test exclusion list REST API of pytest -# run: pytest plugins/pdr_deterministic_plugin/tests/exclude_list_rest_api_tests.py + - name: Test exclusion list REST API of pytest + run: | + sudo bash plugins/pdr_deterministic_plugin/.pytest/run_pdr_standalone_pytest.sh + echo "Test exclusion list REST API methods" + pytest plugins/pdr_deterministic_plugin/tests/exclude_list_rest_api_tests.py + echo "Terminating standalone PDR process" + pkill -9 -f isolation_algo.py 2>/dev/null || true - name: Run full simulation test run: | diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_class_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_class_tests.py index 660d36387..0c03cc25d 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_class_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_class_tests.py @@ -45,7 +45,7 @@ def test_exclude_list_class_methods(): exclude_list = ExcludeList(get_logger()) items = exclude_list.items() assert not items - print(" - Create exclusion list and ensure it's empty -- PASS") + print(" - test: create exclusion list and ensure it's empty -- PASS") # Add ports to excluded list for port in excluded_ports: @@ -54,24 +54,24 @@ def test_exclude_list_class_methods(): # Test exclusion list size items = exclude_list.items() assert items and len(items) == len(excluded_ports) - print(" - Add ports to exclusion list -- PASS") + print(" - test: add ports to exclusion list -- PASS") # Test 'contains' method for port in excluded_ports: assert exclude_list.contains(port.port_name) - print(" - Test exclusion list 'contains' method -- PASS") + print(" - test: exclusion list 'contains' method -- PASS") # Test exclusion list content for (index, item) in enumerate(items): assert item.port_name == excluded_ports[index].port_name assert item.ttl_seconds == excluded_ports[index].ttl_seconds - print(" - Test exclusion list content -- PASS") + print(" - test: exclusion list content -- PASS") # Test auto-remove of second port after TTL is expired auto_remove_port = excluded_ports[1] time.sleep(auto_remove_port.ttl_seconds + 1) assert not exclude_list.contains(auto_remove_port.port_name) - print(" - Test auto-remove of port from exclusion list after TTL is expired -- PASS") + print(" - test: auto-remove of port from exclusion list after TTL is expired -- PASS") # Test excluded list size items = exclude_list.items() @@ -81,13 +81,13 @@ def test_exclude_list_class_methods(): for port in excluded_ports: if port.port_name != auto_remove_port.port_name: assert exclude_list.contains(port.port_name) - print(" - Test exclusion list content -- PASS") + print(" - test: exclusion list content -- PASS") # Test forced remove of third port remove_port = excluded_ports[2] exclude_list.remove(port.port_name) assert not exclude_list.contains(remove_port.port_name) - print(" - Test forced remove of port from exclusion list -- PASS") + print(" - test: forced remove of port from exclusion list -- PASS") # Test excluded list size items = exclude_list.items() @@ -97,7 +97,7 @@ def test_exclude_list_class_methods(): for port in excluded_ports: if port.port_name != remove_port.port_name and port.port_name != auto_remove_port.port_name: assert exclude_list.contains(port.port_name) - print(" - Test exclusion list content -- PASS") + print(" - test: exclusion list content -- PASS") if __name__ == '__main__': diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_rest_api_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_rest_api_tests.py index c03c735b3..ccda219cc 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_rest_api_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_rest_api_tests.py @@ -17,18 +17,7 @@ import time import pytest import requests -from constants import PDRConstants as Constants -from exclude_list import ExcludeList, ExcludeListItem -from isolation_algo import create_logger - - -def get_logger(): - """ - Return logger associated with log file in temporary directory - """ - log_name = os.path.basename(Constants.LOG_FILE) - log_path = os.path.join(tempfile.gettempdir(), log_name) - return create_logger(log_path) +from exclude_list import ExcludeListItem pytest.mark.run(order=0)