-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_warm_pool.exs
More file actions
54 lines (42 loc) · 1.44 KB
/
test_warm_pool.exs
File metadata and controls
54 lines (42 loc) · 1.44 KB
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
# Test script to verify warm pool behavior
# Run with: mix run test_warm_pool.exs
alias FcExCp.{PoolManager, DesiredStateStore}
IO.puts("\n=== Testing Warm Pool with Multiple Jobs ===\n")
# Wait for initial warm VM to be created
Process.sleep(1500)
IO.puts("1. Initial state:")
IO.inspect(PoolManager.stats(), label: "Stats")
# Add a second job with the same spec
spec = %{
rootfs: "rootfs-web.ext4",
kernel: "vmlinux",
cmd: ["/app/bin/server"],
env: %{MIX_ENV: "prod", SECRET_KEY_BASE: "xyz..."},
resources: %{vcpu: 2, mem_mb: 512},
lifecycle: "service"
}
IO.puts("\n2. Adding second job 'web-app-2'...")
:ok = DesiredStateStore.put("web-app-2", "tenant-2", spec)
# Wait for reconciler
Process.sleep(1500)
IO.puts("\n3. After adding web-app-2:")
IO.inspect(PoolManager.stats(), label: "Stats")
# Check both VMs
case PoolManager.lookup("web-app-1") do
{:ok, info} -> IO.inspect(info, label: "web-app-1")
:error -> IO.puts("web-app-1: not found")
end
case PoolManager.lookup("web-app-2") do
{:ok, info} -> IO.inspect(info, label: "web-app-2")
:error -> IO.puts("web-app-2: not found")
end
# Inspect actual VM processes
IO.puts("\n4. Checking VM tenants:")
Registry.lookup(FcExCp.Registry, {:vm, "warm-7A0B641-3"})
|> case do
[{pid, _}] ->
state = :sys.get_state(pid)
IO.inspect(%{id: state.id, tenant: state.tenant, status: state.status}, label: "VM 1")
[] -> IO.puts("VM 1: not found")
end
IO.puts("\n=== Test Complete ===\n")