diff --git a/emulation-system/tests/test_start_client_manager.py b/emulation-system/tests/test_start_client_manager.py index bdda46f71..d9eef94ad 100644 --- a/emulation-system/tests/test_start_client_manager.py +++ b/emulation-system/tests/test_start_client_manager.py @@ -7,13 +7,12 @@ from docker.types import IPAMConfig, IPAMPool import time from csle_common.dao.emulation_config.emulation_env_config import EmulationEnvConfig -from csle_common.util.emulation_util import EmulationUtil import csle_common.constants.constants as constants import csle_collector.client_manager.client_manager_pb2_grpc import csle_collector.client_manager.client_manager_pb2 import csle_collector.client_manager.query_clients from csle_common.metastore.metastore_facade import MetastoreFacade -from IPython.lib.editorhooks import emacs +from typing import Generator @pytest.fixture(scope="module") @@ -27,7 +26,7 @@ def docker_client() -> None: @pytest.fixture(scope="module") -def network(docker_client) -> None: +def network(docker_client) -> Generator: """ Create a custom network with a specific subnet diff --git a/emulation-system/tests/test_start_elk_manager.py b/emulation-system/tests/test_start_elk_manager.py index 6bc497545..500dfb3ef 100644 --- a/emulation-system/tests/test_start_elk_manager.py +++ b/emulation-system/tests/test_start_elk_manager.py @@ -7,14 +7,12 @@ from docker.types import IPAMConfig, IPAMPool import time from csle_common.dao.emulation_config.emulation_env_config import EmulationEnvConfig -from csle_common.util.emulation_util import EmulationUtil import csle_common.constants.constants as constants -from csle_common.controllers.elk_controller import ELKController import csle_collector.elk_manager.elk_manager_pb2_grpc import csle_collector.elk_manager.elk_manager_pb2 import csle_collector.elk_manager.query_elk_manager from csle_common.metastore.metastore_facade import MetastoreFacade -from IPython.lib.editorhooks import emacs +from typing import Generator @pytest.fixture(scope="module") @@ -28,14 +26,14 @@ def docker_client() -> None: @pytest.fixture(scope="module") -def network(docker_client) -> None: +def network(docker_client) -> Generator: """ Create a custom network with a specific subnet :param docker_client: docker_client :yield: network - :return: None + :return: Generator """ subnet = "15.15.15.0/24" ipam_pool = IPAMPool(subnet=subnet) diff --git a/emulation-system/tests/test_start_host_manager.py b/emulation-system/tests/test_start_host_manager.py index c47321695..968041d1e 100644 --- a/emulation-system/tests/test_start_host_manager.py +++ b/emulation-system/tests/test_start_host_manager.py @@ -11,6 +11,8 @@ import csle_collector.host_manager.host_manager_pb2 import csle_collector.host_manager.query_host_manager from csle_common.metastore.metastore_facade import MetastoreFacade +from typing import List +from typing import Generator @pytest.fixture(scope="module") @@ -42,13 +44,13 @@ def network(docker_client) -> Generator: network.remove() -def get_derived_containers(docker_client, excluded_tag="blank") -> None: +def get_derived_containers(docker_client, excluded_tag="blank") -> List: """ Get all the containers except the blank ones :param docker_client: docker_client - :return: None + :return: List of Images """ # Get all images except those with the excluded tag config = MetastoreFacade.get_config(id=1) diff --git a/emulation-system/tests/test_start_kafka_manager.py b/emulation-system/tests/test_start_kafka_manager.py index fa355c4b1..8a6d49920 100644 --- a/emulation-system/tests/test_start_kafka_manager.py +++ b/emulation-system/tests/test_start_kafka_manager.py @@ -7,13 +7,12 @@ from docker.types import IPAMConfig, IPAMPool import time from csle_common.dao.emulation_config.emulation_env_config import EmulationEnvConfig -from csle_common.util.emulation_util import EmulationUtil import csle_common.constants.constants as constants import csle_collector.kafka_manager.kafka_manager_pb2_grpc import csle_collector.kafka_manager.kafka_manager_pb2 import csle_collector.kafka_manager.query_kafka_server from csle_common.metastore.metastore_facade import MetastoreFacade -from IPython.lib.editorhooks import emacs +from typing import Generator @pytest.fixture(scope="module") @@ -27,14 +26,14 @@ def docker_client() -> None: @pytest.fixture(scope="module") -def network(docker_client) -> None: +def network(docker_client) -> Generator: """ Create a custom network with a specific subnet :param docker_client: docker_client :yield: network - :return: None + :return: Generator """ subnet = "15.15.15.0/24" ipam_pool = IPAMPool(subnet=subnet) diff --git a/emulation-system/tests/test_start_ossec_manager.py b/emulation-system/tests/test_start_ossec_manager.py index c5a75e75c..599b8167a 100644 --- a/emulation-system/tests/test_start_ossec_manager.py +++ b/emulation-system/tests/test_start_ossec_manager.py @@ -7,13 +7,12 @@ from docker.types import IPAMConfig, IPAMPool import time from csle_common.dao.emulation_config.emulation_env_config import EmulationEnvConfig -from csle_common.util.emulation_util import EmulationUtil import csle_common.constants.constants as constants import csle_collector.ossec_ids_manager.ossec_ids_manager_pb2_grpc import csle_collector.ossec_ids_manager.ossec_ids_manager_pb2 import csle_collector.ossec_ids_manager.query_ossec_ids_manager from csle_common.metastore.metastore_facade import MetastoreFacade -from IPython.lib.editorhooks import emacs +from typing import Generator @pytest.fixture(scope="module") @@ -27,14 +26,14 @@ def docker_client() -> None: @pytest.fixture(scope="module") -def network(docker_client) -> None: +def network(docker_client) -> Generator: """ Create a custom network with a specific subnet :param docker_client: docker_client :yield: network - :return: None + :return: Generator """ subnet = "15.15.15.0/24" ipam_pool = IPAMPool(subnet=subnet) diff --git a/emulation-system/tests/test_start_ryu_manager.py b/emulation-system/tests/test_start_ryu_manager.py index ccb3ebbe6..7b4f71907 100644 --- a/emulation-system/tests/test_start_ryu_manager.py +++ b/emulation-system/tests/test_start_ryu_manager.py @@ -7,13 +7,12 @@ from docker.types import IPAMConfig, IPAMPool import time from csle_common.dao.emulation_config.emulation_env_config import EmulationEnvConfig -from csle_common.util.emulation_util import EmulationUtil import csle_common.constants.constants as constants import csle_collector.ryu_manager.ryu_manager_pb2_grpc import csle_collector.ryu_manager.ryu_manager_pb2 import csle_collector.ryu_manager.query_ryu_manager from csle_common.metastore.metastore_facade import MetastoreFacade -from IPython.lib.editorhooks import emacs +from typing import Generator @pytest.fixture(scope="module") @@ -27,14 +26,14 @@ def docker_client() -> None: @pytest.fixture(scope="module") -def network(docker_client) -> None: +def network(docker_client) -> Generator: """ Create a custom network with a specific subnet :param docker_client: docker_client :yield: network - :return: None + :return: Generator """ subnet = "15.15.15.0/24" ipam_pool = IPAMPool(subnet=subnet) diff --git a/emulation-system/tests/test_start_snort_manager.py b/emulation-system/tests/test_start_snort_manager.py index 613e02b4e..9a0bc0bb4 100644 --- a/emulation-system/tests/test_start_snort_manager.py +++ b/emulation-system/tests/test_start_snort_manager.py @@ -7,13 +7,11 @@ from docker.types import IPAMConfig, IPAMPool import time from csle_common.dao.emulation_config.emulation_env_config import EmulationEnvConfig -from csle_common.util.emulation_util import EmulationUtil import csle_common.constants.constants as constants -from csle_common.controllers.snort_ids_controller import SnortIDSController import csle_collector.snort_ids_manager.snort_ids_manager_pb2_grpc import csle_collector.snort_ids_manager.snort_ids_manager_pb2 from csle_common.metastore.metastore_facade import MetastoreFacade -from IPython.lib.editorhooks import emacs +from typing import Generator @pytest.fixture(scope="module") @@ -27,14 +25,14 @@ def docker_client() -> None: @pytest.fixture(scope="module") -def network(docker_client) -> None: +def network(docker_client) -> Generator: """ Create a custom network with a specific subnet :param docker_client: docker_client :yield: network - :return: None + :return: Generator """ subnet = "15.15.15.0/24" ipam_pool = IPAMPool(subnet=subnet) @@ -64,7 +62,7 @@ def get_derived_containers(docker_client, excluded_tag=constants.CONTAINER_IMAGE and all(constants.CONTAINER_IMAGES.BASE not in tag for tag in image.tags) and all(excluded_tag not in tag for tag in image.tags) ] - return derived_images + return derived_images @pytest.fixture(scope="module", params=get_derived_containers(docker.from_env())) @@ -81,7 +79,7 @@ def container_setup(request, docker_client, network) -> Generator: # Create and start each derived container image = request.param container = docker_client.containers.create( - image.tags[0], + image.tags[0], command="sh -c 'while true; do sleep 3600; done'", detach=True, ) @@ -144,7 +142,7 @@ def test_start_snort_manager(container_setup) -> None: with grpc.insecure_channel(f"{ip}:{port}", options=constants.GRPC_SERVERS.GRPC_OPTIONS) as channel: stub = csle_collector.snort_ids_manager.snort_ids_manager_pb2_grpc.SnortIdsManagerStub(channel) status = csle_collector.snort_ids_manager.query_snort_ids_manager.get_snort_ids_monitor_status(stub=stub) - assert status + assert status except Exception as e: print(f"Error occurred in container {container_setup.name}: {e}") failed_containers.append(container_setup.name) diff --git a/emulation-system/tests/test_start_traffic_manager.py b/emulation-system/tests/test_start_traffic_manager.py index ba6046c96..b52e2daec 100644 --- a/emulation-system/tests/test_start_traffic_manager.py +++ b/emulation-system/tests/test_start_traffic_manager.py @@ -7,14 +7,12 @@ from docker.types import IPAMConfig, IPAMPool import time from csle_common.dao.emulation_config.emulation_env_config import EmulationEnvConfig -from csle_common.util.emulation_util import EmulationUtil import csle_common.constants.constants as constants import csle_collector.traffic_manager.traffic_manager_pb2_grpc import csle_collector.traffic_manager.traffic_manager_pb2 import csle_collector.traffic_manager.query_traffic_manager from csle_common.metastore.metastore_facade import MetastoreFacade -from IPython.lib.editorhooks import emacs - +from typing import Generator @pytest.fixture(scope="module") def docker_client() -> None: @@ -27,14 +25,14 @@ def docker_client() -> None: @pytest.fixture(scope="module") -def network(docker_client) -> None: +def network(docker_client) -> Generator: """ Create a custom network with a specific subnet :param docker_client: docker_client :yield: network - :return: None + :return: Generator """ subnet = "15.15.15.0/24" ipam_pool = IPAMPool(subnet=subnet) @@ -64,7 +62,7 @@ def get_derived_containers(docker_client, excluded_tag=constants.CONTAINER_IMAGE and all(constants.CONTAINER_IMAGES.BASE not in tag for tag in image.tags) and all(excluded_tag not in tag for tag in image.tags) ] - return derived_images + return derived_images[:1] @pytest.fixture(scope="module", params=get_derived_containers(docker.from_env()))