From 6fde9fe04f86a3376fc657f10b8aa32e4bc97436 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 27 四月 2026 17:50:15 +0800
Subject: [PATCH] feat: add auto tune console page
---
src/test/java/com/zy/ai/service/AutoTuneCoordinatorServiceImplTest.java | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/src/test/java/com/zy/ai/service/AutoTuneCoordinatorServiceImplTest.java b/src/test/java/com/zy/ai/service/AutoTuneCoordinatorServiceImplTest.java
index fc3f594..95977a7 100644
--- a/src/test/java/com/zy/ai/service/AutoTuneCoordinatorServiceImplTest.java
+++ b/src/test/java/com/zy/ai/service/AutoTuneCoordinatorServiceImplTest.java
@@ -19,6 +19,7 @@
import com.zy.asrs.service.WrkMastService;
import com.zy.common.utils.RedisUtil;
import com.zy.core.enums.RedisKeyType;
+import com.zy.system.entity.OperateLog;
import com.zy.system.service.ConfigService;
import com.zy.system.service.OperateLogService;
import org.junit.jupiter.api.BeforeEach;
@@ -422,6 +423,40 @@
}
@Test
+ void manualTriggerRunsAgentWithRunningLockAndDoesNotWriteSchedulerGuard() {
+ AutoTuneAgentService.AutoTuneAgentResult agentResult = successfulAgentResult();
+ agentResult.setTriggerType(AutoTuneTriggerType.MANUAL.getCode());
+ when(redisUtil.trySetStringIfAbsent(anyString(), anyString(), anyLong())).thenReturn(true);
+ when(autoTuneAgentService.runAutoTune(AutoTuneTriggerType.MANUAL.getCode())).thenReturn(agentResult);
+
+ AutoTuneCoordinatorService.AutoTuneCoordinatorResult result = coordinatorService().runManualAutoTune();
+
+ assertFalse(result.getSkipped());
+ assertTrue(result.getTriggered());
+ assertSame(agentResult, result.getAgentResult());
+ verify(autoTuneAgentService).runAutoTune(AutoTuneTriggerType.MANUAL.getCode());
+ verify(wrkMastService, never()).count(any(Wrapper.class));
+ verify(redisUtil, never()).set(eq(RedisKeyType.AI_AUTO_TUNE_LAST_TRIGGER_GUARD.key), any(), anyLong());
+ verify(redisUtil).compareAndDelete(anyString(), anyString());
+
+ ArgumentCaptor<OperateLog> operateLogCaptor = ArgumentCaptor.forClass(OperateLog.class);
+ verify(operateLogService).save(operateLogCaptor.capture());
+ assertEquals("ai_auto_tune_manual_trigger", operateLogCaptor.getValue().getAction());
+ }
+
+ @Test
+ void manualTriggerSkipsWhenRunningLockIsNotAcquired() {
+ when(redisUtil.trySetStringIfAbsent(anyString(), anyString(), anyLong())).thenReturn(false);
+
+ AutoTuneCoordinatorService.AutoTuneCoordinatorResult result = coordinatorService().runManualAutoTune();
+
+ assertTrue(result.getSkipped());
+ assertEquals("running_lock_not_acquired", result.getReason());
+ verify(autoTuneAgentService, never()).runAutoTune(anyString());
+ verify(redisUtil, never()).compareAndDelete(anyString(), anyString());
+ }
+
+ @Test
void agentExecutesSnapshotDryRunAndRealApplyToolSequence() {
AutoTuneAgentServiceImpl service = new AutoTuneAgentServiceImpl(
llmChatService,
--
Gitblit v1.9.1