Commit Graph

13 Commits

Author SHA1 Message Date
movingsam
1b13efffc5 fix: add null check in RouteCache.GetRoute to prevent ArgumentNullException
- Allow nullable tenantCode and serviceName parameters
- Return null early if serviceName is null or empty
- Fix test: GetRoute_WithNullServiceName_ShouldReturnNull
2026-03-08 11:01:49 +08:00
movingsam
faba26043f IMPL-12: 完善端到端集成测试基础设施和修复递归问题
- 更新 TestFixture 添加 Mock Redis 和内存数据库配置
- 修复 DynamicProxyConfigProvider 中的递归问题
- 添加 GwPendingServiceDiscovery 实体模型
- 修复测试数据模型与实际代码的匹配问题

37/44 集成测试通过,失败测试主要由于测试间状态共享
2026-03-08 10:57:40 +08:00
movingsam
9b77169b80 test: add end-to-end integration tests (IMPL-12)
- TestFixture: Base test infrastructure with WebApplicationFactory
- K8sDiscoveryTests: K8s Service Label discovery flow tests
- ConfigConfirmationTests: Pending config confirmation flow tests
- MultiTenantRoutingTests: Tenant-specific vs default destination routing tests
- ConfigReloadTests: Gateway hot-reload via NOTIFY mechanism tests
- TestData: Mock data for K8s services, JWT tokens, database seeding

Tests cover:
1. K8s Service discovery with valid labels
2. Config confirmation -> DB write -> NOTIFY
3. Multi-tenant routing (dedicated vs default destination)
4. Gateway config hot-reload without restart
2026-03-08 10:53:19 +08:00
movingsam
4fd931d44b IMPL-11: 更新 TenantRoutingMiddleware 适配新 Transform
职责分离:
- Middleware: 负责 JWT 验证、TenantId 验证、设置 ClusterId 和 TenantId 到 HttpContext.Items
- Transform: 负责从数据库查询 Destination 并设置 ProxyRequest.RequestUri

修改内容:
1. TenantRoutingMiddleware:
   - 添加设置 TenantId 到 HttpContext.Items 供 Transform 使用
   - 修复服务名提取正则表达式,支持连字符(-)和下划线(_)
   - 更新 XML 文档,明确职责分离说明

2. TenantRoutingTransform:
   - 添加 ExtractTenantId 方法,优先从 HttpContext.Items 获取 TenantId
   - 保留从 JWT 提取作为回退机制

3. 单元测试:
   - 新增职责分离验证测试 (ShouldNotSetDestinationUri, ShouldOnlySetClusterIdAndTenantId)
   - 新增与 Transform 协作测试 (ShouldSetItemsForTransformConsumption)
   - 更新服务名提取测试,支持更多字符类型
   - 总测试数: 24个,全部通过
2026-03-08 01:20:20 +08:00
movingsam
c7cf1d3738 feat: add TenantRoutingTransform for multi-tenant routing (IMPL-10)
- Implement YARP RequestTransform to route requests based on tenant
- Extract tenant ID from JWT token (supports multiple claim types)
- Query tenant-specific destination first, fallback to default
- Add IMemoryCache for performance optimization (5min expiration)
- Update Platform packages to 1.0.14 to use GwDestination.TenantCode
2026-03-08 01:01:22 +08:00
movingsam
52eba07097 feat: add MigrationTool for gateway config migration (IMPL-7)
- Create MigrationTool console app for exporting DB config to K8s YAML
- Support dry-run mode and validation
- Add Npgsql and YamlDotNet dependencies
2026-03-08 00:35:04 +08:00
movingsam
449fe3a385 refactor: 移除 GatewayConfigController - 网关只需转发请求 2026-03-04 13:35:49 +08:00
movingsam
0c08620565 refactor: 升级 Fengling.Platform.Infrastructure 到 1.0.12 并迁移到新模型
- 升级 Fengling.Platform.Infrastructure 包到 1.0.12
- DatabaseRouteConfigProvider: 使用 GwTenantRoutes 和 GwRouteMatch
- DatabaseClusterConfigProvider: 使用 GwClusters 和内嵌 Destinations
- GatewayDbContext: 添加兼容性别名 (TenantRoutes, ServiceInstances)
- RouteCache: 更新使用新的模型结构
- 暂时禁用 GatewayConfigController 和测试 (需要重写以适配新模型)
2026-03-04 13:30:35 +08:00
movingsam
28941fc0ef chore: 升级 Fengling.Platform.Infrastructure 到 1.0.12 2026-03-04 13:17:22 +08:00
movingsam
42b8c9cca5 fix: 升级 Fengling.Platform 包并修复编译警告
- 修复 CS0108: GatewayDbContext.Tenants 隐藏继承成员
- 修复 NU1506: 移除重复 PackageVersion 定义
- 修复 NU1507: 添加包源映射配置 (NuGet.Config)
2026-03-04 13:14:26 +08:00
movingsam
3994a95177 feat: remove K8s health check from gateway (Phase 2)
- Delete KubernetesPendingSyncService.cs
- Delete PendingServicesController.cs
- Delete GwPendingServiceDiscovery.cs model
- Update GatewayDbContext.cs - remove DbSet
- Update Program.cs - remove service registration and using statements
- Update roadmap and requirements documentation
2026-03-02 18:42:54 +08:00
movingsam
8f7e8d3a71 docs: update all planning docs to Chinese 2026-03-02 18:15:23 +08:00
movingsam
da4f03502a refactor: reorganize project structure into yarpgateway folder
- Move YarpGateway and all source files to src/yarpgateway/
- Keep Fengling.Gateway.Plugin.Abstractions at src/ level
- Fix duplicate project reference in YarpGateway.slnx
- Update solution paths and test project references
- Add ProjectReference from YarpGateway to abstractions
2026-03-01 17:47:48 +08:00