diff --git a/ClientTester/EchoClientTester/EchoDummyService/DummyClientService.cs b/ClientTester/EchoClientTester/EchoDummyService/DummyClientService.cs index f35d8c1..d2c3377 100644 --- a/ClientTester/EchoClientTester/EchoDummyService/DummyClientService.cs +++ b/ClientTester/EchoClientTester/EchoDummyService/DummyClientService.cs @@ -8,6 +8,19 @@ public class DummyClientService private readonly List clients; private readonly int sendInterval; + // 유닛 테스트용 (n패킷 시간체크) + public bool IsTest + { + get; + set; + } = false; + + public int TestCount + { + get; + set; + } = 100000; + // 모든거 강종 public event Action? OnAllDisconnected; @@ -21,6 +34,16 @@ public class DummyClientService public async Task RunAsync(CancellationToken ct) { + if (IsTest) + { + foreach (DummyClients c in clients) + { + c.TestCount = TestCount; + } + + Log.Information("[TEST] 유닛 테스트 모드: 클라이언트당 {Count}개 수신 시 자동 종료", TestCount); + } + await Task.WhenAll( PollLoopAsync(ct), SendLoopAsync(ct) @@ -103,6 +126,7 @@ public class DummyClientService { int totalSent = 0, totalRecv = 0; int connected = 0; + int rttClientCount = 0; Log.Information("───────────── Performance Report ─────────────"); @@ -120,14 +144,18 @@ public class DummyClientService totalSent += c.SentCount; totalRecv += c.ReceivedCount; - totalAvgRtt += c.AvgRttMs; + if (c.RttCount > 0) + { + totalAvgRtt += c.AvgRttMs; + rttClientCount++; + } if (c.peer != null) { connected++; } } - double avgRtt = connected > 0 ? totalAvgRtt / connected : 0; + double avgRtt = rttClientCount > 0 ? totalAvgRtt / rttClientCount : 0; Log.Information("────────────────────────────────────────────"); Log.Information( diff --git a/ClientTester/EchoClientTester/EchoDummyService/DummyClients.cs b/ClientTester/EchoClientTester/EchoDummyService/DummyClients.cs index 40ee3cc..9ff2203 100644 --- a/ClientTester/EchoClientTester/EchoDummyService/DummyClients.cs +++ b/ClientTester/EchoClientTester/EchoDummyService/DummyClients.cs @@ -19,6 +19,13 @@ public class DummyClients private ConcurrentDictionary pendingPings = new(); private int seqNumber; + // 유닛 테스트용 (0 = 제한 없음) + public int TestCount + { + get; + set; + } = 0; + // 통계 public int SentCount { @@ -81,6 +88,12 @@ public class DummyClients } ReceivedCount++; + + if (TestCount > 0 && ReceivedCount >= TestCount) + { + peer.Disconnect(); + } + reader.Recycle(); }; diff --git a/ClientTester/EchoClientTester/Program.cs b/ClientTester/EchoClientTester/Program.cs index e096a27..3e3f8e2 100644 --- a/ClientTester/EchoClientTester/Program.cs +++ b/ClientTester/EchoClientTester/Program.cs @@ -35,6 +35,8 @@ class EcoClientTester await cts.CancelAsync(); }; + // service.IsTest = true; + // service.TestCount = 100; await service.RunAsync(cts.Token); service.PrintStats();