@@ -97,20 +97,6 @@ def opal_network():
9797 else :
9898 logger .error (f"Failed to remove network got exception\n { e } " )
9999
100- @pytest .fixture (scope = "session" )
101- def number_of_opal_servers ():
102- """The number of OPAL servers to start.
103-
104- This fixture is used to determine how many OPAL servers to start for
105- the tests. The default value is 2, but it can be overridden by setting
106- the environment variable OPAL_TESTS_NUMBER_OF_OPAL_SERVERS.
107-
108- Returns:
109- int: The number of OPAL servers to start.
110- """
111- return 2
112-
113-
114100from tests .fixtures .broadcasters import (
115101 broadcast_channel ,
116102 kafka_broadcast_channel ,
@@ -125,9 +111,7 @@ def number_of_opal_servers():
125111def opal_servers (
126112 opal_network : Network ,
127113 policy_repo ,
128- number_of_opal_servers : int ,
129114 opal_server_image : str ,
130- topics : dict [str , int ],
131115 broadcast_channel : BroadcastContainerBase ,
132116 # kafka_broadcast_channel: KafkaContainer,
133117 # redis_broadcast_channel: RedisBroadcastContainer,
@@ -167,7 +151,7 @@ def opal_servers(
167151 containers = [] # List to store container instances
168152
169153
170- for i in range (number_of_opal_servers ):
154+ for i in range (session_matrix [ " number_of_opal_servers" ] ):
171155 container_name = f"opal_server_{ i + 1 } "
172156
173157 repo_url = policy_repo .get_repo_url ()
@@ -180,7 +164,7 @@ def opal_servers(
180164 policy_repo_url = repo_url ,
181165 image = opal_server_image ,
182166 log_level = "DEBUG" ,
183- data_topics = " " .join (topics .keys ()),
167+ data_topics = " " .join (session_matrix [ " topics" ] .keys ()),
184168 polling_interval = 3 ,
185169 policy_repo_main_branch = policy_repo .test_branch ,
186170 ),
@@ -209,18 +193,6 @@ def opal_servers(
209193 for container in containers :
210194 container .stop ()
211195
212-
213- @pytest .fixture (scope = "session" )
214- def number_of_opal_clients ():
215- """The number of OPAL clients to start.
216-
217- This fixture is used to determine how many OPAL clients to start for
218- the tests. The default value is 2, but it can be overridden by
219- setting the environment variable OPAL_TESTS_NUMBER_OF_OPAL_CLIENTS.
220- """
221- return 2
222-
223-
224196@pytest .fixture (scope = "session" )
225197def connected_clients (opal_clients : List [OpalClientContainer ]):
226198 """A fixture that waits for all OPAL clients to connect to the PubSub
@@ -264,7 +236,7 @@ def opal_clients(
264236 # opa_server: OpaContainer,
265237 # cedar_server: CedarContainer,
266238 request ,
267- number_of_opal_clients : int ,
239+ session_matrix ,
268240 opal_client_with_opa_image ,
269241):
270242 """A fixture that starts and manages multiple OPAL client containers.
@@ -303,7 +275,7 @@ def opal_clients(
303275
304276 containers = [] # List to store OpalClientContainer instances
305277
306- for i in range (number_of_opal_clients ):
278+ for i in range (session_matrix [ " number_of_opal_clients" ] ):
307279 container_name = f"opal_client_{ i + 1 } " # Unique name for each client
308280
309281 client_token = opal_servers [0 ].obtain_OPAL_tokens (container_name )["client" ]
@@ -355,26 +327,8 @@ def opal_clients(
355327 logger .error (f"Failed to stop containers: { container } " )
356328 pass
357329
358-
359330@pytest .fixture (scope = "session" )
360- def topics ():
361- """A fixture that returns a dictionary mapping topic names to the number of
362- OpalClientContainer instances that should subscribe to each topic.
363-
364- Returns
365- -------
366- dict
367- A dictionary mapping topic names to the number of OpalClientContainer
368- instances that should subscribe to each topic.
369- """
370- topics = {"topic_1" : 1 , "topic_2" : 1 }
371- return topics
372-
373-
374- @pytest .fixture (scope = "session" )
375- def topiced_clients (
376- topics , opal_network : Network , opal_servers : list [OpalServerContainer ]
377- ):
331+ def topiced_clients (opal_network : Network , opal_servers : list [OpalServerContainer ], session_matrix ):
378332 """Fixture that starts and manages multiple OPAL client containers, each
379333 subscribing to a different topic.
380334
@@ -427,7 +381,7 @@ def topiced_clients(
427381 }
428382 )
429383
430- for topic , number_of_clients in topics .items ():
384+ for topic , number_of_clients in session_matrix [ " topics" ] .items ():
431385 for i in range (number_of_clients ):
432386 container_name = f"opal_client_{ topic } _{ i + 1 } " # Unique name for each client
433387
0 commit comments