Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
themeEmacs
[Theory(DisplayName = "테스트 n초당 1회 호출제약")]
[InlineData(5, 1, false)]
public void ThrottleLimitTest(int givenTestCount, int givenLimitSeconds, bool isPerformTest)
{
.......
  // Create ThrottleLimit Actor
  throttleLimitActor = actorSystem.ActorOf(Props.Create(() => new ThrottleLimitActor(1, givenLimitSeconds, 1000)));
  throttleLimitActor.Tell(new SetTarget(probe))
  
  for (int i = 0; i < givenTestCount; i++)
  {
      throttleLimitActor.Tell(new EventCmd()
      {
          Message = "test",
      });
  }
  
  //Then : Safe processing within N seconds limit
  for (int i = 0; i < givenTestCount; i++)
  {
      probe.ExpectMsg<EventCmd>(message =>
      {
          Assert.Equal("test", message.Message);                        
      });
  
      output.WriteLine($"[{DateTime.Now}] - GTPRequestCmd");
  
      if (isPerformTest)
      {
          _dictionary.Add(_key++, _key);
          _addCounter.Increment();
      }
  }
...........
}  

도메인 검증은 기본유닛테스트는 발생메시지가 모두 소비되었나를 검증하며 , 소비가 되었는가만을 검증합니다.


TPS 1을 유지하였는가 성능검증은 다음과같이 작성합니다? 는 다음과 같이 분리하여 측정될수 있습니다.

Code Block
themeEmacs
        [NBenchFact]
        [PerfBenchmark(NumberOfIterations = 3, RunMode = RunMode.Throughput,
        RunTimeMilliseconds = 1000, TestMode = TestMode.Test)]
        [CounterThroughputAssertion("TestCounter", MustBe.LessThanOrEqualTo, 1.0d)]
        [CounterTotalAssertion("TestCounter", MustBe.LessThanOrEqualTo, 1)]
        [CounterMeasurement("TestCounter")]
        public void ThrottleLimitPerformanceTest()
        {
            ThrottleLimitTest(1, 1, true);
        }


통과옵션을을  1보다 작다로 설정을 하여 TPS1이하인지 TPS1이하를 검증을 할수가 있습니다.

  • [CounterThroughputAssertion("TestCounter", MustBe.LessThanOrEqualTo, 1.0d)]
  • [CounterTotalAssertion("TestCounter", MustBe.LessThanOrEqualTo, 1)]

...

Code Block
themeEmacs
    [PASS] Expected [Counter] TestCounter to must be less than or equal to 1.00 operations; actual value was 0.98 operations.
    
    [PASS] Expected [Counter] TestCounter to must be less than or equal to 1.00 operations; actual value was 1.00 operations.
    
    
    ---------- Measurements ----------
    
    Metric : [Counter] TestCounter
    
    Per Second ( operations )
    Average         : 0.9802234345891607
    Max             : 0.9823810933292493
    Min             : 0.9787775577268321
    Std. Deviation  : 0.0019042957466220024
    Std. Error      : 0.0010994456619288725
    
    Per Test ( operations )
    Average         : 1
    Max             : 1
    Min             : 1
    Std. Deviation  : 0
    Std. Error      : 0
    


검증 옵션을 GreaterThanOrEqualTo 반대로 설정을 하면 실패가 발생하며 아래와같이 검증 실패가 발생하게됩니다.옵션과 측정수가 일치하지 않으면 다음과같이 유닛테스트가 실패하게 됩니다.

(실패를 유발하기위해 GreaterThanOrEqualTo 으로 설정한 케이스)

Code Block
    [FAIL] Expected [Counter] TestCounter to must be greater than or equal to 1.00 operations; actual value was 0.98 operations.
    Expected: True
    Actual:   False

...