@@ -8,7 +8,7 @@ pub mod vm;
88pub use openshell_driver_docker:: DockerComputeConfig ;
99pub use vm:: VmComputeConfig ;
1010
11- use crate :: grpc:: policy:: { SANDBOX_SETTINGS_OBJECT_TYPE , sandbox_settings_id } ;
11+ use crate :: grpc:: policy:: SANDBOX_SETTINGS_OBJECT_TYPE ;
1212use crate :: persistence:: { ObjectId , ObjectName , ObjectRecord , ObjectType , Store } ;
1313use crate :: sandbox_index:: SandboxIndex ;
1414use crate :: sandbox_watch:: SandboxWatchBus ;
@@ -501,7 +501,7 @@ impl ComputeRuntime {
501501
502502 if let Err ( e) = self
503503 . store
504- . delete ( SANDBOX_SETTINGS_OBJECT_TYPE , & sandbox_settings_id ( & id ) )
504+ . delete_by_name ( SANDBOX_SETTINGS_OBJECT_TYPE , sandbox . object_name ( ) )
505505 . await
506506 {
507507 warn ! (
@@ -1479,6 +1479,115 @@ fn is_terminal_failure_reason(reason: &str) -> bool {
14791479 !transient_reasons. contains ( & reason. as_str ( ) )
14801480}
14811481
1482+ #[ cfg( test) ]
1483+ #[ derive( Debug , Default ) ]
1484+ pub ( crate ) struct NoopTestDriver ;
1485+
1486+ #[ cfg( test) ]
1487+ #[ tonic:: async_trait]
1488+ impl ComputeDriver for NoopTestDriver {
1489+ type WatchSandboxesStream = DriverWatchStream ;
1490+
1491+ async fn get_capabilities (
1492+ & self ,
1493+ _request : Request < GetCapabilitiesRequest > ,
1494+ ) -> Result < tonic:: Response < openshell_core:: proto:: compute:: v1:: GetCapabilitiesResponse > , Status >
1495+ {
1496+ Ok ( tonic:: Response :: new (
1497+ openshell_core:: proto:: compute:: v1:: GetCapabilitiesResponse {
1498+ driver_name : "noop-test-driver" . to_string ( ) ,
1499+ driver_version : "test" . to_string ( ) ,
1500+ default_image : "openshell/sandbox:test" . to_string ( ) ,
1501+ supports_gpu : false ,
1502+ } ,
1503+ ) )
1504+ }
1505+
1506+ async fn validate_sandbox_create (
1507+ & self ,
1508+ _request : Request < ValidateSandboxCreateRequest > ,
1509+ ) -> Result <
1510+ tonic:: Response < openshell_core:: proto:: compute:: v1:: ValidateSandboxCreateResponse > ,
1511+ Status ,
1512+ > {
1513+ Ok ( tonic:: Response :: new (
1514+ openshell_core:: proto:: compute:: v1:: ValidateSandboxCreateResponse { } ,
1515+ ) )
1516+ }
1517+
1518+ async fn get_sandbox (
1519+ & self ,
1520+ _request : Request < GetSandboxRequest > ,
1521+ ) -> Result < tonic:: Response < openshell_core:: proto:: compute:: v1:: GetSandboxResponse > , Status >
1522+ {
1523+ Err ( Status :: not_found ( "sandbox not found" ) )
1524+ }
1525+
1526+ async fn list_sandboxes (
1527+ & self ,
1528+ _request : Request < ListSandboxesRequest > ,
1529+ ) -> Result < tonic:: Response < openshell_core:: proto:: compute:: v1:: ListSandboxesResponse > , Status >
1530+ {
1531+ Ok ( tonic:: Response :: new (
1532+ openshell_core:: proto:: compute:: v1:: ListSandboxesResponse {
1533+ sandboxes : Vec :: new ( ) ,
1534+ } ,
1535+ ) )
1536+ }
1537+
1538+ async fn create_sandbox (
1539+ & self ,
1540+ _request : Request < CreateSandboxRequest > ,
1541+ ) -> Result < tonic:: Response < openshell_core:: proto:: compute:: v1:: CreateSandboxResponse > , Status >
1542+ {
1543+ Ok ( tonic:: Response :: new (
1544+ openshell_core:: proto:: compute:: v1:: CreateSandboxResponse { } ,
1545+ ) )
1546+ }
1547+
1548+ async fn stop_sandbox (
1549+ & self ,
1550+ _request : Request < openshell_core:: proto:: compute:: v1:: StopSandboxRequest > ,
1551+ ) -> Result < tonic:: Response < openshell_core:: proto:: compute:: v1:: StopSandboxResponse > , Status >
1552+ {
1553+ Ok ( tonic:: Response :: new (
1554+ openshell_core:: proto:: compute:: v1:: StopSandboxResponse { } ,
1555+ ) )
1556+ }
1557+
1558+ async fn delete_sandbox (
1559+ & self ,
1560+ _request : Request < DeleteSandboxRequest > ,
1561+ ) -> Result < tonic:: Response < openshell_core:: proto:: compute:: v1:: DeleteSandboxResponse > , Status >
1562+ {
1563+ Ok ( tonic:: Response :: new (
1564+ openshell_core:: proto:: compute:: v1:: DeleteSandboxResponse { deleted : true } ,
1565+ ) )
1566+ }
1567+
1568+ async fn watch_sandboxes (
1569+ & self ,
1570+ _request : Request < WatchSandboxesRequest > ,
1571+ ) -> Result < tonic:: Response < Self :: WatchSandboxesStream > , Status > {
1572+ Ok ( tonic:: Response :: new ( Box :: pin ( futures:: stream:: empty ( ) ) ) )
1573+ }
1574+ }
1575+
1576+ #[ cfg( test) ]
1577+ pub ( crate ) async fn new_test_runtime ( store : Arc < Store > ) -> ComputeRuntime {
1578+ ComputeRuntime {
1579+ driver : Arc :: new ( NoopTestDriver ) ,
1580+ _driver_process : None ,
1581+ default_image : "openshell/sandbox:test" . to_string ( ) ,
1582+ store,
1583+ sandbox_index : SandboxIndex :: new ( ) ,
1584+ sandbox_watch_bus : SandboxWatchBus :: new ( ) ,
1585+ tracing_log_bus : TracingLogBus :: new ( ) ,
1586+ supervisor_sessions : Arc :: new ( SupervisorSessionRegistry :: new ( ) ) ,
1587+ sync_lock : Arc :: new ( Mutex :: new ( ( ) ) ) ,
1588+ }
1589+ }
1590+
14821591#[ cfg( test) ]
14831592mod tests {
14841593 use super :: * ;
0 commit comments