diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1ae8818d..ba7a77f2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,7 @@ # Running tests Unless you are testing older .NET runtimes on Windows, you should run the tests against the newer runtimes as follows: + - https://dotnet.microsoft.com/en-us/download/dotnet/6.0 ``` make test-net6 diff --git a/examples/MomentoLoadGen/Program.cs b/examples/MomentoLoadGen/Program.cs index c0254be6..0b443dce 100644 --- a/examples/MomentoLoadGen/Program.cs +++ b/examples/MomentoLoadGen/Program.cs @@ -1,9 +1,4 @@ -using System; -using System.Diagnostics; -using System.Diagnostics.Metrics; -using System.Security.Cryptography; -using System.Text; -using Grpc.Core; +using System.Diagnostics; using HdrHistogram; using Microsoft.Extensions.Logging; using Momento.Sdk; @@ -30,7 +25,9 @@ enum AsyncSetGetResult UNAVAILABLE, TIMEOUT, LIMIT_EXCEEDED, - RST_STREAM + RST_STREAM, + UNKNOWN, + CANCELLED }; internal class CsharpLoadGeneratorContext @@ -45,6 +42,8 @@ internal class CsharpLoadGeneratorContext public int GlobalUnavailableCount; public int GlobalTimeoutExceededCount; public int GlobalLimitExceededCount; + public int GlobalUnknownCount; + public int GlobalCancelledCount; public int GlobalRstStreamCount; public CsharpLoadGeneratorContext() @@ -58,6 +57,8 @@ public CsharpLoadGeneratorContext() GlobalSuccessCount = 0; GlobalTimeoutExceededCount = 0; GlobalLimitExceededCount = 0; + GlobalUnknownCount = 0; + GlobalCancelledCount = 0; GlobalRstStreamCount = 0; GlobalUnavailableCount = 0; } @@ -67,8 +68,7 @@ public CsharpLoadGeneratorContext() public class CsharpLoadGenerator { const int CACHE_ITEM_TTL_SECONDS = 60; - const string CACHE_NAME = "momento-loadgen"; - const int NUM_REQUESTS_PER_OPERATION = 2; + const string CACHE_NAME = "dotnet-momento-loadgen"; private readonly ILoggerFactory _loggerFactory; private readonly ILogger _logger; @@ -189,6 +189,8 @@ private void PrintStats(LongHistogram setsAccumulatingHistogram, LongHistogram g unavailable: {context.GlobalUnavailableCount} ({PercentRequests(context, context.GlobalUnavailableCount)}%) timeout exceeded: {context.GlobalTimeoutExceededCount} ({PercentRequests(context, context.GlobalTimeoutExceededCount)}%) limit exceeded: {context.GlobalLimitExceededCount} ({PercentRequests(context, context.GlobalLimitExceededCount)}%) + cancelled: {context.GlobalCancelledCount} ({PercentRequests(context, context.GlobalCancelledCount)}%) + unknown: {context.GlobalUnknownCount} ({PercentRequests(context, context.GlobalUnknownCount)}%) rst stream: {context.GlobalRstStreamCount} ({PercentRequests(context, context.GlobalRstStreamCount)}%) cumulative set latencies: @@ -306,9 +308,16 @@ private AsyncSetGetResult ConvertErrorToAsyncSetGetResult(MomentoErrorCode error { return AsyncSetGetResult.LIMIT_EXCEEDED; } + else if (errorCode is MomentoErrorCode.UNKNOWN_ERROR or MomentoErrorCode.UNKNOWN_SERVICE_ERROR) + { + return AsyncSetGetResult.UNKNOWN; + } + else if (errorCode == MomentoErrorCode.CANCELLED_ERROR) + { + return AsyncSetGetResult.CANCELLED; + } _logger.LogError("UNCAUGHT EXCEPTION: {}", ex); throw new ApplicationException($"Unsupported error code: {errorCode}"); - } private static void UpdateContextCountsForRequest( @@ -324,6 +333,8 @@ AsyncSetGetResult result AsyncSetGetResult.TIMEOUT => Interlocked.Increment(ref context.GlobalTimeoutExceededCount), AsyncSetGetResult.LIMIT_EXCEEDED => Interlocked.Increment(ref context.GlobalLimitExceededCount), AsyncSetGetResult.RST_STREAM => Interlocked.Increment(ref context.GlobalRstStreamCount), + AsyncSetGetResult.UNKNOWN => Interlocked.Increment(ref context.GlobalUnknownCount), + AsyncSetGetResult.CANCELLED => Interlocked.Increment(ref context.GlobalCancelledCount), _ => throw new Exception($"Unrecognized result: {result}"), }; return; diff --git a/examples/MomentoLoadGen/README.md b/examples/MomentoLoadGen/README.md index f7268aa8..8deddd60 100644 --- a/examples/MomentoLoadGen/README.md +++ b/examples/MomentoLoadGen/README.md @@ -40,3 +40,11 @@ Within the `MomentoLoadGen` directory you can run: # Run example load generator MOMENTO_AUTH_TOKEN= dotnet run ``` + +If you make modifications to the code, remember to do a clean otherwise +the program might not run. + +```bash +dotnet clean +MOMENTO_AUTH_TOKEN= dotnet run +```