MCPcopy Create free account
hub / github.com/astercloud/aster / TestPool_Resume

Function TestPool_Resume

pkg/core/pool_test.go:428–487  ·  view source on GitHub ↗

TestPool_Resume 测试恢复 Agent 注意: 这个测试依赖于 Agent 实际保存消息到 Store,在单元测试环境中可能会失败

(t *testing.T)

Source from the content-addressed store, hash-verified

426// TestPool_Resume 测试恢复 Agent
427// 注意: 这个测试依赖于 Agent 实际保存消息到 Store,在单元测试环境中可能会失败
428func TestPool_Resume(t *testing.T) {
429 t.Skip("Skipping Resume test - requires real agent message persistence")
430 deps := createTestDeps(t)
431 ctx := context.Background()
432
433 // 第一个池 - 创建并保存 Agent
434 pool1 := NewPool(&PoolOptions{
435 Dependencies: deps,
436 MaxAgents: 10,
437 })
438
439 config := createTestConfig("persistent-agent")
440
441 // 创建 Agent
442 ag1, err := pool1.Create(ctx, config)
443 if err != nil {
444 t.Fatalf("Failed to create agent: %v", err)
445 }
446
447 // 发送消息以保存状态
448 err = ag1.Send(ctx, "Test message")
449 if err != nil {
450 t.Logf("Send message warning: %v", err)
451 }
452
453 // 等待保存完成
454 time.Sleep(100 * time.Millisecond)
455
456 // 关闭第一个池
457 if err := pool1.Shutdown(); err != nil {
458 t.Fatalf("Failed to shutdown pool1: %v", err)
459 }
460
461 // 第二个池 - 恢复 Agent
462 pool2 := NewPool(&PoolOptions{
463 Dependencies: deps,
464 MaxAgents: 10,
465 })
466 defer func() {
467 if err := pool2.Shutdown(); err != nil {
468 t.Errorf("Shutdown failed: %v", err)
469 }
470 }()
471
472 // 恢复 Agent
473 ag2, err := pool2.Resume(ctx, "persistent-agent", config)
474 if err != nil {
475 t.Fatalf("Failed to resume agent: %v", err)
476 }
477
478 if ag2 == nil {
479 t.Fatal("Resumed agent is nil")
480 }
481
482 // 验证 Agent 在池中
483 _, exists := pool2.Get("persistent-agent")
484 if !exists {
485 t.Error("Resumed agent not found in pool")

Callers

nothing calls this directly

Calls 9

CreateMethod · 0.95
ShutdownMethod · 0.95
ResumeMethod · 0.95
GetMethod · 0.95
createTestDepsFunction · 0.85
NewPoolFunction · 0.85
createTestConfigFunction · 0.85
ErrorMethod · 0.65
SendMethod · 0.45

Tested by

no test coverage detected