-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix issue with multiple aggregated counter for monitoring
- Loading branch information
Showing
4 changed files
with
40 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/Hangfire.MemoryStorage.UnitTest/MemoryStorageMonitoringApiTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
using Hangfire.MemoryStorage.Database; | ||
using Hangfire.MemoryStorage.Dto; | ||
using Hangfire.MemoryStorage; | ||
|
||
namespace Hangfire.MemoryStorage.UnitTest; | ||
|
||
public class MemoryStorageMonitoringApiTests | ||
{ | ||
private Data data; | ||
private MemoryStorageMonitoringApi monitoringApi; | ||
|
||
public MemoryStorageMonitoringApiTests() | ||
{ | ||
data = new Data(); | ||
monitoringApi = new MemoryStorageMonitoringApi(data); | ||
} | ||
|
||
[Fact] | ||
public void MonitoringShouldReturnSumOfCounterIfTwoAggregatedCounterDtoHaveSameKey() | ||
{ | ||
var key = string.Format("stats:succeeded:{0}", DateTime.UtcNow.AddHours(-2).ToString("yyyy-MM-dd-HH")); | ||
data.Create(new AggregatedCounterDto { Id = 1, Key = key, Value = 5 }); | ||
data.Create(new AggregatedCounterDto { Id = 2, Key = key, Value = 2 }); // Creation in CountersAggregator can produce two object in concurrent environment | ||
|
||
var stats = monitoringApi.HourlySucceededJobs().ToArray(); | ||
Assert.Equal(7, stats[2].Value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters