|
16 | 16 | from test.e2e.clients.python.framework.context import TestContext |
17 | 17 |
|
18 | 18 | import pytest |
| 19 | +import yaml |
19 | 20 | from agentic_sandbox import SandboxClient |
20 | 21 |
|
21 | 22 | TEST_MANIFESTS_DIR = "test/e2e/clients/python/test_manifests" |
|
25 | 26 | ROUTER_YAML_PATH = ( |
26 | 27 | "clients/python/agentic-sandbox-client/sandbox-router/sandbox_router.yaml" |
27 | 28 | ) |
| 29 | +GATEWAY_YAML_PATH = ( |
| 30 | + "clients/python/agentic-sandbox-client/gateway-kind/gateway-kind.yaml" |
| 31 | +) |
| 32 | +GATEWAY_NAME = "kind-gateway" |
28 | 33 |
|
29 | 34 |
|
30 | 35 | @pytest.fixture(scope="module") |
@@ -70,6 +75,18 @@ def deploy_router(tc, temp_namespace): |
70 | 75 | tc.wait_for_deployment_ready("sandbox-router-deployment", namespace=temp_namespace) |
71 | 76 |
|
72 | 77 |
|
| 78 | +@pytest.fixture(scope="function") |
| 79 | +def deploy_gateway(tc, temp_namespace): |
| 80 | + """Deploys the sandbox gateway into the test namespace""" |
| 81 | + with open(GATEWAY_YAML_PATH, "r") as f: |
| 82 | + manifest = f.read() |
| 83 | + |
| 84 | + print(f"Applying gateway manifest to namespace: {temp_namespace}") |
| 85 | + tc.apply_manifest_text(manifest, namespace=temp_namespace) |
| 86 | + print("Waiting for gateway to get an address...") |
| 87 | + tc.wait_for_gateway_address(GATEWAY_NAME, namespace=temp_namespace) |
| 88 | + |
| 89 | + |
73 | 90 | @pytest.fixture(scope="function") |
74 | 91 | def sandbox_template(tc, temp_namespace): |
75 | 92 | """Deploys the sandbox template into the test namespace""" |
@@ -144,3 +161,46 @@ def test_python_sdk_router_mode_warmpool( |
144 | 161 |
|
145 | 162 | except Exception as e: |
146 | 163 | pytest.fail(f"SDK test with warmpool failed: {e}") |
| 164 | + |
| 165 | + |
| 166 | +def test_python_sdk_gateway_mode( |
| 167 | + tc, temp_namespace, sandbox_template, deploy_router, deploy_gateway |
| 168 | +): |
| 169 | + """Tests the Python SDK in Production mode (with Gateway and Router) without warmpool.""" |
| 170 | + try: |
| 171 | + with SandboxClient( |
| 172 | + template_name=sandbox_template, |
| 173 | + namespace=temp_namespace, |
| 174 | + gateway_name=GATEWAY_NAME, |
| 175 | + gateway_namespace=temp_namespace, |
| 176 | + ) as sandbox: |
| 177 | + print("\n--- Running SDK tests without warmpool ---") |
| 178 | + run_sdk_tests(sandbox) |
| 179 | + print("SDK test without warmpool passed!") |
| 180 | + |
| 181 | + except Exception as e: |
| 182 | + pytest.fail(f"SDK test without warmpool failed: {e}") |
| 183 | + |
| 184 | + |
| 185 | +def test_python_sdk_gateway_mode_warmpool( |
| 186 | + tc, |
| 187 | + temp_namespace, |
| 188 | + sandbox_template, |
| 189 | + deploy_router, |
| 190 | + sandbox_warmpool, |
| 191 | + deploy_gateway, |
| 192 | +): |
| 193 | + """Tests the Python SDK in Production mode (with gateway and router) with warmpool.""" |
| 194 | + try: |
| 195 | + with SandboxClient( |
| 196 | + template_name=sandbox_template, |
| 197 | + namespace=temp_namespace, |
| 198 | + gateway_name=GATEWAY_NAME, |
| 199 | + gateway_namespace=temp_namespace, |
| 200 | + ) as sandbox: |
| 201 | + print("\n--- Running SDK tests with warmpool ---") |
| 202 | + run_sdk_tests(sandbox) |
| 203 | + print("SDK test with warmpool passed!") |
| 204 | + |
| 205 | + except Exception as e: |
| 206 | + pytest.fail(f"SDK test with warmpool failed: {e}") |
0 commit comments