@@ -1187,3 +1187,57 @@ impl OrchestratorTask {
11871187 }
11881188 }
11891189}
1190+
1191+ #[ cfg( test) ]
1192+ mod tests {
1193+ use super :: * ;
1194+
1195+ #[ tokio:: test]
1196+ async fn test_start_two_functions_then_stop_one ( ) {
1197+ // channels
1198+ let ( _tx, rx) = futures:: channel:: mpsc:: unbounded ( ) ;
1199+ let ( subscriber_tx, _subscriber_rx) = futures:: channel:: mpsc:: unbounded ( ) ;
1200+
1201+ // mock proxy expectations setting
1202+ let mut mock_proxy = crate :: proxy:: MockProxy :: new ( ) ;
1203+ mock_proxy. expect_update_nodes ( ) . returning ( |_| ( ) ) ;
1204+ mock_proxy. expect_update_resource_providers ( ) . returning ( |_| ( ) ) ;
1205+ mock_proxy. expect_update_active_instances ( ) . returning ( |_| ( ) ) ;
1206+ mock_proxy. expect_update_dependency_graph ( ) . returning ( |_| ( ) ) ;
1207+ mock_proxy. expect_retrieve_deploy_intents ( ) . returning ( || vec ! [ ] ) ;
1208+
1209+ // mock AgentAPI expectations
1210+ let mut mock_agent_api = edgeless_api:: outer:: agent:: MockAgentAPI :: new ( ) ;
1211+ mock_agent_api. expect_node_management_api ( )
1212+ . returning ( || {
1213+ let mut mock_node_mgmt_api = edgeless_api:: node_management:: MockNodeManagementAPI :: new ( ) ;
1214+ mock_node_mgmt_api. expect_update_peers ( )
1215+ . returning ( |_| Ok ( ( ) ) ) ;
1216+ Box :: new ( mock_node_mgmt_api)
1217+ } ) ;
1218+
1219+ let proxy = std:: sync:: Arc :: new ( tokio:: sync:: Mutex :: new ( mock_proxy) ) ;
1220+
1221+ let settings = crate :: EdgelessOrcBaselineSettings {
1222+ orchestration_strategy : crate :: OrchestrationStrategy :: RoundRobin ,
1223+ } ;
1224+
1225+ let mut _orchestrator = OrchestratorTask :: new ( rx, settings, proxy. clone ( ) , subscriber_tx) . await ;
1226+
1227+ // Add three nodes
1228+ let node_1_id = uuid:: Uuid :: new_v4 ( ) ;
1229+ let client_desc = crate :: client_desc:: ClientDesc {
1230+ agent_url : "http://node1/agent" . to_string ( ) ,
1231+ invocation_url : "http://node1" . to_string ( ) ,
1232+ capabilities : edgeless_api:: node_registration:: NodeCapabilities :: default ( ) ,
1233+ cordoned : false ,
1234+ api : Box :: new ( mock_agent_api) ,
1235+ } ;
1236+ let resource_providers = vec ! [ ] ;
1237+ _orchestrator. add_node ( node_1_id, client_desc, resource_providers) . await ;
1238+ // test if it works
1239+ assert_eq ! ( 1 , 1 ) ;
1240+ }
1241+ }
1242+
1243+
0 commit comments