Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions rock/sdk/sandbox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,11 @@ async def start(self):
status = await self.get_status()
logging.debug(f"Get status response: {status}")
if status.is_alive:
break
return
except Exception as e:
logging.warning(f"Failed to get status, {str(e)}")
await asyncio.sleep(1)
await asyncio.sleep(3)
raise Exception(f"Failed to start sandbox within {self.config.startup_timeout}s")

async def is_alive(self) -> IsAliveResponse:
try:
Expand Down
18 changes: 18 additions & 0 deletions tests/integration/sdk/sandbox/test_sdk_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

from rock.sdk.sandbox.client import Sandbox
from rock.sdk.sandbox.config import SandboxConfig
from tests.integration.conftest import SKIP_IF_NO_DOCKER


Expand Down Expand Up @@ -34,3 +35,20 @@ async def test_arun_timeout(sandbox_instance: Sandbox):
assert resp.output.__contains__("Command execution failed due to timeout")

await sandbox_instance.stop()

@pytest.mark.need_admin
@SKIP_IF_NO_DOCKER
@pytest.mark.asyncio
async def test_sandbox_get_status(admin_remote_server):
config = SandboxConfig(
image="fake_image:latest",
memory="8g",
cpus=2.0,
base_url=f"{admin_remote_server.endpoint}:{admin_remote_server.port}",
startup_timeout=10,
)
sandbox = Sandbox(config)
with pytest.raises(Exception) as exc_info:
await sandbox.start()
assert "Failed to start sandbox" in str(exc_info.value)
sandbox.stop()
Loading