-
Notifications
You must be signed in to change notification settings - Fork 3
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
Martin Ligtenberg
committed
Feb 7, 2024
1 parent
a4845e5
commit b9b2520
Showing
7 changed files
with
53 additions
and
67 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
13 changes: 13 additions & 0 deletions
13
src/Orchestrator/CloudRepublic.BenchMark.Orchestrator.V2/Interfaces/IBenchMarkService.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,13 @@ | ||
using CloudRepublic.BenchMark.Application.Models; | ||
|
||
namespace CloudRepublic.BenchMark.Orchestrator.V2.Interfaces; | ||
|
||
public interface IBenchMarkService | ||
{ | ||
/// <summary> | ||
/// Starts the client and makes the Request | ||
/// </summary> | ||
/// <param name="clientName"></param> | ||
/// <returns></returns> | ||
Task<BenchMarkResponse> RunBenchMarkAsync(BenchMarkType benchMarkType, int CallPositionNumber); | ||
} |
35 changes: 35 additions & 0 deletions
35
src/Orchestrator/CloudRepublic.BenchMark.Orchestrator.V2/Services/BenchMarkService.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,35 @@ | ||
using System.Diagnostics; | ||
using CloudRepublic.BenchMark.Application.Models; | ||
using CloudRepublic.BenchMark.Orchestrator.V2.Interfaces; | ||
|
||
namespace CloudRepublic.BenchMark.Orchestrator.V2.Services; | ||
|
||
public class BenchMarkService : IBenchMarkService | ||
{ | ||
private readonly IHttpClientFactory _httpClientFactory; | ||
|
||
public BenchMarkService(IHttpClientFactory httpClientFactory) | ||
{ | ||
_httpClientFactory = httpClientFactory; | ||
} | ||
public async Task<BenchMarkResponse> RunBenchMarkAsync(BenchMarkType benchMarkType, int CallPositionNumber) | ||
{ | ||
var client = _httpClientFactory.CreateClient("benchmarkTester"); | ||
try | ||
{ | ||
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, benchMarkType.TestEndpoint); | ||
|
||
requestMessage.Headers.Add(benchMarkType.AuthenticationHeaderName, benchMarkType.AuthenticationHeaderValue); | ||
|
||
var stopWatch = Stopwatch.StartNew(); | ||
var response = await client.SendAsync(requestMessage); | ||
var result = stopWatch.ElapsedMilliseconds; | ||
|
||
return new BenchMarkResponse(response.IsSuccessStatusCode, (int)response.StatusCode, result, await response.Content.ReadAsStringAsync(), CallPositionNumber); | ||
} | ||
catch (Exception) | ||
{ | ||
return new BenchMarkResponse(false, 0, 0, null, CallPositionNumber); | ||
} | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
src/Shared/CloudRepublic.BenchMark.Shared/Application/Interfaces/IBenchMarkService.cs
This file was deleted.
Oops, something went wrong.
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
39 changes: 0 additions & 39 deletions
39
src/Shared/CloudRepublic.BenchMark.Shared/Application/Services/BenchMarkService.cs
This file was deleted.
Oops, something went wrong.
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