@@ -3421,6 +3421,103 @@ mod tests {
34213421 ) ;
34223422 }
34233423
3424+ #[ tokio:: test]
3425+ #[ cfg( unix) ]
3426+ async fn remote_compute_driver_forwards_lifecycle_calls_over_uds ( ) {
3427+ use crate :: test_support:: { FakeComputeDriver , FakeComputeDriverCall } ;
3428+
3429+ let dir = tempfile:: tempdir ( ) . unwrap ( ) ;
3430+ let socket_path = dir. path ( ) . join ( "compute-driver.sock" ) ;
3431+ let driver = FakeComputeDriver :: new ( )
3432+ . with_driver_name ( "fake-remote-driver" )
3433+ . with_default_image ( "openshell/sandbox:remote" ) ;
3434+ let _server = driver. serve_uds ( & socket_path) . unwrap ( ) ;
3435+
3436+ let endpoint = connect_remote_compute_driver ( "external-test" , & socket_path)
3437+ . await
3438+ . unwrap ( ) ;
3439+ let store = Arc :: new ( Store :: connect ( "sqlite::memory:" ) . await . unwrap ( ) ) ;
3440+ let runtime = ComputeRuntime :: new_remote_driver (
3441+ endpoint,
3442+ store,
3443+ SandboxIndex :: new ( ) ,
3444+ SandboxWatchBus :: new ( ) ,
3445+ TracingLogBus :: new ( ) ,
3446+ Arc :: new ( SupervisorSessionRegistry :: new ( ) ) ,
3447+ )
3448+ . await
3449+ . unwrap ( ) ;
3450+
3451+ let mut sandbox = sandbox_record ( "sb-uds" , "uds-sandbox" , SandboxPhase :: Provisioning ) ;
3452+ sandbox. spec = Some ( SandboxSpec {
3453+ log_level : "debug" . to_string ( ) ,
3454+ template : Some ( SandboxTemplate {
3455+ image : "ghcr.io/nvidia/openshell/sandbox:test" . to_string ( ) ,
3456+ driver_config : Some ( prost_types:: Struct {
3457+ fields : [
3458+ (
3459+ "external-test" . to_string ( ) ,
3460+ struct_value ( [ ( "pool" , string_value ( "ci" ) ) ] ) ,
3461+ ) ,
3462+ (
3463+ "docker" . to_string ( ) ,
3464+ struct_value ( [ ( "network_mode" , string_value ( "bridge" ) ) ] ) ,
3465+ ) ,
3466+ ]
3467+ . into_iter ( )
3468+ . collect ( ) ,
3469+ } ) ,
3470+ ..Default :: default ( )
3471+ } ) ,
3472+ ..Default :: default ( )
3473+ } ) ;
3474+
3475+ runtime. validate_sandbox_create ( & sandbox) . await . unwrap ( ) ;
3476+ runtime. create_sandbox ( sandbox, None ) . await . unwrap ( ) ;
3477+ assert ! ( runtime. delete_sandbox( "uds-sandbox" ) . await . unwrap( ) ) ;
3478+
3479+ let calls = driver. calls ( ) ;
3480+ assert_eq ! ( calls. len( ) , 4 , "unexpected calls: {calls:?}" ) ;
3481+ assert ! ( matches!( calls[ 0 ] , FakeComputeDriverCall :: GetCapabilities ) ) ;
3482+
3483+ let validated = match & calls[ 1 ] {
3484+ FakeComputeDriverCall :: ValidateSandboxCreate {
3485+ sandbox : Some ( sandbox) ,
3486+ } => sandbox,
3487+ other => panic ! ( "expected ValidateSandboxCreate call, got {other:?}" ) ,
3488+ } ;
3489+ assert_eq ! ( validated. id, "sb-uds" ) ;
3490+ assert_eq ! ( validated. name, "uds-sandbox" ) ;
3491+ let driver_config = validated
3492+ . spec
3493+ . as_ref ( )
3494+ . and_then ( |spec| spec. template . as_ref ( ) )
3495+ . and_then ( |template| template. driver_config . as_ref ( ) )
3496+ . expect ( "selected driver_config should be forwarded" ) ;
3497+ assert ! ( driver_config. fields. contains_key( "pool" ) ) ;
3498+ assert ! ( !driver_config. fields. contains_key( "network_mode" ) ) ;
3499+
3500+ let created = match & calls[ 2 ] {
3501+ FakeComputeDriverCall :: CreateSandbox {
3502+ sandbox : Some ( sandbox) ,
3503+ } => sandbox,
3504+ other => panic ! ( "expected CreateSandbox call, got {other:?}" ) ,
3505+ } ;
3506+ assert_eq ! ( created. id, "sb-uds" ) ;
3507+ assert_eq ! ( created. name, "uds-sandbox" ) ;
3508+
3509+ match & calls[ 3 ] {
3510+ FakeComputeDriverCall :: DeleteSandbox {
3511+ sandbox_id,
3512+ sandbox_name,
3513+ } => {
3514+ assert_eq ! ( sandbox_id, "sb-uds" ) ;
3515+ assert_eq ! ( sandbox_name, "uds-sandbox" ) ;
3516+ }
3517+ other => panic ! ( "expected DeleteSandbox call, got {other:?}" ) ,
3518+ }
3519+ }
3520+
34243521 #[ tokio:: test]
34253522 async fn create_sandbox_returns_resource_version_one ( ) {
34263523 let runtime = test_runtime ( Arc :: new ( TestDriver :: default ( ) ) ) . await ;
0 commit comments