test(infra): DbDiagnose 用例库不可达自守卫——真探测一次+进程级缓存结论
原守卫 try 挂在 GetYLDbContext() 上永远打不中(EF context 构造不连库, Connect Timeout 发生在首个查询),无库裸跑 14 个用例逐个假红且各耗 15s。 改为 DbDiagnoseGuard.RequireTestDb():CanConnect 真探测一次并缓存, 不可达全批 Inconclusive——裸跑不再有假失败噪音,探测成本 14×15s→1×15s。 连上库的机器行为不变(照常真跑)。
This commit is contained in:
@@ -28,6 +28,7 @@ namespace YLErp.Modules.SwapModule
|
||||
[TestCategory("DbDiagnose")]
|
||||
public void Record_RealSnapshot()
|
||||
{
|
||||
DbDiagnoseGuard.RequireTestDb();
|
||||
YLContext db;
|
||||
try { db = DbContextFactory.GetYLDbContext(); }
|
||||
catch (Exception ex) { Assert.Inconclusive($"无法连接测试库:{ex.Message}"); return; }
|
||||
@@ -113,6 +114,7 @@ namespace YLErp.Modules.SwapModule
|
||||
|
||||
private void DiagnoseTrade(string tradeNumber)
|
||||
{
|
||||
DbDiagnoseGuard.RequireTestDb();
|
||||
YLContext db;
|
||||
try { db = DbContextFactory.GetYLDbContext(); }
|
||||
catch (Exception ex) { Assert.Inconclusive($"无法连接测试库:{ex.Message}"); return; }
|
||||
@@ -266,6 +268,7 @@ namespace YLErp.Modules.SwapModule
|
||||
public void Diagnose_0006_UnwindPercentRate_Display()
|
||||
{
|
||||
const string tradeNumber = "GLMS-20260701-0006";
|
||||
DbDiagnoseGuard.RequireTestDb();
|
||||
YLContext db;
|
||||
try { db = DbContextFactory.GetYLDbContext(); }
|
||||
catch (Exception ex) { Assert.Inconclusive($"无法连接测试库:{ex.Message}"); return; }
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace YLErp.Modules.SwapModule
|
||||
[TestCategory("DbDiagnose")]
|
||||
public void Record_RealSnapshot()
|
||||
{
|
||||
DbDiagnoseGuard.RequireTestDb();
|
||||
YLContext db;
|
||||
try { db = DbContextFactory.GetYLDbContext(); }
|
||||
catch (Exception ex) { Assert.Inconclusive($"无法连接测试库:{ex.Message}"); return; }
|
||||
@@ -193,6 +194,7 @@ namespace YLErp.Modules.SwapModule
|
||||
[TestCategory("DbDiagnose")]
|
||||
public void Diagnose_100vs40_InterestDiff()
|
||||
{
|
||||
DbDiagnoseGuard.RequireTestDb();
|
||||
YLContext db;
|
||||
try { db = DbContextFactory.GetYLDbContext(); }
|
||||
catch (Exception ex) { Assert.Inconclusive($"无法连接测试库:{ex.Message}"); return; }
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace UnitTestProject.Modules.SwapModule.Margin
|
||||
[TestCategory("DbDiagnose")]
|
||||
public void 保证金腿_真实库_EOD逐日新旧比对()
|
||||
{
|
||||
DbDiagnoseGuard.RequireTestDb();
|
||||
YLContext db;
|
||||
try { db = DbContextFactory.GetYLDbContext(); }
|
||||
catch (Exception ex) { Assert.Inconclusive($"无法连接测试库(192.168.2.96):{ex.Message}"); return; }
|
||||
|
||||
Reference in New Issue
Block a user