-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_multi_simple.jl
More file actions
108 lines (90 loc) · 2.94 KB
/
Copy pathtest_multi_simple.jl
File metadata and controls
108 lines (90 loc) · 2.94 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
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
#!/usr/bin/env julia
# Simple test of multi-instance mode
using LLMBenchMCPServer
using ClaudeMCPTools
using JSON
using Sockets
# Create a test module
module SimpleMultiTest
using LLMBenchSimple
@bench "add" begin
promptval"What is 1 + 1?" == 2
end
end
# Test configuration
test_workspace = mktempdir()
socket_path = joinpath(test_workspace, "multi_test.sock")
println("Starting server in multi-instance mode...")
println("Workspace: $test_workspace")
println("Socket: $socket_path")
# Start server in background
server_pid = @async begin
try
setup_fn = (wd, pid="") -> Main.SimpleMultiTest.setup_problem(wd, pid)
grade_fn = (wd, t, pid="") -> Main.SimpleMultiTest.grade(wd, t, pid)
# Start server with timeout
timeout = Timer(15) do _
println("\nServer running for 15 seconds, shutting down...")
end
LLMBenchMCPServer.run_server_multi_instance(
setup_fn, grade_fn, socket_path, test_workspace,
verbose=true, use_revise=false,
include_basic_tools=false)
catch e
if !(e isa InterruptException)
@error "Server error" exception=e
end
end
end
# Wait for server to start
sleep(2)
# Test two simultaneous connections
println("\nTesting two simultaneous connections...")
for i in 1:2
@async begin
try
client = connect(socket_path)
# Send initialization
init_msg = Dict(
"jsonrpc" => "2.0",
"id" => 1,
"method" => "initialize",
"params" => Dict(
"protocolVersion" => "0.1.0",
"capabilities" => Dict()
)
)
println(client, JSON.json(init_msg))
response = JSON.parse(readline(client))
println("Client $i initialized")
# Setup problem
setup_msg = Dict(
"jsonrpc" => "2.0",
"id" => 2,
"method" => "tools/call",
"params" => Dict(
"name" => "setup_problem",
"arguments" => Dict("problem_id" => "add")
)
)
println(client, JSON.json(setup_msg))
response = JSON.parse(readline(client))
println("Client $i got problem: ", response["result"]["content"][1]["text"][1:50], "...")
close(client)
catch e
@error "Client $i error" exception=e
end
end
end
# Wait a bit for connections to complete
sleep(3)
# Check created directories
instance_dirs = filter(x -> startswith(x, "instance_"), readdir(test_workspace))
println("\nInstance directories created: ", instance_dirs)
println("Number of instances: ", length(instance_dirs))
# Interrupt server after demonstration
Base.throwto(server_pid, InterruptException())
sleep(1)
# Cleanup
rm(test_workspace, recursive=true)
println("\nTest completed successfully!")