private async Task <bool> CheckCounters(IStreamerOutGrain producer, IStreamerInGrain consumer, int consumerCount, bool assertIsTrue) { var numProduced = await producer.GetNumberProduced(); var numConsumed = await consumer.GetNumberConsumed(); if (assertIsTrue) { Assert.True(numConsumed.Values.All(v => v.Item2 == 0), "Errors"); Assert.True(numProduced > 0, "Events were not produced"); Assert.Equal(consumerCount, numConsumed.Count);//, "Incorrect number of consumers"); foreach (int consumed in numConsumed.Values.Select(v => v.Item1)) { Assert.Equal(numProduced, consumed);//, "Produced and consumed counts do not match"); } } else if (numProduced <= 0 || // no events produced? consumerCount != numConsumed.Count || // subscription counts are wrong? numConsumed.Values.Any(consumedCount => consumedCount.Item1 != numProduced) || // consumed events don't match produced events for any subscription? numConsumed.Values.Any(v => v.Item2 != 0)) // stream errors { if (numProduced <= 0) { logger.Info("numProduced <= 0: Events were not produced"); } if (consumerCount != numConsumed.Count) { logger.Info("consumerCount != numConsumed.Count: Incorrect number of consumers. consumerCount = {0}, numConsumed.Count = {1}", consumerCount, numConsumed.Count); } foreach (var consumed in numConsumed) { if (numProduced != consumed.Value.Item1) { logger.Info("numProduced != consumed: Produced and consumed counts do not match. numProduced = {0}, consumed = {1}", numProduced, consumed.Key.HandleId + " -> " + consumed.Value); //numProduced, Utils.DictionaryToString(numConsumed)); } } return(false); } logger.Info("All counts are equal. numProduced = {0}, numConsumed = {1}", numProduced, Utils.EnumerableToString(numConsumed, kvp => kvp.Key.HandleId.ToString() + "->" + kvp.Value.ToString())); return(true); }
private async Task<bool> CheckCounters(IStreamerOutGrain producer, IStreamerInGrain consumer, int consumerCount, bool assertIsTrue) { var numProduced = await producer.GetNumberProduced(); var numConsumed = await consumer.GetNumberConsumed(); if (assertIsTrue) { Assert.True(numConsumed.Values.All(v => v.Item2 == 0), "Errors"); Assert.True(numProduced > 0, "Events were not produced"); Assert.Equal(consumerCount, numConsumed.Count);//, "Incorrect number of consumers"); foreach (int consumed in numConsumed.Values.Select(v => v.Item1)) { Assert.Equal(numProduced, consumed);//, "Produced and consumed counts do not match"); } } else if (numProduced <= 0 || // no events produced? consumerCount != numConsumed.Count || // subscription counts are wrong? numConsumed.Values.Any(consumedCount => consumedCount.Item1 != numProduced) ||// consumed events don't match produced events for any subscription? numConsumed.Values.Any(v => v.Item2 != 0)) // stream errors { if (numProduced <= 0) { logger.Info("numProduced <= 0: Events were not produced"); } if (consumerCount != numConsumed.Count) { logger.Info("consumerCount != numConsumed.Count: Incorrect number of consumers. consumerCount = {0}, numConsumed.Count = {1}", consumerCount, numConsumed.Count); } foreach (var consumed in numConsumed) { if (numProduced != consumed.Value.Item1) { logger.Info("numProduced != consumed: Produced and consumed counts do not match. numProduced = {0}, consumed = {1}", numProduced, consumed.Key.HandleId + " -> " + consumed.Value); //numProduced, Utils.DictionaryToString(numConsumed)); } } return false; } logger.Info("All counts are equal. numProduced = {0}, numConsumed = {1}", numProduced, Utils.EnumerableToString(numConsumed, kvp => kvp.Key.HandleId.ToString() + "->" + kvp.Value.ToString())); return true; }