oxirs_embed/cloud_integration/
functions.rs1#[cfg(test)]
6mod tests {
7 use super::super::{
8 AWSSageMakerService, CloudIntegrationConfig, CloudIntegrationManager, CloudService,
9 DeploymentConfig, DeploymentStatus, NetworkingConfig, ResourceRequirements,
10 };
11 use std::collections::HashMap;
12 #[tokio::test]
13 async fn test_cloud_integration_manager_creation() {
14 let config = CloudIntegrationConfig::default();
15 let manager = CloudIntegrationManager::new(config);
16 let providers = manager.providers.read().await;
17 assert!(providers.is_empty());
18 }
19 #[tokio::test]
20 async fn test_aws_sagemaker_service() {
21 let service = AWSSageMakerService::new(
22 "us-east-1".to_string(),
23 "test_key".to_string(),
24 "test_secret".to_string(),
25 None,
26 );
27 let config = DeploymentConfig {
28 model_name: "test-model".to_string(),
29 model_version: "1.0".to_string(),
30 instance_type: "ml.m5.large".to_string(),
31 initial_instance_count: 1,
32 auto_scaling_enabled: true,
33 environment_variables: HashMap::new(),
34 resource_requirements: ResourceRequirements {
35 cpu_cores: 2.0,
36 memory_gb: 8.0,
37 gpu_count: 0,
38 storage_gb: 50,
39 },
40 networking: NetworkingConfig {
41 vpc_config: None,
42 enable_network_isolation: false,
43 custom_security_groups: vec![],
44 },
45 data_capture: None,
46 };
47 let result = service.deploy_model(&config).await.expect("should succeed");
48 assert!(matches!(result.status, DeploymentStatus::Creating));
49 assert!(result.cost_estimate.is_some());
50 }
51 #[tokio::test]
52 async fn test_cost_estimation() {
53 let service = AWSSageMakerService::new(
54 "us-east-1".to_string(),
55 "test_key".to_string(),
56 "test_secret".to_string(),
57 None,
58 );
59 let config = DeploymentConfig {
60 model_name: "test-model".to_string(),
61 model_version: "1.0".to_string(),
62 instance_type: "ml.m5.large".to_string(),
63 initial_instance_count: 2,
64 auto_scaling_enabled: true,
65 environment_variables: HashMap::new(),
66 resource_requirements: ResourceRequirements {
67 cpu_cores: 2.0,
68 memory_gb: 8.0,
69 gpu_count: 0,
70 storage_gb: 50,
71 },
72 networking: NetworkingConfig {
73 vpc_config: None,
74 enable_network_isolation: false,
75 custom_security_groups: vec![],
76 },
77 data_capture: None,
78 };
79 let estimate = service
80 .estimate_costs(&config, 24)
81 .await
82 .expect("should succeed");
83 assert!(estimate.hourly_cost_usd > 0.0);
84 assert!(estimate.estimated_monthly_cost_usd > 0.0);
85 }
86}