Skip to content

Commit d159988

Browse files
committed
Add new smoketests for tunnel v2
1 parent 08c5bd7 commit d159988

3 files changed

Lines changed: 92 additions & 1 deletion

File tree

tests/smoketests/sdk/test_async_devbox.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,53 @@ async def test_create_and_remove_tunnel(self, async_sdk_client: AsyncRunloopSDK)
458458
finally:
459459
await devbox.shutdown()
460460

461+
@pytest.mark.timeout(TWO_MINUTE_TIMEOUT)
462+
async def test_create_with_tunnel_param(self, async_sdk_client: AsyncRunloopSDK) -> None:
463+
"""Test creating a devbox with tunnel configuration in create params."""
464+
devbox = await async_sdk_client.devbox.create(
465+
name=unique_name("sdk-async-devbox-tunnel-param"),
466+
launch_parameters={"resource_size_request": "SMALL", "keep_alive_time_seconds": 60 * 5},
467+
tunnel={"auth_mode": "open"},
468+
)
469+
470+
try:
471+
# Verify devbox is running
472+
info = await devbox.get_info()
473+
assert info.status == "running"
474+
475+
# Verify tunnel was created at launch
476+
assert info.tunnel is not None
477+
assert info.tunnel.tunnel_key is not None
478+
assert info.tunnel.auth_mode is not None
479+
finally:
480+
await devbox.shutdown()
481+
482+
@pytest.mark.timeout(TWO_MINUTE_TIMEOUT)
483+
async def test_enable_tunnel(self, async_sdk_client: AsyncRunloopSDK) -> None:
484+
"""Test enabling a V2 tunnel on an existing devbox."""
485+
devbox = await async_sdk_client.devbox.create(
486+
name=unique_name("sdk-async-devbox-enable-tunnel"),
487+
launch_parameters={"resource_size_request": "SMALL", "keep_alive_time_seconds": 60 * 5},
488+
)
489+
490+
try:
491+
# Verify no tunnel exists initially
492+
info = await devbox.get_info()
493+
assert info.tunnel is None
494+
495+
# Enable tunnel using the V2 API
496+
tunnel = await async_sdk_client.api.devboxes.enable_tunnel(devbox.id, auth_mode="open")
497+
assert tunnel is not None
498+
assert tunnel.tunnel_key is not None
499+
assert tunnel.auth_mode is not None
500+
501+
# Verify tunnel is now present in devbox info
502+
info = await devbox.get_info()
503+
assert info.tunnel is not None
504+
assert info.tunnel.tunnel_key == tunnel.tunnel_key
505+
finally:
506+
await devbox.shutdown()
507+
461508

462509
class TestAsyncDevboxCreationMethods:
463510
"""Test various async devbox creation methods."""

tests/smoketests/sdk/test_devbox.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,50 @@ def test_create_and_remove_tunnel(self, sdk_client: RunloopSDK) -> None:
455455
finally:
456456
devbox.shutdown()
457457

458+
@pytest.mark.timeout(TWO_MINUTE_TIMEOUT)
459+
def test_create_with_tunnel_param(self, sdk_client: RunloopSDK) -> None:
460+
"""Test creating a devbox with tunnel configuration in create params."""
461+
devbox = sdk_client.devbox.create(
462+
name=unique_name("sdk-devbox-tunnel-param"),
463+
launch_parameters={"resource_size_request": "SMALL", "keep_alive_time_seconds": 60 * 5},
464+
tunnel={"auth_mode": "open"},
465+
)
466+
467+
try:
468+
# Verify devbox is running
469+
info = devbox.get_info()
470+
assert info.status == "running"
471+
472+
# Verify tunnel was created at launch
473+
assert info.tunnel is not None
474+
assert info.tunnel.tunnel_key is not None
475+
assert info.tunnel.auth_mode is not None
476+
finally:
477+
devbox.shutdown()
478+
479+
@pytest.mark.timeout(TWO_MINUTE_TIMEOUT)
480+
def test_enable_tunnel(self, sdk_client: RunloopSDK) -> None:
481+
"""Test enabling a V2 tunnel on an existing devbox."""
482+
devbox = sdk_client.devbox.create(
483+
name=unique_name("sdk-devbox-enable-tunnel"),
484+
launch_parameters={"resource_size_request": "SMALL", "keep_alive_time_seconds": 60 * 5},
485+
)
486+
487+
try:
488+
info = devbox.get_info()
489+
assert info.tunnel is None
490+
491+
tunnel = sdk_client.api.devboxes.enable_tunnel(devbox.id, auth_mode="open")
492+
assert tunnel is not None
493+
assert tunnel.tunnel_key is not None
494+
assert tunnel.auth_mode is not None
495+
496+
info = devbox.get_info()
497+
assert info.tunnel is not None
498+
assert info.tunnel.tunnel_key == tunnel.tunnel_key
499+
finally:
500+
devbox.shutdown()
501+
458502

459503
class TestDevboxCreationMethods:
460504
"""Test various devbox creation methods."""

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)