-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
60 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using NSubstitute; | ||
using Xunit; | ||
|
||
namespace Prometheus.Client.MetricPusher.Tests; | ||
|
||
public class MetricPushServerTests | ||
{ | ||
[Fact] | ||
public async Task PushContinuesOnError() | ||
{ | ||
var pusher = Substitute.For<IMetricPusher>(); | ||
pusher.PushAsync().Returns(Task.FromException(new Exception("Push error"))); | ||
|
||
var worker = new MetricPushServer(pusher, TimeSpan.FromSeconds(0.05)); | ||
worker.Start(); | ||
await Task.Delay(150); | ||
|
||
await pusher.Received(3).PushAsync(); | ||
worker.Stop(); | ||
} | ||
} |
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
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,23 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using DotNet.Testcontainers.Builders; | ||
using DotNet.Testcontainers.Containers; | ||
using Xunit; | ||
|
||
namespace Prometheus.Client.MetricPusher.Tests; | ||
|
||
public class PushGatewayFixture : IAsyncLifetime | ||
{ | ||
private readonly IContainer _container = new ContainerBuilder() | ||
.WithImage("prom/pushgateway") | ||
.WithPortBinding(9091, true) | ||
.Build(); | ||
|
||
public string GetEndpoint() => $"{Uri.UriSchemeHttp}://{_container.Hostname}:{_container.GetMappedPublicPort(9091)}"; | ||
|
||
public Task InitializeAsync() | ||
=> _container.StartAsync(); | ||
|
||
public Task DisposeAsync() | ||
=> _container.DisposeAsync().AsTask(); | ||
} |