chore: 更新Docker和CI配置

- 更新Woodpecker CI配置
- 更新Docker Compose配置
- 更新应用主类配置
- 更新网关路由服务
- 更新审计日志相关代码
This commit is contained in:
张翔
2026-04-15 23:38:03 +08:00
parent 38dc055a27
commit 60fb84e306
11 changed files with 398 additions and 204 deletions
@@ -74,11 +74,9 @@ public class DynamicRouteService implements IDynamicRouteService {
logger.info("Adding route: {}", routeId);
return routeDefinitionWriter.save(Mono.just(routeDefinition))
.then(Mono.fromRunnable(() -> {
routeCache.put(routeId, routeDefinition);
refreshRoutes();
logger.info("Route added successfully: {}", routeId);
}))
.then(Mono.fromRunnable(() -> routeCache.put(routeId, routeDefinition)))
.then(refreshRoutes())
.then(Mono.fromRunnable(() -> logger.info("Route added successfully: {}", routeId)))
.thenReturn(true)
.onErrorResume(error -> {
logger.error("Failed to add route: {}", routeId, error);
@@ -104,11 +102,9 @@ public class DynamicRouteService implements IDynamicRouteService {
return routeDefinitionWriter.delete(Mono.just(routeId))
.then(routeDefinitionWriter.save(Mono.just(routeDefinition)))
.then(Mono.fromRunnable(() -> {
routeCache.put(routeId, routeDefinition);
refreshRoutes();
logger.info("Route updated successfully: {}", routeId);
}))
.then(Mono.fromRunnable(() -> routeCache.put(routeId, routeDefinition)))
.then(refreshRoutes())
.then(Mono.fromRunnable(() -> logger.info("Route updated successfully: {}", routeId)))
.thenReturn(true)
.onErrorResume(error -> {
logger.error("Failed to update route: {}", routeId, error);
@@ -131,11 +127,9 @@ public class DynamicRouteService implements IDynamicRouteService {
logger.info("Deleting route: {}", routeId);
return routeDefinitionWriter.delete(Mono.just(routeId))
.then(Mono.fromRunnable(() -> {
routeCache.remove(routeId);
refreshRoutes();
logger.info("Route deleted successfully: {}", routeId);
}))
.then(Mono.fromRunnable(() -> routeCache.remove(routeId)))
.then(refreshRoutes())
.then(Mono.fromRunnable(() -> logger.info("Route deleted successfully: {}", routeId)))
.thenReturn(true)
.onErrorResume(error -> {
logger.error("Failed to delete route: {}", routeId, error);
@@ -1,5 +1,6 @@
package cn.novalon.manage.gateway.route;
import cn.novalon.manage.gateway.service.impl.DynamicRouteService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -25,7 +26,7 @@ import static org.mockito.Mockito.*;
* 涉及业务:路由增删改查、路由刷新
*
* @author 张翔
* @date 2026-03-26
* @date 2026-04-14
*/
@ExtendWith(MockitoExtension.class)
class DynamicRouteServiceTest {
@@ -78,7 +79,15 @@ class DynamicRouteServiceTest {
@Test
void testDeleteRoute_Success() {
String routeId = "test-route";
RouteDefinition routeDefinition = createRouteDefinition(routeId);
// 先添加路由到缓存中
when(routeDefinitionWriter.save(any())).thenReturn(Mono.empty());
StepVerifier.create(dynamicRouteService.addRoute(routeDefinition))
.expectNext(true)
.verifyComplete();
// 然后删除路由
when(routeDefinitionWriter.delete(any())).thenReturn(Mono.empty());
StepVerifier.create(dynamicRouteService.deleteRoute(routeId))
@@ -86,7 +95,7 @@ class DynamicRouteServiceTest {
.verifyComplete();
verify(routeDefinitionWriter).delete(any());
verify(publisher).publishEvent(any(RefreshRoutesEvent.class));
verify(publisher, times(2)).publishEvent(any(RefreshRoutesEvent.class));
}
@Test
@@ -113,7 +122,7 @@ class DynamicRouteServiceTest {
.expectNext(true)
.verifyComplete();
StepVerifier.create(dynamicRouteService.getAllRoutes().collectList())
StepVerifier.create(dynamicRouteService.getRoutes().collectList())
.assertNext(routes -> {
assertNotNull(routes);
assertTrue(routes.size() >= 2);
@@ -131,7 +140,9 @@ class DynamicRouteServiceTest {
.expectNext(true)
.verifyComplete();
assertTrue(dynamicRouteService.getRouteCount() >= 1);
StepVerifier.create(dynamicRouteService.getRouteCount())
.assertNext(count -> assertTrue(count >= 1))
.verifyComplete();
}
private RouteDefinition createRouteDefinition(String id) {