22
33These tests configure Llama Stack's run.yaml with NetworkConfig settings
44(proxy, TLS) and verify the full pipeline works through the Lightspeed Stack.
5- The proxy sits between Llama Stack and the LLM provider (e.g., OpenAI) .
5+ The proxy sits between Llama Stack and whichever remote LLM provider is active .
66
77Config switching uses the same pattern as other e2e tests: overwrite the
88host-mounted run.yaml and restart Docker containers. Restarts are not
@@ -138,17 +138,41 @@ def _write_config(config: dict[str, Any], path: str) -> None:
138138 yaml .dump (config , f , default_flow_style = False )
139139
140140
141- def _find_openai_provider (config : dict [str , Any ]) -> dict [str , Any ]:
142- """Find the OpenAI inference provider in the config.
141+ def _find_inference_provider (
142+ context : Context , config : dict [str , Any ]
143+ ) -> dict [str , Any ]:
144+ """Find the target remote inference provider in the config.
145+
146+ Priority:
147+ 1. ``context.default_provider`` (detected in ``before_all``), if present.
148+ 2. First remote inference provider in ``run.yaml``.
143149
144150 Raises:
145- AssertionError: If no remote::openai provider is found.
151+ AssertionError: If no suitable remote inference provider is found.
146152 """
147153 providers = config .get ("providers" , {})
148- for provider in providers .get ("inference" , []):
149- if provider .get ("provider_type" ) == "remote::openai" :
154+ inference_providers = providers .get ("inference" , [])
155+ target_provider_id = getattr (context , "default_provider" , None )
156+
157+ if target_provider_id :
158+ for provider in inference_providers :
159+ if provider .get ("provider_id" ) == target_provider_id :
160+ provider_type = str (provider .get ("provider_type" , "" ))
161+ assert provider_type .startswith ("remote::" ), (
162+ "Configured default provider "
163+ f"'{ target_provider_id } ' is not a remote provider in run.yaml"
164+ )
165+ return provider
166+
167+ for provider in inference_providers :
168+ provider_type = str (provider .get ("provider_type" , "" ))
169+ if provider_type .startswith ("remote::" ):
150170 return provider
151- raise AssertionError ("No remote::openai provider found in run.yaml" )
171+
172+ raise AssertionError (
173+ "No remote inference provider found in run.yaml "
174+ "(expected provider_type starting with 'remote::')"
175+ )
152176
153177
154178def _backup_llama_config () -> None :
@@ -244,7 +268,7 @@ def configure_llama_tunnel_proxy(context: Context) -> None:
244268 proxy = context .tunnel_proxy
245269 proxy_host = _get_proxy_host (context .is_docker_mode )
246270 config = _load_llama_config ()
247- provider = _find_openai_provider ( config )
271+ provider = _find_inference_provider ( context , config )
248272
249273 if "config" not in provider :
250274 provider ["config" ] = {}
@@ -262,7 +286,7 @@ def configure_llama_unreachable_proxy(context: Context, proxy_url: str) -> None:
262286 """Modify run.yaml with a proxy URL (may be unreachable)."""
263287 _backup_llama_config ()
264288 config = _load_llama_config ()
265- provider = _find_openai_provider ( config )
289+ provider = _find_inference_provider ( context , config )
266290
267291 if "config" not in provider :
268292 provider ["config" ] = {}
@@ -326,7 +350,7 @@ def configure_llama_interception_with_ca(context: Context) -> None:
326350 proxy = context .interception_proxy
327351 proxy_host = _get_proxy_host (context .is_docker_mode )
328352 config = _load_llama_config ()
329- provider = _find_openai_provider ( config )
353+ provider = _find_inference_provider ( context , config )
330354
331355 if "config" not in provider :
332356 provider ["config" ] = {}
@@ -353,7 +377,7 @@ def configure_llama_interception_no_ca(context: Context) -> None:
353377 proxy = context .interception_proxy
354378 proxy_host = _get_proxy_host (context .is_docker_mode )
355379 config = _load_llama_config ()
356- provider = _find_openai_provider ( config )
380+ provider = _find_inference_provider ( context , config )
357381
358382 if "config" not in provider :
359383 provider ["config" ] = {}
@@ -374,7 +398,7 @@ def configure_llama_tls_version(context: Context, version: str) -> None:
374398 """Modify run.yaml with TLS version config."""
375399 _backup_llama_config ()
376400 config = _load_llama_config ()
377- provider = _find_openai_provider ( config )
401+ provider = _find_inference_provider ( context , config )
378402
379403 if "config" not in provider :
380404 provider ["config" ] = {}
@@ -392,7 +416,7 @@ def configure_llama_ciphers(context: Context, ciphers: str) -> None:
392416 """Modify run.yaml with cipher suite config."""
393417 _backup_llama_config ()
394418 config = _load_llama_config ()
395- provider = _find_openai_provider ( config )
419+ provider = _find_inference_provider ( context , config )
396420
397421 if "config" not in provider :
398422 provider ["config" ] = {}
0 commit comments