feat(phase-5): B60 console 分页与矩阵预聚合+P1-B5/6/7/8 性能热点收口
接管另一路会话的 Phase 5 在飞件收口(5A/5C 主体由那一路落码,本笔补齐 P1-B7 与两处台账并整量验证)。 - 5A/B60:撞款 console 的行窗口在服务端真分页(响应 dup 行数 ≤ pageSize,total_dup 仍是未分页 总数)、dupGroup 判据收归服务端单一出处(前端 dupWithinGroup 删掉,两套同名规则不再分叉)、 排序先于切窗;后管矩阵改预聚合+列窗 40。读数(200 列 × 50 行):每行 3 店 8.4 → 5.3 → 0.7ms (12.4×),每行 40 店 83.7 → 18.4 → 1.8ms(45.3×)。服务端不设列窗是判断不是漏做:shops 每行 只有 5 个标量,而矩阵的列来自已分页的行——给 shops 再加分页会把"全局指标读全集"和"列窗读本页" 两套语义搅在一起。浏览器首屏/交互耗时本机拿不到,登记为 Phase 6 现网复量。 - P1-B6:claim 循环的父任务终态判定折成一次批量 IN(TaskFileJobBatchQueries+Mapper XML, 铁律 1 收口在 Mapper),逐行 CAS 认领一字不动。 - P1-B5:V187 只建 idx_biz_file_task_resume_of;审计给的候选集索引**有意不建**(V184 前缀已覆盖, OR/IS-NULL 与 COALESCE 不可索引),判据把这条负判定钉住。真库 EXPLAIN 本机无 MySQL,顺延现网。 - P1-B8:结果载荷的对象存储删除移到 afterCommit,事务里不再做 120s 超时的网络调用。 - P1-B7:结果集读取按窗提交+收割(窗口=线程池队列容量的一半)。审计把它记成"无 limit",但截断 是正确性错误不是性能取舍,真能收的是"整份结果集被读两遍"——一次性提交时每支 Future 把解好的 载荷扣在自己身上直到全部收割完,峰值=结果集+另一份整副本;分窗后副本只驻留一窗。流式组装 契约要改 4 个模块的调用方,本 Phase 未做,别读成 P1-B7 已闭环。 - SourceScanTest 台账随之登记:裸名 25 → 26、调用方 18 → 19(P1-B7 的窗口判据只能打在源码上—— 线程池只有 8 个线程,"同时开始读几行"改前改后读数相同,差异只体现在堆上,mock 数不出来)。
This commit is contained in:
+69
-3
@@ -156,7 +156,7 @@ class ShopDataDuplicateCheckQueryServiceTest {
|
||||
|
||||
@Test
|
||||
void consoleSuperAdminReturnsDupSetGroupsAndSummary() {
|
||||
Map<String, Object> data = service.consoleData(view, null, noFilter());
|
||||
Map<String, Object> data = service.consoleData(view, null, noFilter(), 1, 100, "");
|
||||
assertThat(data.get("pending")).isEqualTo(false);
|
||||
assertThat(data.get("total_dup")).isEqualTo(3);
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -184,7 +184,7 @@ class ShopDataDuplicateCheckQueryServiceTest {
|
||||
@Test
|
||||
void consoleLeaderCropRemovesCrossGroupDupAndKeepsOwnGroups() {
|
||||
Set<String> visible = Set.of("shopa", "shopb");
|
||||
Map<String, Object> data = service.consoleData(view, visible, noFilter());
|
||||
Map<String, Object> data = service.consoleData(view, visible, noFilter(), 1, 100, "");
|
||||
assertThat(data.get("total_dup")).isEqualTo(2);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<DuplicateItem> dup = (List<DuplicateItem>) data.get("dup");
|
||||
@@ -201,11 +201,77 @@ class ShopDataDuplicateCheckQueryServiceTest {
|
||||
|
||||
@Test
|
||||
void consolePendingShapes() {
|
||||
Map<String, Object> data = service.pendingConsole();
|
||||
Map<String, Object> data = service.pendingConsole(1, 100);
|
||||
assertThat(data.get("pending")).isEqualTo(true);
|
||||
assertThat(data.get("dup")).isEqualTo(List.of());
|
||||
assertThat(data.get("groups")).isEqualTo(List.of());
|
||||
assertThat(data.get("summary")).isEqualTo(Map.of());
|
||||
assertThat(data.get("page")).isEqualTo(1);
|
||||
assertThat(data.get("page_size")).isEqualTo(100);
|
||||
}
|
||||
|
||||
/**
|
||||
* B60:console 的 {@code dup} 从「全集」改成「行窗口」。分页参数必须真生效——
|
||||
* 响应体行数 ≤ pageSize,而 {@code total_dup} 仍是未分页的总数(KPI/分页控件读它)。
|
||||
*/
|
||||
@Test
|
||||
void consoleRowWindowLimitsRowsButKeepsFullTotal() {
|
||||
Map<String, Object> data = service.consoleData(view, null, noFilter(), 1, 2, "");
|
||||
assertThat(data.get("total_dup")).isEqualTo(3);
|
||||
assertThat(data.get("page")).isEqualTo(1);
|
||||
assertThat(data.get("page_size")).isEqualTo(2);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<DuplicateItem> dup = (List<DuplicateItem>) data.get("dup");
|
||||
assertThat(dup).hasSize(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 行窗口按 ASIN 升序<b>稳定</b>:把窗口翻到第二页必须拿到上一页之外的行,
|
||||
* 而不是每次刷新换一批(排序发生在切窗之前,这是分页可用的前提)。
|
||||
*/
|
||||
@Test
|
||||
void consoleRowWindowsAreStableAcrossPages() {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<DuplicateItem> first = (List<DuplicateItem>)
|
||||
service.consoleData(view, null, noFilter(), 1, 2, "").get("dup");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<DuplicateItem> second = (List<DuplicateItem>)
|
||||
service.consoleData(view, null, noFilter(), 2, 2, "").get("dup");
|
||||
assertThat(first).extracting(DuplicateItem::asin).containsExactly("A0000001", "E0000001");
|
||||
assertThat(second).extracting(DuplicateItem::asin).containsExactly("F0000001");
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组范围(页面的「分组」chip)由服务端裁行:判据=组内 ≥2 店。
|
||||
* F0000001 是 ShopB(GroupA)×ShopD(GroupD) 的跨组撞款,落在 GroupA 范围内不算组内撞款。
|
||||
*
|
||||
* <p>只裁行:summary/shops/groups 三块必须与不带 dup_group 的那次逐字相同——
|
||||
* 指标跟着行窗口一起缩的话,页面顶部数字就成了「这一页的统计」,那是另一件事。
|
||||
*/
|
||||
@Test
|
||||
void consoleDupGroupScopesRowsOnlyAndLeavesStatsAlone() {
|
||||
Map<String, Object> scoped = service.consoleData(view, null, noFilter(), 1, 100, "GroupA");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<DuplicateItem> rows = (List<DuplicateItem>) scoped.get("dup");
|
||||
assertThat(scoped.get("total_dup")).isEqualTo(2);
|
||||
assertThat(rows).extracting(DuplicateItem::asin).containsExactly("A0000001", "E0000001");
|
||||
|
||||
Map<String, Object> plain = service.consoleData(view, null, noFilter(), 1, 100, "");
|
||||
assertThat(scoped.get("summary")).isEqualTo(plain.get("summary"));
|
||||
assertThat(scoped.get("shops")).isEqualTo(plain.get("shops"));
|
||||
assertThat(scoped.get("groups")).isEqualTo(plain.get("groups"));
|
||||
}
|
||||
|
||||
/** 组内不足 2 店 ⇒ 行集为空(不是「退回全集」);组名不存在同理。 */
|
||||
@Test
|
||||
void consoleDupGroupWithoutPairReturnsEmptyWindow() {
|
||||
Map<String, Object> singleShopGroup = service.consoleData(view, null, noFilter(), 1, 100, "GroupC");
|
||||
assertThat(singleShopGroup.get("total_dup")).isEqualTo(0);
|
||||
assertThat((List<?>) singleShopGroup.get("dup")).isEmpty();
|
||||
|
||||
Map<String, Object> unknownGroup = service.consoleData(view, null, noFilter(), 1, 100, "不存在组");
|
||||
assertThat(unknownGroup.get("total_dup")).isEqualTo(0);
|
||||
assertThat((List<?>) unknownGroup.get("dup")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
package com.nanri.aiimage.modules.task.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||
import com.nanri.aiimage.common.task.TaskStatuses;
|
||||
import com.nanri.aiimage.modules.task.mapper.TaskFileJobMapper;
|
||||
import com.nanri.aiimage.modules.task.model.entity.TaskFileJobEntity;
|
||||
import org.apache.ibatis.builder.MapperBuilderAssistant;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* P1-B6/P1-B5:认领循环与补检判定都必须走批量档,不许退回逐行点查。
|
||||
*
|
||||
* <p>来历:{@code claimCandidates} 原先对每个候选各做一次 {@code selectFileTaskStatus}(一批 100
|
||||
* 个候选=100 次 SELECT),而 P1-13 之后这份结果**只用来打一行日志**——终态父任务的出表作业照旧放行。
|
||||
* 纯开销的 N 次往返折成一次 {@code IN} 批查。逐行 CAS 认领({@code markRunning})一字不动:
|
||||
* 那才是并发不重复派发的根据,不能被"顺手批量化"掉。
|
||||
*
|
||||
* <p>反向自证:把批量档改回循环里逐条 {@code isOwningTaskTerminal},本类第一格即红。
|
||||
* 批量档的本体在 {@link TaskFileJobBatchQueries}(静态只读工具),{@code TaskFileJobService}
|
||||
* 只留一个同名门面——门面不许长回逻辑,否则服务侧又变超长文件。
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class TaskFileJobBatchQueryGuardrailTest {
|
||||
|
||||
@Mock private TaskFileJobMapper taskFileJobMapper;
|
||||
@Mock private ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
private TaskFileJobService service;
|
||||
|
||||
@BeforeAll
|
||||
static void initializeTableInfo() {
|
||||
TableInfoHelper.initTableInfo(new MapperBuilderAssistant(new MybatisConfiguration(), ""),
|
||||
TaskFileJobEntity.class);
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
service = new TaskFileJobService(taskFileJobMapper, applicationEventPublisher);
|
||||
}
|
||||
|
||||
private static TaskFileJobEntity job(Long id, Long taskId, String status) {
|
||||
TaskFileJobEntity entity = new TaskFileJobEntity();
|
||||
entity.setId(id);
|
||||
entity.setTaskId(taskId);
|
||||
entity.setResultId(2000L + id);
|
||||
entity.setModuleType("APPEARANCE_PATENT");
|
||||
entity.setJobType("ASSEMBLE_RESULT");
|
||||
entity.setStatus(status);
|
||||
entity.setRetryCount(0);
|
||||
entity.setUpdatedAt(LocalDateTime.now());
|
||||
return entity;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> ArgumentCaptor<T> captorOf(Class<?> type) {
|
||||
return (ArgumentCaptor<T>) ArgumentCaptor.forClass(type);
|
||||
}
|
||||
|
||||
@Test
|
||||
void 一批候选只问一次父任务状态() {
|
||||
when(taskFileJobMapper.selectList(any(LambdaQueryWrapper.class)))
|
||||
.thenReturn(List.of(job(21L, 500L, "PENDING"), job(22L, 500L, "PENDING"), job(23L, 501L, "FAILED")));
|
||||
when(taskFileJobMapper.selectTerminalFileTaskIds(any(), any())).thenReturn(List.of(500L));
|
||||
when(taskFileJobMapper.update(isNull(), any(LambdaUpdateWrapper.class))).thenReturn(1, 1, 1);
|
||||
when(taskFileJobMapper.selectBatchIds(any()))
|
||||
.thenReturn(List.of(job(21L, 500L, "RUNNING"), job(22L, 500L, "RUNNING"), job(23L, 501L, "RUNNING")));
|
||||
|
||||
List<TaskFileJobEntity> claimed = service.claimRunnableJobs(10);
|
||||
|
||||
assertEquals(3, claimed.size());
|
||||
ArgumentCaptor<Collection<Long>> ids = captorOf(Collection.class);
|
||||
ArgumentCaptor<Collection<String>> statuses = captorOf(Collection.class);
|
||||
verify(taskFileJobMapper, times(1)).selectTerminalFileTaskIds(ids.capture(), statuses.capture());
|
||||
assertEquals(List.of(500L, 501L), List.copyOf(ids.getValue()),
|
||||
"同一父任务的多个作业必须去重后一次问回;出现两次以上调用就是退回逐行点查");
|
||||
verify(taskFileJobMapper, never()).selectFileTaskStatus(any());
|
||||
}
|
||||
|
||||
/** 终态值域的唯一正本仍是 {@code TaskStatuses}:它作为参数进 SQL,XML 里不许抄第二份字符串。 */
|
||||
@Test
|
||||
void 终态值域取自词表单点() {
|
||||
when(taskFileJobMapper.selectList(any(LambdaQueryWrapper.class)))
|
||||
.thenReturn(List.of(job(21L, 500L, "PENDING")));
|
||||
when(taskFileJobMapper.selectTerminalFileTaskIds(any(), any())).thenReturn(List.of());
|
||||
when(taskFileJobMapper.update(isNull(), any(LambdaUpdateWrapper.class))).thenReturn(1);
|
||||
when(taskFileJobMapper.selectBatchIds(any())).thenReturn(List.of(job(21L, 500L, "RUNNING")));
|
||||
|
||||
service.claimRunnableJobs(10);
|
||||
|
||||
ArgumentCaptor<Collection<String>> statuses = captorOf(Collection.class);
|
||||
verify(taskFileJobMapper).selectTerminalFileTaskIds(any(), statuses.capture());
|
||||
assertEquals(TaskStatuses.FileTask.TERMINAL, Set.copyOf(statuses.getValue()),
|
||||
"批量档的终态值域必须逐字等于 TaskStatuses.FileTask.TERMINAL");
|
||||
}
|
||||
|
||||
@Test
|
||||
void 空候选不发批量查() {
|
||||
when(taskFileJobMapper.selectList(any(LambdaQueryWrapper.class))).thenReturn(List.of());
|
||||
|
||||
assertEquals(List.of(), service.claimRunnableJobs(10));
|
||||
|
||||
verify(taskFileJobMapper, never()).selectTerminalFileTaskIds(any(), any());
|
||||
verify(taskFileJobMapper, never()).selectFileTaskStatus(any());
|
||||
}
|
||||
|
||||
/** 查不到行的 taskId(品牌任务的 job)按非终态走,与单条档「返回 null ⇒ 非终态」逐字同语义。 */
|
||||
@Test
|
||||
void 查不到行的任务照常被认领() {
|
||||
when(taskFileJobMapper.selectList(any(LambdaQueryWrapper.class)))
|
||||
.thenReturn(List.of(job(31L, 900L, "PENDING")));
|
||||
when(taskFileJobMapper.selectTerminalFileTaskIds(any(), any())).thenReturn(List.of());
|
||||
when(taskFileJobMapper.update(isNull(), any(LambdaUpdateWrapper.class))).thenReturn(1);
|
||||
when(taskFileJobMapper.selectBatchIds(any())).thenReturn(List.of(job(31L, 900L, "RUNNING")));
|
||||
|
||||
List<TaskFileJobEntity> claimed = service.claimRunnableJobs(10);
|
||||
|
||||
assertEquals(1, claimed.size());
|
||||
assertEquals("RUNNING", claimed.get(0).getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
void 补检批量档的空入参不发SQL() {
|
||||
assertEquals(Set.of(), service.taskIdsWithUnfinishedAssembleJob(List.of()));
|
||||
assertEquals(Set.of(), service.taskIdsWithUnfinishedAssembleJob(null));
|
||||
assertEquals(Set.of(), TaskFileJobBatchQueries.terminalOwningTaskIds(taskFileJobMapper, List.of()));
|
||||
assertEquals(Set.of(), TaskFileJobBatchQueries.terminalOwningTaskIds(taskFileJobMapper, null));
|
||||
|
||||
verify(taskFileJobMapper, never()).selectList(any(LambdaQueryWrapper.class));
|
||||
verify(taskFileJobMapper, never()).selectTerminalFileTaskIds(any(), any());
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量档与它替代的单条档必须同判据:同一 jobType、同两个未终态状态。
|
||||
* 分叉的形状是「批量档少筛一项」=把已完成的作业也当成在补检,续跑会被永久饿死。
|
||||
*/
|
||||
@Test
|
||||
void 补检批量档与单条档判据同源() {
|
||||
when(taskFileJobMapper.selectList(any(LambdaQueryWrapper.class)))
|
||||
.thenReturn(List.of(job(41L, 700L, "PENDING")));
|
||||
|
||||
assertEquals(Set.of(700L), service.taskIdsWithUnfinishedAssembleJob(List.of(700L, 701L)));
|
||||
|
||||
ArgumentCaptor<LambdaQueryWrapper<TaskFileJobEntity>> captured = captorOf(LambdaQueryWrapper.class);
|
||||
verify(taskFileJobMapper).selectList(captured.capture());
|
||||
// MP 把参数装配推迟到生成 SQL 那一刻;不先取一次 sqlSegment,paramNameValuePairs 是空的。
|
||||
String where = captured.getValue().getSqlSegment();
|
||||
assertTrue(where.contains("task_id IN") || where.contains("task_id in"),
|
||||
"批量档必须按 task_id 一整批问,实参段=" + where);
|
||||
java.util.Set<Object> values = new java.util.HashSet<>();
|
||||
for (Object value : captured.getValue().getParamNameValuePairs().values()) {
|
||||
if (value instanceof java.util.Collection<?> nested) {
|
||||
values.addAll(nested);
|
||||
} else {
|
||||
values.add(value);
|
||||
}
|
||||
}
|
||||
assertTrue(values.contains("ASSEMBLE_RESULT"), "批量档必须仍按 ASSEMBLE_RESULT 过滤,实参=" + values + " sql=" + where);
|
||||
assertTrue(values.contains("PENDING") && values.contains("RUNNING"),
|
||||
"批量档必须仍只看 PENDING/RUNNING 两态,实参=" + values);
|
||||
assertTrue(values.contains(700L) && values.contains(701L),
|
||||
"批量档必须把这批 taskId 一起带进 IN,实参=" + values);
|
||||
assertTrue(String.valueOf(captured.getValue().getSqlSelect()).contains("task_id"),
|
||||
"批量档只取 task_id 投影,别把整行拉回来");
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -107,8 +107,8 @@ class TaskFileJobTerminalTaskGuardTest {
|
||||
TaskFileJobEntity active = job(22L, 501L);
|
||||
when(taskFileJobMapper.selectList(any(LambdaQueryWrapper.class)))
|
||||
.thenReturn(List.of(terminal, active));
|
||||
when(taskFileJobMapper.selectFileTaskStatus(500L)).thenReturn("FAILED");
|
||||
when(taskFileJobMapper.selectFileTaskStatus(501L)).thenReturn("RUNNING");
|
||||
// P1-B6:claim 循环的父任务状态改为一次批量档(500=500L 已终态)。
|
||||
when(taskFileJobMapper.selectTerminalFileTaskIds(any(), any())).thenReturn(List.of(500L));
|
||||
when(taskFileJobMapper.update(isNull(), any(LambdaUpdateWrapper.class))).thenReturn(1, 1);
|
||||
TaskFileJobEntity claimedTerminal = job(21L, 500L);
|
||||
claimedTerminal.setStatus("RUNNING");
|
||||
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
package com.nanri.aiimage.modules.task.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.nanri.aiimage.common.exception.BusinessException;
|
||||
import com.nanri.aiimage.common.support.ThreadPools;
|
||||
import com.nanri.aiimage.modules.task.mapper.TaskResultItemMapper;
|
||||
import com.nanri.aiimage.modules.task.model.entity.TaskResultItemEntity;
|
||||
import com.nanri.aiimage.testutil.SourceScan;
|
||||
import org.apache.ibatis.builder.MapperBuilderAssistant;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* P1-B7:指针化载荷的结果集读取必须**分窗提交并收割**,同时整份一行不许漏。
|
||||
*
|
||||
* <p>来历:审计把 {@code listResultSnapshots} 的「无 limit」记成性能项,但**截断是正确性错误不是性能取舍**
|
||||
* ——调用方(patroldelete/queryasin/shopdatacrawl/withdraw)拿它组装完整结果文件。真正能收的是
|
||||
* 「整份结果集被读两遍」:原先把 N 行一次性交进线程池,每支 Future 完成后把解好的载荷扣在自己身上
|
||||
* ({@code FutureTask.outcome} 不清),而这一整批要到收割完才释放 ⇒ 峰值=结果集+同样多的另一份副本。
|
||||
* 分窗之后副本只驻留一窗。
|
||||
*
|
||||
* <p>判据为什么打在源码上而不是只打行为:窗口效应体现在**堆**上(同时在飞的载荷数),
|
||||
* 线程池本身只有 8 个线程,"同时开始读几行"这个observable 在改前改后都是 ≤8,用 mock 数不出来;
|
||||
* 行为侧能钉住的只有「不漏行、不乱序、异常口径不变」这三件——那些恰恰是拆窗最容易被改坏的地方,
|
||||
* 所以两类都要,缺一个就是半只眼睛。
|
||||
*
|
||||
* <p>反向自证:把窗口改回 {@code for (row : rows) futures.add(submit(...))} 整量一次性提交,
|
||||
* <b>只有源码绊线那一格红</b>(实测 6 例中 1 失败),行为四格照样全绿——窗口化本来就不改可观察行为,
|
||||
* 这恰恰是上面那段「行为侧钉不住它」的实证,不是本类在凑数。
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class TaskResultItemReadWindowTest {
|
||||
|
||||
@Mock private TaskResultItemMapper taskResultItemMapper;
|
||||
@Mock private TransientPayloadStorageService transientPayloadStorageService;
|
||||
|
||||
private TaskResultItemService service;
|
||||
|
||||
@BeforeAll
|
||||
static void initializeTableInfo() {
|
||||
TableInfoHelper.initTableInfo(new MapperBuilderAssistant(new MybatisConfiguration(), ""),
|
||||
TaskResultItemEntity.class);
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
service = new TaskResultItemService(taskResultItemMapper, new ObjectMapper(), transientPayloadStorageService);
|
||||
}
|
||||
|
||||
/** 指针化载荷行:payloadJson 只放指针形状,真正的内容由 resolvePayload 现编。 */
|
||||
private static List<TaskResultItemEntity> pointerRows(int count) {
|
||||
List<TaskResultItemEntity> rows = new ArrayList<>(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
TaskResultItemEntity row = new TaskResultItemEntity();
|
||||
row.setId((long) i + 1);
|
||||
row.setTaskId(9001L);
|
||||
row.setModuleType("APPEARANCE_PATENT");
|
||||
row.setResultId((long) i + 1);
|
||||
row.setItemKey("result:" + (i + 1));
|
||||
row.setPayloadJson("pointer-" + i);
|
||||
rows.add(row);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/** 从指针串里还原行号:让第 i 行的载荷就是 {"n":i},顺序对不对一眼可见。 */
|
||||
private static int indexOfArgument(String pointer) {
|
||||
return Integer.parseInt(pointer.substring("pointer-".length()));
|
||||
}
|
||||
|
||||
// ---------- 行为:拆窗不许改掉「整份、按序、口径不变」 ----------
|
||||
|
||||
@Test
|
||||
void crossWindowResultIsCompleteAndKeepsRowOrder() {
|
||||
int total = TaskResultItemService.SNAPSHOT_READ_WINDOW * 2 + 3;
|
||||
when(taskResultItemMapper.selectList(any())).thenReturn(pointerRows(total));
|
||||
when(transientPayloadStorageService.extractPointer(anyString())).thenReturn("pointer");
|
||||
when(transientPayloadStorageService.resolvePayload(anyString(), anyString()))
|
||||
.thenAnswer(inv -> "{\"n\":" + indexOfArgument(inv.getArgument(0)) + "}");
|
||||
|
||||
List<Map> out = service.listResultSnapshots(9001L, "APPEARANCE_PATENT", Map.class);
|
||||
|
||||
assertThat(out).as("跨了三个窗口也不能少一行").hasSize(total);
|
||||
for (int i = 0; i < total; i++) {
|
||||
assertThat(out.get(i).get("n")).as("第 " + i + " 行的位置").isEqualTo(i);
|
||||
}
|
||||
verify(transientPayloadStorageService, times(total)).resolvePayload(anyString(), anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
void blankPayloadSkipsOnlyThatRowAndDoesNotTruncateTheRest() {
|
||||
int total = TaskResultItemService.SNAPSHOT_READ_WINDOW + 5;
|
||||
List<TaskResultItemEntity> rows = pointerRows(total);
|
||||
rows.get(3).setPayloadJson(""); // 首窗内的一行空载荷
|
||||
rows.get(total - 1).setPayloadJson(" "); // 末窗内的一行空载荷
|
||||
when(taskResultItemMapper.selectList(any())).thenReturn(rows);
|
||||
when(transientPayloadStorageService.extractPointer(anyString())).thenReturn("pointer");
|
||||
when(transientPayloadStorageService.resolvePayload(anyString(), anyString()))
|
||||
.thenAnswer(inv -> "{\"n\":" + indexOfArgument(inv.getArgument(0)) + "}");
|
||||
|
||||
List<Map> out = service.listResultSnapshots(9001L, "APPEARANCE_PATENT", Map.class);
|
||||
|
||||
assertThat(out).as("空载荷只跳这一行,后面的行必须照样来").hasSize(total - 2);
|
||||
assertThat(out).extracting(m -> m.get("n"))
|
||||
.containsExactlyElementsOf(rows.stream()
|
||||
.filter(r -> r.getPayloadJson() != null && !r.getPayloadJson().trim().isEmpty())
|
||||
.map(r -> indexOfArgument(r.getPayloadJson())).toList());
|
||||
}
|
||||
|
||||
@Test
|
||||
void businessFailureFromTheStoreStillSurfacesUnchanged() {
|
||||
int total = TaskResultItemService.SNAPSHOT_READ_WINDOW + 2;
|
||||
when(taskResultItemMapper.selectList(any())).thenReturn(pointerRows(total));
|
||||
when(transientPayloadStorageService.extractPointer(anyString())).thenReturn("pointer");
|
||||
when(transientPayloadStorageService.resolvePayload(anyString(), anyString()))
|
||||
.thenAnswer(inv -> "{\"n\":" + indexOfArgument(inv.getArgument(0)) + "}");
|
||||
when(transientPayloadStorageService.resolvePayload(org.mockito.ArgumentMatchers.eq("pointer-1"), anyString()))
|
||||
.thenThrow(new BusinessException("读取任务结果明细失败"));
|
||||
|
||||
BusinessException thrown = assertThrows(BusinessException.class,
|
||||
() -> service.listResultSnapshots(9001L, "APPEARANCE_PATENT", Map.class));
|
||||
|
||||
assertThat(thrown).hasMessage("读取任务结果明细失败");
|
||||
}
|
||||
|
||||
@Test
|
||||
void unexpectedStoreFailureIsWrappedIntoBusinessExceptionAsBefore() {
|
||||
when(taskResultItemMapper.selectList(any())).thenReturn(pointerRows(TaskResultItemService.SNAPSHOT_READ_WINDOW + 2));
|
||||
when(transientPayloadStorageService.extractPointer(anyString())).thenReturn("pointer");
|
||||
when(transientPayloadStorageService.resolvePayload(anyString(), anyString()))
|
||||
.thenThrow(new IllegalStateException("对象存储 500"));
|
||||
|
||||
BusinessException thrown = assertThrows(BusinessException.class,
|
||||
() -> service.listResultSnapshots(9001L, "APPEARANCE_PATENT", Map.class));
|
||||
|
||||
assertThat(thrown).hasMessage("读取任务结果明细失败");
|
||||
}
|
||||
|
||||
// ---------- 源码绊线:窗口这道闸本身 ----------
|
||||
|
||||
@Test
|
||||
void submissionIsWindowBoundedNotWholeResultSetAtOnce() {
|
||||
String body = methodBody(SourceScan.withoutComments(SourceScan.sourceText("TaskResultItemService.java")),
|
||||
"List<T> listResultSnapshots(Long taskId, String moduleType, Class<T> clazz)");
|
||||
|
||||
assertThat(body).as("提交循环必须由窗口常量钳制").contains("from += SNAPSHOT_READ_WINDOW");
|
||||
assertThat(body).as("每次只提交一窗的行").contains("Math.min(from + SNAPSHOT_READ_WINDOW");
|
||||
assertThat(body.indexOf("from += SNAPSHOT_READ_WINDOW"))
|
||||
.as("submit 必须落在窗口循环里面,不是回到整量 for (row : rows)")
|
||||
.isLessThan(body.indexOf("snapshotReadPool.submit("));
|
||||
assertThat(countOf(body, "snapshotReadPool.submit("))
|
||||
.as("提交点只许一处:多一处就多一份没人收割的副本").isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void windowMustStayBelowThePoolQueueSoTheCallerNeverReadsInline() {
|
||||
assertThat(TaskResultItemService.SNAPSHOT_READ_WINDOW)
|
||||
.as("窗口大于线程池队列就会撞上 CallerRunsPolicy,把调用线程变成同步读对象存储的那个人")
|
||||
.isBetween(1, ThreadPools.DEFAULT_QUEUE_CAPACITY);
|
||||
}
|
||||
|
||||
/** 从方法签名起做括号配对,取出方法体(注释已由 withoutComments 剥掉)。 */
|
||||
private static String methodBody(String source, String signature) {
|
||||
int start = source.indexOf(signature);
|
||||
assertThat(start).as("必须存在方法 " + signature).isGreaterThan(-1);
|
||||
int open = source.indexOf('{', start);
|
||||
assertThat(open).as(signature + " 的方法体起点").isGreaterThan(-1);
|
||||
int depth = 0;
|
||||
for (int i = open; i < source.length(); i++) {
|
||||
char c = source.charAt(i);
|
||||
if (c == '{') {
|
||||
depth++;
|
||||
} else if (c == '}') {
|
||||
depth--;
|
||||
if (depth == 0) {
|
||||
return source.substring(open + 1, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new AssertionError(signature + " 括号未闭合");
|
||||
}
|
||||
|
||||
private static int countOf(String haystack, String needle) {
|
||||
int count = 0;
|
||||
for (int at = haystack.indexOf(needle); at >= 0; at = haystack.indexOf(needle, at + needle.length())) {
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
package com.nanri.aiimage.modules.task.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.nanri.aiimage.modules.task.mapper.TaskResultPayloadMapper;
|
||||
import com.nanri.aiimage.modules.task.model.entity.TaskResultPayloadEntity;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.transaction.support.TransactionSynchronization;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* P1-B8:结果载荷的<b>对象存储删除</b>不得落在 DB 事务里。
|
||||
*
|
||||
* <p>原形状是 {@code @Transactional} 的 {@code deleteLatest} 里先同步删对象、再删行。两头的代价都真:
|
||||
* 一次删除超时 120s、重试 3 次,还要带一次引用计数反查——DB 连接被这段时间占住(连接池单节点 30,
|
||||
* 几次并发删除即可打满并波及其它请求);而回滚时对象已经没了、行还在=读得到一个不存在的载荷。
|
||||
* 结果明细行({@link TaskResultItemService} 的 deletePayloadsAfterCommit,2026-09)早已改成提交后删,
|
||||
* 本类钉的是当时漏掉的这一处。
|
||||
*
|
||||
* <p>反向自证:把 {@code deletePayloadIfPresent} 挪回事务内(或去掉 afterCommit 分支),第一格即红;
|
||||
* 把顺序倒回来(先删对象再删行),第三格即红。
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class TaskResultPayloadDeleteTxBoundaryTest {
|
||||
|
||||
private static final String POINTER = "rustfs:task-payload/APPEARANCE_PATENT/9001/abc.json";
|
||||
|
||||
@Mock private TaskResultPayloadMapper taskResultPayloadMapper;
|
||||
@Mock private TransientPayloadStorageService transientPayloadStorageService;
|
||||
|
||||
private TaskResultPayloadService service;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
service = new TaskResultPayloadService(taskResultPayloadMapper, new ObjectMapper(),
|
||||
transientPayloadStorageService);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void clearSynchronizationIfLeftActive() {
|
||||
if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||
TransactionSynchronizationManager.clearSynchronization();
|
||||
}
|
||||
}
|
||||
|
||||
private void stubRowWithPayload(String payloadJson) {
|
||||
TaskResultPayloadEntity existing = new TaskResultPayloadEntity();
|
||||
existing.setId(11L);
|
||||
existing.setTaskId(9001L);
|
||||
existing.setModuleType("APPEARANCE_PATENT");
|
||||
existing.setPayloadJson(payloadJson);
|
||||
when(taskResultPayloadMapper.selectOne(any(LambdaQueryWrapper.class))).thenReturn(existing);
|
||||
}
|
||||
|
||||
/** 没有活动同步器时 Spring 直接抛 IllegalState;测试里按「没注册任何同步器」读成空。 */
|
||||
private static List<TransactionSynchronization> registered() {
|
||||
return TransactionSynchronizationManager.isSynchronizationActive()
|
||||
? TransactionSynchronizationManager.getSynchronizations()
|
||||
: List.of();
|
||||
}
|
||||
|
||||
@Test
|
||||
void 有事务上下文时对象存储要等提交之后才动() {
|
||||
stubRowWithPayload(POINTER);
|
||||
TransactionSynchronizationManager.initSynchronization();
|
||||
|
||||
service.deleteLatest(9001L, "APPEARANCE_PATENT", "scope-a");
|
||||
|
||||
verify(taskResultPayloadMapper, times(1)).deleteById(11L);
|
||||
verify(transientPayloadStorageService, never()).deletePayloadIfPresent(anyString());
|
||||
|
||||
List<TransactionSynchronization> synchronizations = registered();
|
||||
assertEquals(1, synchronizations.size(), "提交后删除必须挂在事务同步器上,否则回滚也会照删");
|
||||
synchronizations.forEach(TransactionSynchronization::afterCommit);
|
||||
verify(transientPayloadStorageService, times(1)).deletePayloadIfPresent(POINTER);
|
||||
}
|
||||
|
||||
/** 没有事务上下文(被非事务调用方直接用)时**立即删**——静默不删就是留孤儿对象。 */
|
||||
@Test
|
||||
void 无事务上下文时仍然删到() {
|
||||
stubRowWithPayload(POINTER);
|
||||
|
||||
service.deleteLatest(9001L, "APPEARANCE_PATENT", "scope-a");
|
||||
|
||||
verify(taskResultPayloadMapper, times(1)).deleteById(11L);
|
||||
verify(transientPayloadStorageService, times(1)).deletePayloadIfPresent(POINTER);
|
||||
assertEquals(0, registered().size(), "不在事务里就别往线程上挂同步器(挂了也没人触发它)");
|
||||
}
|
||||
|
||||
/** 落库失败=这单还没删:对象存储一次都不许碰(否则回滚后行还在、载荷已经没了)。 */
|
||||
@Test
|
||||
void 落库失败不留半成品() {
|
||||
stubRowWithPayload(POINTER);
|
||||
when(taskResultPayloadMapper.deleteById(11L)).thenThrow(new IllegalStateException("db down"));
|
||||
|
||||
assertThrows(IllegalStateException.class,
|
||||
() -> service.deleteLatest(9001L, "APPEARANCE_PATENT", "scope-a"));
|
||||
|
||||
verify(transientPayloadStorageService, never()).deletePayloadIfPresent(anyString());
|
||||
}
|
||||
|
||||
/** 行里没有载荷值时不注册提交后删除:一次空的网络往返都不该发。 */
|
||||
@Test
|
||||
void 空载荷不注册提交后删除() {
|
||||
stubRowWithPayload(null);
|
||||
TransactionSynchronizationManager.initSynchronization();
|
||||
|
||||
service.deleteLatest(9001L, "APPEARANCE_PATENT", "scope-a");
|
||||
|
||||
verify(taskResultPayloadMapper, times(1)).deleteById(11L);
|
||||
assertEquals(0, registered().size(), "没有指针就没有要删的对象,别挂一个注定空跑的同步器");
|
||||
verify(transientPayloadStorageService, never()).deletePayloadIfPresent(anyString());
|
||||
}
|
||||
|
||||
/** 没有这一行=什么都不做(既不删库也不注册删除)。 */
|
||||
@Test
|
||||
void 行不存在时整条链路不动() {
|
||||
when(taskResultPayloadMapper.selectOne(any(LambdaQueryWrapper.class))).thenReturn(null);
|
||||
TransactionSynchronizationManager.initSynchronization();
|
||||
|
||||
service.deleteLatest(9001L, "APPEARANCE_PATENT", "scope-a");
|
||||
|
||||
verify(taskResultPayloadMapper, never()).deleteById(11L);
|
||||
assertEquals(0, registered().size());
|
||||
verify(transientPayloadStorageService, never()).deletePayloadIfPresent(anyString());
|
||||
}
|
||||
}
|
||||
+48
-5
@@ -10,11 +10,13 @@ import com.nanri.aiimage.modules.task.model.entity.FileTaskEntity;
|
||||
import com.nanri.aiimage.modules.task.spi.ClientTaskRetrySpi;
|
||||
import org.apache.ibatis.builder.MapperBuilderAssistant;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
@@ -23,6 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -143,10 +146,18 @@ class TaskResumeServiceTest {
|
||||
@Test
|
||||
void 已有重试任务时跳过避免重复克隆() {
|
||||
FileTaskMapper mapper = mock(FileTaskMapper.class);
|
||||
when(mapper.selectList(any())).thenReturn(List.of(
|
||||
failedTask(28587L, "SIMILAR_ASIN", "任务心跳超时,已自动失败")));
|
||||
// 第一次是"不支持重试的中断任务数",第二次是"是否已有重试子任务"
|
||||
when(mapper.selectCount(any())).thenReturn(0L, 1L);
|
||||
FileTaskEntity origin = failedTask(28587L, "SIMILAR_ASIN", "任务心跳超时,已自动失败");
|
||||
FileTaskEntity child = new FileTaskEntity();
|
||||
child.setId(28600L);
|
||||
child.setResumeOfTaskId(28587L);
|
||||
// P1-B5 之后「是否已有重试子任务」不再是每行一次 selectCount,而是循环前一次批量 selectList。
|
||||
// 候选查询与反查都落在同一个 selectList 上,按投影列区分:反查那一支只取 resume_of_task_id。
|
||||
when(mapper.selectList(any())).thenAnswer(invocation -> {
|
||||
com.baomidou.mybatisplus.core.conditions.AbstractWrapper<?, ?, ?> wrapper = invocation.getArgument(0);
|
||||
String projection = String.valueOf(wrapper.getSqlSelect());
|
||||
return projection.contains("resume_of_task_id") ? List.of(child) : List.of(origin);
|
||||
});
|
||||
when(mapper.selectCount(any())).thenReturn(0L);
|
||||
ClientTaskRetrySpi spi = mock(ClientTaskRetrySpi.class);
|
||||
when(spi.moduleType()).thenReturn("SIMILAR_ASIN");
|
||||
TaskResumeService service = service(mapper, List.of(spi), true, 3);
|
||||
@@ -157,6 +168,37 @@ class TaskResumeServiceTest {
|
||||
assertEquals(0, stats.resumedTaskCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* P1-B6 同族:反查子任务与「补检中」两条判定都必须**批量**取(循环前一次),不许退回逐行点查——
|
||||
* 逐行形状在 500 个候选时是 1,000 次往返,且 {@code resume_of_task_id} 那列在 V187 之前无索引。
|
||||
* 判据=selectList 只发生「清账 + 候选 + 反查」三次、selectCount 只发生一次(不支持重试的计数),
|
||||
* 且批量档拿到的是这一轮的全部候选 id。
|
||||
*/
|
||||
@Test
|
||||
void 两条前置判定按批量档取不逐行点查() {
|
||||
FileTaskMapper mapper = mock(FileTaskMapper.class);
|
||||
when(mapper.selectList(any())).thenReturn(List.of(
|
||||
failedTask(28587L, "SIMILAR_ASIN", "任务心跳超时,已自动失败"),
|
||||
failedTask(28588L, "SIMILAR_ASIN", "任务心跳超时,已自动失败")));
|
||||
when(mapper.selectCount(any())).thenReturn(0L);
|
||||
TaskFileJobService jobs = mock(TaskFileJobService.class);
|
||||
ClientTaskRetrySpi spi = mock(ClientTaskRetrySpi.class);
|
||||
when(spi.moduleType()).thenReturn("SIMILAR_ASIN");
|
||||
TaskResumeService service = service(mapper, jobs, List.of(spi), true, 3);
|
||||
|
||||
TaskResumeService.ResumeStats stats = service.resumeInterruptedTasks();
|
||||
|
||||
assertEquals(2, stats.resumedTaskCount);
|
||||
@SuppressWarnings("unchecked")
|
||||
ArgumentCaptor<Collection<Long>> captor =
|
||||
(ArgumentCaptor<Collection<Long>>) (ArgumentCaptor<?>) ArgumentCaptor.forClass(Collection.class);
|
||||
verify(jobs).taskIdsWithUnfinishedAssembleJob(captor.capture());
|
||||
assertTrue(captor.getValue().containsAll(List.of(28587L, 28588L)),
|
||||
"批量档必须一次带走本轮全部候选,漏一个就是退回逐行点查");
|
||||
verify(mapper, times(3)).selectList(any());
|
||||
verify(mapper, times(1)).selectCount(any());
|
||||
}
|
||||
|
||||
/**
|
||||
* 现网 2026-10-24:一枚 760 行的外观专利任务因交付缺口把组装作业排回补检(作业还在
|
||||
* PENDING/RUNNING),任务行却已是 FAILED,于是被巡检连克隆成 4 枚、每枚全量重跑一遍,
|
||||
@@ -170,7 +212,8 @@ class TaskResumeServiceTest {
|
||||
failedTask(32201L, "APPEARANCE_PATENT", "有 3 行抓取失败(未取得商品页数据):B07P5TR7Q5")));
|
||||
when(mapper.selectCount(any())).thenReturn(0L);
|
||||
TaskFileJobService jobs = mock(TaskFileJobService.class);
|
||||
when(jobs.hasUnfinishedAssembleJob(32201L)).thenReturn(true);
|
||||
// P1-B5:补检判定从逐行 hasUnfinishedAssembleJob 折成循环前一次批量档。
|
||||
when(jobs.taskIdsWithUnfinishedAssembleJob(any())).thenReturn(java.util.Set.of(32201L));
|
||||
ClientTaskRetrySpi spi = mock(ClientTaskRetrySpi.class);
|
||||
when(spi.moduleType()).thenReturn("APPEARANCE_PATENT");
|
||||
TaskResumeService service = service(mapper, jobs, List.of(spi), true, 3);
|
||||
|
||||
Reference in New Issue
Block a user