From dc941636c3bb489f9f9dfacba303f2896d650549 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 25 Mar 2026 00:19:22 +0800 Subject: [PATCH] test(robot): update integration tests to use dry run executor - Modified integration tests to utilize the new dry run executor in the manager configuration, ensuring consistent execution behavior during testing. - Updated multiple test cases to replace direct manager instantiation with the new configuration method, enhancing test reliability and maintainability. --- agent/robot/manager/integration_test.go | 8 ++++---- agent/robot/manager/manager_test.go | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/agent/robot/manager/integration_test.go b/agent/robot/manager/integration_test.go index 12d69d43..742ef4b0 100644 --- a/agent/robot/manager/integration_test.go +++ b/agent/robot/manager/integration_test.go @@ -52,10 +52,10 @@ func TestIntegrationSchedulingFlow(t *testing.T) { // Setup: Create a robot with times mode clock config setupIntegrationRobotTimes(t, "robot_integ_flow_clock", "team_integ_flow") - // Create manager with slow tick interval to avoid auto-tick interference config := &manager.Config{ TickInterval: 10 * time.Second, PoolConfig: &pool.Config{WorkerSize: 5, QueueSize: 50}, + Executor: executor.NewDryRun(), } m := manager.NewWithConfig(config) @@ -91,7 +91,7 @@ func TestIntegrationSchedulingFlow(t *testing.T) { setupIntegrationRobotTimes(t, "robot_integ_flow_db1", "team_integ_flow") setupIntegrationRobotInterval(t, "robot_integ_flow_db2", "team_integ_flow") - m := manager.New() + m := manager.NewWithConfig(&manager.Config{Executor: executor.NewDryRun()}) err := m.Start() require.NoError(t, err) defer m.Stop() @@ -116,7 +116,7 @@ func TestIntegrationSchedulingFlow(t *testing.T) { // Setup: Create an inactive robot setupIntegrationRobotInactive(t, "robot_integ_flow_inactive", "team_integ_flow") - m := manager.New() + m := manager.NewWithConfig(&manager.Config{Executor: executor.NewDryRun()}) err := m.Start() require.NoError(t, err) defer m.Stop() @@ -130,7 +130,7 @@ func TestIntegrationSchedulingFlow(t *testing.T) { // Setup: Create a robot with autonomous_mode=false setupIntegrationRobotNonAutonomous(t, "robot_integ_flow_nonauto", "team_integ_flow") - m := manager.New() + m := manager.NewWithConfig(&manager.Config{Executor: executor.NewDryRun()}) err := m.Start() require.NoError(t, err) defer m.Stop() diff --git a/agent/robot/manager/manager_test.go b/agent/robot/manager/manager_test.go index 7ea57adf..3266be8a 100644 --- a/agent/robot/manager/manager_test.go +++ b/agent/robot/manager/manager_test.go @@ -11,6 +11,7 @@ import ( "github.com/yaoapp/gou/model" "github.com/yaoapp/xun/capsule" agentcontext "github.com/yaoapp/yao/agent/context" + "github.com/yaoapp/yao/agent/robot/executor" "github.com/yaoapp/yao/agent/robot/manager" "github.com/yaoapp/yao/agent/robot/pool" "github.com/yaoapp/yao/agent/robot/types" @@ -89,10 +90,10 @@ func TestManagerTick(t *testing.T) { defer cleanupTestRobots(t) t.Run("tick with times mode - matching time", func(t *testing.T) { - // Create manager with short tick interval for testing config := &manager.Config{ TickInterval: 100 * time.Millisecond, PoolConfig: &pool.Config{WorkerSize: 2, QueueSize: 10}, + Executor: executor.NewDryRun(), } m := manager.NewWithConfig(config) @@ -121,6 +122,7 @@ func TestManagerTick(t *testing.T) { config := &manager.Config{ TickInterval: 100 * time.Millisecond, PoolConfig: &pool.Config{WorkerSize: 2, QueueSize: 10}, + Executor: executor.NewDryRun(), } m := manager.NewWithConfig(config) @@ -153,6 +155,7 @@ func TestManagerTick(t *testing.T) { config := &manager.Config{ TickInterval: 100 * time.Millisecond, PoolConfig: &pool.Config{WorkerSize: 2, QueueSize: 10}, + Executor: executor.NewDryRun(), } m := manager.NewWithConfig(config) @@ -181,6 +184,7 @@ func TestManagerTick(t *testing.T) { config := &manager.Config{ TickInterval: 100 * time.Millisecond, PoolConfig: &pool.Config{WorkerSize: 2, QueueSize: 10}, + Executor: executor.NewDryRun(), } m := manager.NewWithConfig(config) @@ -295,7 +299,7 @@ func TestManagerClockModes(t *testing.T) { defer cleanupTestRobots(t) t.Run("times mode - day matching", func(t *testing.T) { - m := manager.New() + m := manager.NewWithConfig(&manager.Config{Executor: executor.NewDryRun()}) err := m.Start() assert.NoError(t, err) defer m.Stop() @@ -315,7 +319,7 @@ func TestManagerClockModes(t *testing.T) { }) t.Run("times mode - day not matching", func(t *testing.T) { - m := manager.New() + m := manager.NewWithConfig(&manager.Config{Executor: executor.NewDryRun()}) err := m.Start() assert.NoError(t, err) defer m.Stop() @@ -336,7 +340,7 @@ func TestManagerClockModes(t *testing.T) { }) t.Run("daemon mode - always triggers when idle", func(t *testing.T) { - m := manager.New() + m := manager.NewWithConfig(&manager.Config{Executor: executor.NewDryRun()}) err := m.Start() assert.NoError(t, err) defer m.Stop() @@ -374,7 +378,7 @@ func TestManagerTimezoneDedup(t *testing.T) { defer cleanupTestRobots(t) t.Run("times mode - same minute same day should not trigger twice", func(t *testing.T) { - m := manager.New() + m := manager.NewWithConfig(&manager.Config{Executor: executor.NewDryRun()}) err := m.Start() assert.NoError(t, err) defer m.Stop() @@ -414,7 +418,7 @@ func TestManagerTimezoneDedup(t *testing.T) { }) t.Run("times mode - different day should trigger again", func(t *testing.T) { - m := manager.New() + m := manager.NewWithConfig(&manager.Config{Executor: executor.NewDryRun()}) err := m.Start() assert.NoError(t, err) defer m.Stop() @@ -444,7 +448,7 @@ func TestManagerTimezoneDedup(t *testing.T) { }) t.Run("times mode - cross-timezone day boundary", func(t *testing.T) { - m := manager.New() + m := manager.NewWithConfig(&manager.Config{Executor: executor.NewDryRun()}) err := m.Start() assert.NoError(t, err) defer m.Stop() @@ -477,7 +481,7 @@ func TestManagerTimezoneDedup(t *testing.T) { }) t.Run("times mode - UTC vs local timezone comparison", func(t *testing.T) { - m := manager.New() + m := manager.NewWithConfig(&manager.Config{Executor: executor.NewDryRun()}) err := m.Start() assert.NoError(t, err) defer m.Stop()