1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Environment variable translation tests temporarily disabled due to complex mocking requirements
// TODO: Enable when test infrastructure supports mock Docker
/*
use std::collections::HashMap;
use minifly_core::models::{CreateMachineRequest, MachineConfig, GuestConfig, CreateAppRequest};
mod common;
use common::*;
#[tokio::test]
async fn test_fly_env_vars_translation() {
let (url, _handle) = start_test_server().await;
let client = test_client();
// Create an app
let create_app_req = CreateAppRequest {
app_name: "env-test-app".to_string(),
org_slug: "personal".to_string(),
};
client
.post(&format!("{}/apps", url))
.json(&create_app_req)
.send()
.await
.expect("Failed to create app");
// Create a machine with some existing env vars
let mut env = HashMap::new();
env.insert("MY_VAR".to_string(), "my_value".to_string());
env.insert("NODE_ENV".to_string(), "production".to_string()); // Should not be overridden
let config = MachineConfig {
image: "alpine:latest".to_string(),
guest: GuestConfig {
cpu_kind: "shared".to_string(),
cpus: 1,
memory_mb: 256,
gpu_kind: None,
gpus: None,
kernel_args: None,
},
env: Some(env),
services: None,
mounts: None,
restart: None,
checks: None,
auto_destroy: None,
dns: None,
processes: None,
files: None,
init: None,
containers: None,
};
let req = CreateMachineRequest {
name: Some("env-test-machine".to_string()),
region: Some("local".to_string()),
config,
skip_launch: Some(true), // Skip actual container creation for unit test
skip_service_registration: None,
lease_ttl: None,
};
let response = client
.post(&format!("{}/apps/env-test-app/machines", url))
.json(&req)
.send()
.await
.expect("Failed to create machine");
assert_eq!(response.status(), 201);
let machine_data: serde_json::Value = response.json().await.unwrap();
// The actual environment variable translation happens inside the Docker container
// so we can only verify the machine was created successfully
// In integration tests, we would inspect the running container
assert_eq!(machine_data["name"], "env-test-machine");
assert_eq!(machine_data["region"], "local");
}
#[tokio::test]
async fn test_tigris_endpoint_translation() {
let (url, _handle) = start_test_server().await;
let client = test_client();
let create_app_req = CreateAppRequest {
app_name: "tigris-test-app".to_string(),
org_slug: "personal".to_string(),
};
client
.post(&format!("{}/apps", url))
.json(&create_app_req)
.send()
.await
.expect("Failed to create app");
// Create a machine with Tigris/S3 endpoints
let mut env = HashMap::new();
env.insert("TIGRIS_ENDPOINT".to_string(), "https://fly.storage.tigris.dev".to_string());
env.insert("AWS_ENDPOINT_URL".to_string(), "https://fly.storage.tigris.dev".to_string());
let config = MachineConfig {
image: "alpine:latest".to_string(),
guest: GuestConfig {
cpu_kind: "shared".to_string(),
cpus: 1,
memory_mb: 256,
gpu_kind: None,
gpus: None,
kernel_args: None,
},
env: Some(env),
services: None,
mounts: None,
restart: None,
checks: None,
auto_destroy: None,
dns: None,
processes: None,
files: None,
init: None,
containers: None,
};
let req = CreateMachineRequest {
name: Some("tigris-test-machine".to_string()),
region: Some("local".to_string()),
config,
skip_launch: Some(true),
skip_service_registration: None,
lease_ttl: None,
};
let response = client
.post(&format!("{}/apps/tigris-test-app/machines", url))
.json(&req)
.send()
.await
.expect("Failed to create machine");
assert_eq!(response.status(), 201);
// When the container is created, TIGRIS_ENDPOINT and AWS_ENDPOINT_URL
// should be translated to point to local MinIO (http://localhost:9000)
}
*/