initial commit
This commit is contained in:
59
examples/test_openrpc_methods.rs
Normal file
59
examples/test_openrpc_methods.rs
Normal file
@@ -0,0 +1,59 @@
|
||||
//! Test to verify OpenRPC method registration
|
||||
|
||||
use hero_supervisor_openrpc_client::SupervisorClient;
|
||||
use tokio::time::{sleep, Duration};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("🔍 Testing OpenRPC method registration");
|
||||
|
||||
// Start a local supervisor with OpenRPC (assume it's running)
|
||||
println!("📡 Connecting to OpenRPC server...");
|
||||
let client = SupervisorClient::new("http://127.0.0.1:3030").await?;
|
||||
|
||||
// Test basic methods first
|
||||
println!("🧪 Testing basic methods...");
|
||||
|
||||
// Test list_runners (should work)
|
||||
match client.list_runners().await {
|
||||
Ok(runners) => println!("✅ list_runners works: {:?}", runners),
|
||||
Err(e) => println!("❌ list_runners failed: {}", e),
|
||||
}
|
||||
|
||||
// Test get_all_runner_status (might have serialization issues)
|
||||
match client.get_all_runner_status().await {
|
||||
Ok(statuses) => println!("✅ get_all_runner_status works: {} runners", statuses.len()),
|
||||
Err(e) => println!("❌ get_all_runner_status failed: {}", e),
|
||||
}
|
||||
|
||||
// Test the new queue_and_wait method
|
||||
println!("🎯 Testing queue_and_wait method...");
|
||||
|
||||
// Create a simple test job
|
||||
use hero_supervisor::job::{JobBuilder, JobType};
|
||||
let job = JobBuilder::new()
|
||||
.caller_id("test_client")
|
||||
.context_id("method_test")
|
||||
.payload("print('Testing queue_and_wait method registration');")
|
||||
.job_type(JobType::OSIS)
|
||||
.runner_name("osis_actor") // Use existing runner
|
||||
.timeout(Duration::from_secs(10))
|
||||
.build()?;
|
||||
|
||||
match client.queue_and_wait("osis_actor", job, 10).await {
|
||||
Ok(Some(result)) => println!("✅ queue_and_wait works! Result: {}", result),
|
||||
Ok(None) => println!("⏰ queue_and_wait timed out"),
|
||||
Err(e) => {
|
||||
println!("❌ queue_and_wait failed: {}", e);
|
||||
|
||||
// Check if it's a MethodNotFound error
|
||||
if e.to_string().contains("Method not found") {
|
||||
println!("🔍 Method not found - this suggests trait registration issue");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
println!("🏁 OpenRPC method test completed");
|
||||
|
||||
Ok(())
|
||||
}
|
Reference in New Issue
Block a user