7
7
from docker .types import IPAMConfig , IPAMPool
8
8
import time
9
9
from csle_common .dao .emulation_config .emulation_env_config import EmulationEnvConfig
10
- from csle_common .util .emulation_util import EmulationUtil
11
10
import csle_common .constants .constants as constants
12
- from csle_common .controllers .snort_ids_controller import SnortIDSController
13
11
import csle_collector .snort_ids_manager .snort_ids_manager_pb2_grpc
14
12
import csle_collector .snort_ids_manager .snort_ids_manager_pb2
15
13
from csle_common .metastore .metastore_facade import MetastoreFacade
16
- from IPython . lib . editorhooks import emacs
14
+ from typing import Generator
17
15
18
16
19
17
@pytest .fixture (scope = "module" )
@@ -27,14 +25,14 @@ def docker_client() -> None:
27
25
28
26
29
27
@pytest .fixture (scope = "module" )
30
- def network (docker_client ) -> None :
28
+ def network (docker_client ) -> Generator :
31
29
"""
32
30
Create a custom network with a specific subnet
33
31
34
32
:param docker_client: docker_client
35
33
:yield: network
36
34
37
- :return: None
35
+ :return: Generator
38
36
"""
39
37
subnet = "15.15.15.0/24"
40
38
ipam_pool = IPAMPool (subnet = subnet )
@@ -64,7 +62,7 @@ def get_derived_containers(docker_client, excluded_tag=constants.CONTAINER_IMAGE
64
62
and all (constants .CONTAINER_IMAGES .BASE not in tag for tag in image .tags )
65
63
and all (excluded_tag not in tag for tag in image .tags )
66
64
]
67
- return derived_images
65
+ return derived_images
68
66
69
67
70
68
@pytest .fixture (scope = "module" , params = get_derived_containers (docker .from_env ()))
@@ -81,7 +79,7 @@ def container_setup(request, docker_client, network) -> Generator:
81
79
# Create and start each derived container
82
80
image = request .param
83
81
container = docker_client .containers .create (
84
- image .tags [0 ],
82
+ image .tags [0 ],
85
83
command = "sh -c 'while true; do sleep 3600; done'" ,
86
84
detach = True ,
87
85
)
@@ -144,7 +142,7 @@ def test_start_snort_manager(container_setup) -> None:
144
142
with grpc .insecure_channel (f"{ ip } :{ port } " , options = constants .GRPC_SERVERS .GRPC_OPTIONS ) as channel :
145
143
stub = csle_collector .snort_ids_manager .snort_ids_manager_pb2_grpc .SnortIdsManagerStub (channel )
146
144
status = csle_collector .snort_ids_manager .query_snort_ids_manager .get_snort_ids_monitor_status (stub = stub )
147
- assert status
145
+ assert status
148
146
except Exception as e :
149
147
print (f"Error occurred in container { container_setup .name } : { e } " )
150
148
failed_containers .append (container_setup .name )
0 commit comments