ci: rid test sync

This commit is contained in:
CaptainB 2023-11-03 13:52:03 +08:00 committed by 刘瑞斌
parent ba9378fa29
commit b53cbda642
1 changed files with 8 additions and 4 deletions

View File

@ -31,9 +31,11 @@ public class RIdGeneratorTests {
executorService.submit(() -> { executorService.submit(() -> {
long nextId = NumGenerator.nextNum(projectId, ApplicationNumScope.API_DEFINITION); long nextId = NumGenerator.nextNum(projectId, ApplicationNumScope.API_DEFINITION);
System.out.println(nextId); System.out.println(nextId);
synchronized (projectId) {
if (atomicLong.get() < nextId) { if (atomicLong.get() < nextId) {
atomicLong.set(nextId); atomicLong.set(nextId);
} }
}
}); });
} }
executorService.close(); executorService.close();
@ -58,9 +60,11 @@ public class RIdGeneratorTests {
// 接口用例的前缀为: PROJECT_ID_API_DEFINITION 比较特殊 // 接口用例的前缀为: PROJECT_ID_API_DEFINITION 比较特殊
long nextId = NumGenerator.nextNum(projectId + "_" + apiNum, ApplicationNumScope.API_TEST_CASE); long nextId = NumGenerator.nextNum(projectId + "_" + apiNum, ApplicationNumScope.API_TEST_CASE);
System.out.println(nextId); System.out.println(nextId);
synchronized (projectId) {
if (atomicLong.get() < nextId) { if (atomicLong.get() < nextId) {
atomicLong.set(nextId); atomicLong.set(nextId);
} }
}
}); });
} }
executorService.close(); executorService.close();