Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a04f58f
rename Serializer subfolder to Auxiliary
Mpdreamz Jul 2, 2019
8954f57
introduced seperate project for virtual cluster
Mpdreamz Jul 2, 2019
923a1c6
VirtualCluster auditor returns a more real fake response
Mpdreamz Jul 2, 2019
cf454ca
moved WaitingInMemoryConnection back
Mpdreamz Jul 2, 2019
0256e52
Union was copied twice
Mpdreamz Jul 2, 2019
09ef419
make sure VirtualClusterConnection is exposed
Mpdreamz Jul 2, 2019
6d3996c
Add Elasticsearch.Net.Virtual as project into the build
Mpdreamz Jul 2, 2019
b2d5fe2
do not rely on HttpClientException on net461
Mpdreamz Jul 2, 2019
a57b5a7
Exception test needs to be .NET core specific now
Mpdreamz Jul 2, 2019
79cb672
build for canary was still looking in Serializers folder not Auxiliary
Mpdreamz Jul 2, 2019
19bd9b4
canary handling for Elasticsearch.Net.Virtual
Mpdreamz Jul 2, 2019
2fc36a8
skip nuget testing for Elasticearch.Net.Virtual
Mpdreamz Jul 2, 2019
aae5909
reference TestPackageVersion of Elasticsearch.Net optionally
Mpdreamz Jul 3, 2019
f8fb868
still included csproj
Mpdreamz Jul 3, 2019
9038208
Use targetting pack and made sure canary works under linux too
Mpdreamz Jul 4, 2019
2463e19
Update build/Elasticsearch.Net.Virtual.nuspec
Mpdreamz Aug 27, 2019
8033a14
Merge branch '7.x' into feature/7.x/virtual-connection
Mpdreamz Sep 24, 2019
0cf8ed4
Client on VirtualizedCluster became public on 7.x, mirror that here
Mpdreamz Sep 24, 2019
8f26e7d
change namespace to Elasticsearch.Net.VirtualizedCluster
Mpdreamz Sep 24, 2019
1426454
update tests from 7.x and bumped sdk version
Mpdreamz Sep 24, 2019
295e34a
Merge branch 'feature/7.x/virtual-connection' of github.com:elastic/e…
Mpdreamz Sep 24, 2019
5285d8f
bump global json back
Mpdreamz Sep 24, 2019
a79730f
canary build needs to resolve Elasticsearch.Net reference as nuget fo…
Mpdreamz Sep 24, 2019
b1a7cc4
bulk all exception tests canary ignore
Mpdreamz Sep 24, 2019
43c6b9c
bulk all exception tests canary ignore
Mpdreamz Sep 24, 2019
8fe36e9
make test less strict
Mpdreamz Sep 24, 2019
5504afd
skip test on CI
Mpdreamz Sep 24, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions build/Elasticsearch.Net.VirtualizedCluster.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>Elasticsearch.Net.VirtualizedCluster</id>
<version>$version$</version>
<title>Elasticsearch.Net.VirtualizedCluster - A highly configurable in memory IConnection</title>
<authors>Elastic and contributors</authors>
<owners>Elastic</owners>
<license type="file">license.txt</license>
<projectUrl>https://github.com/elastic/elasticsearch-net</projectUrl>
<iconUrl>https://raw.githubusercontent.com/elastic/elasticsearch-net/master/build/nuget-icon.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<summary>Provides a way to assert client behaviour through a rule engine backed VirtualClusterConnection</summary>
<description>Provides a way to assert cluent behaviour through a rule engine backed VirtualClusterConnection</description>
<releaseNotes>See https://github.com/elastic/elasticsearch-net/releases/tag/$version$</releaseNotes>
<copyright>2014-$year$ Elasticsearch BV</copyright>
<tags>elasticsearch,elastic,search,lucene,nest</tags>
<dependencies>
<group targetFramework=".NETStandard2.0">
<dependency id="Elasticsearch.Net" version="[$currentMajorVersion$, $nextMajorVersion$)" />
</group>
<group targetFramework="net461">
<dependency id="Elasticsearch.Net" version="[$currentMajorVersion$, $nextMajorVersion$)" />
</group>
</dependencies>
</metadata>
<files>
<file src="..\license.txt" target="" />

<file src="output\Elasticsearch.Net.VirtualizedCluster\netstandard2.0\Elasticsearch.Net.VirtualizedCluster.dll" target="lib\netstandard2.0"/>
<file src="output\Elasticsearch.Net.VirtualizedCluster\netstandard2.0\Elasticsearch.Net.VirtualizedCluster.xml" target="lib\netstandard2.0"/>

<file src="output\Elasticsearch.Net.VirtualizedCluster\net461\Elasticsearch.Net.VirtualizedCluster.dll" target="lib\net461"/>
<file src="output\Elasticsearch.Net.VirtualizedCluster\net461\Elasticsearch.Net.VirtualizedCluster.xml" target="lib\net461"/>
</files>
</package>
3 changes: 2 additions & 1 deletion build/scripts/Paths.fs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ module Paths =
match project with
| Project p ->
match p with
| NestJsonNetSerializer -> sprintf "%s/Serializers/%s/%s.csproj" SourceFolder project.Name project.Name
| NestJsonNetSerializer -> sprintf "%s/Auxiliary/%s/%s.csproj" SourceFolder project.Name project.Name
| ElasticsearchNetVirtual -> sprintf "%s/Auxiliary/%s/%s.csproj" SourceFolder project.Name project.Name
| _ -> sprintf "%s/%s/%s.csproj" SourceFolder project.Name project.Name
| PrivateProject p ->
match p with
Expand Down
4 changes: 4 additions & 0 deletions build/scripts/Projects.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module Projects =
| Nest
| ElasticsearchNet
| NestJsonNetSerializer
| ElasticsearchNetVirtual

type PrivateProject =
| Tests
Expand All @@ -39,6 +40,7 @@ module Projects =
Project Project.ElasticsearchNet;
Project Project.Nest;
Project Project.NestJsonNetSerializer;
Project Project.ElasticsearchNetVirtual;
PrivateProject PrivateProject.Tests
]

Expand All @@ -47,6 +49,7 @@ module Projects =
Project Project.ElasticsearchNet;
Project Project.Nest;
Project Project.NestJsonNetSerializer;
Project Project.ElasticsearchNetVirtual;
]
static member Tests = seq [PrivateProject PrivateProject.Tests]

Expand All @@ -67,6 +70,7 @@ module Projects =
| Project Nest -> "Nest"
| Project ElasticsearchNet -> "Elasticsearch.Net"
| Project NestJsonNetSerializer -> "Nest.JsonNetSerializer"
| Project ElasticsearchNetVirtual -> "Elasticsearch.Net.VirtualizedCluster"
| PrivateProject Tests -> "Tests"
| PrivateProject DocGenerator -> "DocGenerator"
| PrivateProject ApiGenerator -> "ApiGenerator"
Expand Down
4 changes: 4 additions & 0 deletions build/scripts/Releasing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ module Release =
)

match p with
| Project ElasticsearchNetVirtual
| Project Nest ->
let esDeps = doc.XPathSelectElements("/x:package/x:metadata//x:dependency[@id='Elasticsearch.Net']", nsManager);
esDeps |> Seq.iter(fun e ->
Expand Down Expand Up @@ -143,6 +144,9 @@ module Release =

let private nugetPackVersioned (p:DotNetProject) nugetId nuspec properties version =
match p with
| Project ElasticsearchNetVirtual ->
printfn "Skipping %s from building a versioned nightly" p.Name
ignore()
| _ -> nugetPackVersionedUnfiltered p nugetId nuspec properties version

let NugetPack (ArtifactsVersion(version)) = packProjects version nugetPackMain
Expand Down
4 changes: 2 additions & 2 deletions build/scripts/Targets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ module Main =
target "inherit-doc" <| InheritDoc.PatchInheritDocs

target "test-nuget-package" <| fun _ ->
//run release unit tests puts packages in the system cache prevent this from happening locally
// run release unit tests puts packages in the system cache prevent this from happening locally
if not Commandline.runningOnCi then ignore ()
else Tests.RunReleaseUnitTests artifactsVersion |> ignore

target "nuget-pack" <| fun _ -> Release.NugetPack artifactsVersion

conditional (parsed.Target = "canary") "nuget-pack-versioned" <| fun _ -> Release.NugetPackVersioned artifactsVersion
conditional (parsed.Target = "canary" && not isMono) "nuget-pack-versioned" <| fun _ -> Release.NugetPackVersioned artifactsVersion

conditional (parsed.Target <> "canary") "generate-release-notes" <| fun _ -> ReleaseNotes.GenerateNotes buildVersions

Expand Down
38 changes: 0 additions & 38 deletions build/scripts/scripts.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,44 +29,6 @@
<Content Include="..\..\appveyor.yml"><Link>appveyor.yml</Link></Content>
<Content Include="..\..\azure-pipelines.yml"><Link>azure-pipelines.yml</Link></Content>
</ItemGroup>
<!-- Type providers currently can't run inside the .NET Core 2.0 hosted compiler, see https://github.com/Microsoft/visualfsharp/pull/3658#issuecomment-334773415 -->
<PropertyGroup>
<IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>
<PropertyGroup Condition="'$(IsWindows)' == 'true' AND Exists('C:\Program Files (x86)\Microsoft SDKs\F#\4.1\Framework\v4.0\fsc.exe')">
<FscToolPath>C:\Program Files (x86)\Microsoft SDKs\F#\4.1\Framework\v4.0</FscToolPath>
<FscToolExe>fsc.exe</FscToolExe>
</PropertyGroup>
<PropertyGroup Condition="'$(IsWindows)' == 'true' AND Exists('C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\FSharp\fsc.exe')">
<FscToolPath>C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\FSharp</FscToolPath>
<FscToolExe>fsc.exe</FscToolExe>
</PropertyGroup>
<PropertyGroup Condition="'$(IsWindows)' == 'true' AND Exists('C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\FSharp\fsc.exe')">
<FscToolPath>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\FSharp</FscToolPath>
<FscToolExe>fsc.exe</FscToolExe>
</PropertyGroup>
<PropertyGroup Condition="'$(IsWindows)' == 'true' AND Exists('C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\FSharp\fsc.exe')">
<FscToolPath>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\FSharp</FscToolPath>
<FscToolExe>fsc.exe</FscToolExe>
</PropertyGroup>
<PropertyGroup Condition="'$(IsWindows)' == 'true' AND Exists('C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\FSharp\fsc.exe')">
<FscToolPath>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\FSharp</FscToolPath>
<FscToolExe>fsc.exe</FscToolExe>
</PropertyGroup>
<PropertyGroup Condition="'$(IsWindows)' == 'true' AND Exists('C:\Program Files (x86)\Microsoft SDKs\F#\10.1\Framework\v4.0\fsc.exe')">
<FscToolPath>C:\Program Files (x86)\Microsoft SDKs\F#\10.1\Framework\v4.0</FscToolPath>
<FscToolExe>fsc.exe</FscToolExe>
</PropertyGroup>
<PropertyGroup Condition="'$(IsOSX)' == 'true' AND Exists('/Library/Frameworks/Mono.framework/Versions/Current/Commands/fsharpc')">
<FscToolPath>/Library/Frameworks/Mono.framework/Versions/Current/Commands</FscToolPath>
<FscToolExe>fsharpc</FscToolExe>
</PropertyGroup>
<PropertyGroup Condition="'$(IsLinux)' == 'true' AND Exists('/usr/bin/fsharpc')">
<FscToolPath>/usr/bin</FscToolPath>
<FscToolExe>fsharpc</FscToolExe>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Bullseye" Version="3.0.0-rc.1" />
<PackageReference Include="Elastic.Managed" Version="0.1.0-ci20190806T115008" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Elasticsearch.Net;
using Elasticsearch.Net.Extensions;
using FluentAssertions;
using Nest;
using Tests.Core.Extensions;
using Tests.Framework.Extensions;

namespace Tests.Framework.VirtualClustering.Audit
using Elasticsearch.Net.VirtualizedCluster.Extensions;

namespace Elasticsearch.Net.VirtualizedCluster.Audit
{
public class Auditor
{
Expand All @@ -36,8 +31,8 @@ private Auditor(VirtualizedCluster cluster, VirtualizedCluster clusterAsync)
public List<Elasticsearch.Net.Audit> AuditTrail { get; set; }
public Func<VirtualizedCluster> Cluster { get; set; }

public IResponse Response { get; internal set; }
public IResponse ResponseAsync { get; internal set; }
public IElasticsearchResponse Response { get; internal set; }
public IElasticsearchResponse ResponseAsync { get; internal set; }

private bool StartedUp { get; }

Expand Down Expand Up @@ -66,7 +61,7 @@ public async Task<Auditor> TraceStartup(ClientCall callTrace = null)
_clusterAsync = _clusterAsync ?? Cluster();
if (!StartedUp) AssertPoolBeforeStartup?.Invoke(_clusterAsync.ConnectionPool);
AssertPoolBeforeCall?.Invoke(_clusterAsync.ConnectionPool);
ResponseAsync = await _clusterAsync.ClientCallAsync(callTrace?.RequestOverrides);
ResponseAsync = await _clusterAsync.ClientCallAsync(callTrace?.RequestOverrides).ConfigureAwait(false);
AsyncAuditTrail = ResponseAsync.ApiCall.AuditTrail;
if (!StartedUp) AssertPoolAfterStartup?.Invoke(_clusterAsync.ConnectionPool);
AssertPoolAfterCall?.Invoke(_clusterAsync.ConnectionPool);
Expand All @@ -75,7 +70,7 @@ public async Task<Auditor> TraceStartup(ClientCall callTrace = null)

public async Task<Auditor> TraceCall(ClientCall callTrace, int nthCall = 0)
{
await TraceStartup(callTrace);
await TraceStartup(callTrace).ConfigureAwait(false);
return AssertAuditTrails(callTrace, nthCall);
}

Expand All @@ -89,18 +84,16 @@ private async Task TraceException<TException>(ClientCall callTrace, Action<TExce
AssertPoolBeforeCall?.Invoke(_cluster.ConnectionPool);

Action call = () => _cluster.ClientCall(callTrace?.RequestOverrides);
var exception = call.Should().ThrowExactly<TException>()
.Subject.First();
var exception = TryCall(call, assert);
assert(exception);

AuditTrail = exception.AuditTrail;
AssertPoolAfterCall?.Invoke(_cluster.ConnectionPool);

_clusterAsync = _clusterAsync ?? Cluster();
_clusterAsync.ClientThrows(true);
Func<Task> callAsync = async () => await _clusterAsync.ClientCallAsync(callTrace?.RequestOverrides);
exception = callAsync.Should().ThrowExactly<TException>()
.Subject.First();
Func<Task> callAsync = () => _clusterAsync.ClientCallAsync(callTrace?.RequestOverrides);
exception = await TryCallAsync(callAsync, assert).ConfigureAwait(false);
assert(exception);

AsyncAuditTrail = exception.AuditTrail;
Expand All @@ -109,14 +102,14 @@ private async Task TraceException<TException>(ClientCall callTrace, Action<TExce

public async Task<Auditor> TraceElasticsearchException(ClientCall callTrace, Action<ElasticsearchClientException> assert)
{
await TraceException(callTrace, assert);
await TraceException(callTrace, assert).ConfigureAwait(false);
var audit = new Auditor(_cluster, _clusterAsync);
return await audit.TraceElasticsearchExceptionOnResponse(callTrace, assert);
return await audit.TraceElasticsearchExceptionOnResponse(callTrace, assert).ConfigureAwait(false);
}

public async Task<Auditor> TraceUnexpectedElasticsearchException(ClientCall callTrace, Action<UnexpectedElasticsearchClientException> assert)
{
await TraceException(callTrace, assert);
await TraceException(callTrace, assert).ConfigureAwait(false);
return new Auditor(_cluster, _clusterAsync);
}

Expand All @@ -129,23 +122,24 @@ public async Task<Auditor> TraceElasticsearchExceptionOnResponse(ClientCall call
AssertPoolBeforeCall?.Invoke(_cluster.ConnectionPool);

Action call = () => { Response = _cluster.ClientCall(callTrace?.RequestOverrides); };
call.Should().NotThrow();

Response.ShouldNotBeValid();
call();

if (Response.ApiCall.Success) throw new Exception("Expected call to not be valid");

var exception = Response.ApiCall.OriginalException as ElasticsearchClientException;
exception.Should().NotBeNull("OriginalException on response is not expected ElasticsearchClientException");
if (exception == null) throw new Exception("OriginalException on response is not expected ElasticsearchClientException");
assert(exception);

AuditTrail = exception.AuditTrail;
AssertPoolAfterCall?.Invoke(_cluster.ConnectionPool);

_clusterAsync = _clusterAsync ?? Cluster();
_clusterAsync.ClientThrows(false);
Func<Task> callAsync = async () => { ResponseAsync = await _clusterAsync.ClientCallAsync(callTrace?.RequestOverrides); };
callAsync.Should().NotThrow();
ResponseAsync.ShouldNotBeValid();
Func<Task> callAsync = async () => { ResponseAsync = await _clusterAsync.ClientCallAsync(callTrace?.RequestOverrides).ConfigureAwait(false); };
await callAsync().ConfigureAwait(false);
if (Response.ApiCall.Success) throw new Exception("Expected call to not be valid");
exception = ResponseAsync.ApiCall.OriginalException as ElasticsearchClientException;
exception.Should().NotBeNull("OriginalException on response is not expected ElasticsearchClientException");
if (exception == null) throw new Exception("OriginalException on response is not expected ElasticsearchClientException");
assert(exception);

AsyncAuditTrail = exception.AuditTrail;
Expand All @@ -163,17 +157,15 @@ public async Task<Auditor> TraceUnexpectedException(ClientCall callTrace, Action
AssertPoolBeforeCall?.Invoke(_cluster.ConnectionPool);

Action call = () => _cluster.ClientCall(callTrace?.RequestOverrides);
var exception = call.Should().ThrowExactly<UnexpectedElasticsearchClientException>()
.Subject.First();
var exception = TryCall(call, assert);
assert(exception);

AuditTrail = exception.AuditTrail;
AssertPoolAfterCall?.Invoke(_cluster.ConnectionPool);

_clusterAsync = _clusterAsync ?? Cluster();
Func<Task> callAsync = async () => await _clusterAsync.ClientCallAsync(callTrace?.RequestOverrides);
exception = callAsync.Should().ThrowExactly<UnexpectedElasticsearchClientException>()
.Subject.First();
Func<Task> callAsync = () => _clusterAsync.ClientCallAsync(callTrace?.RequestOverrides);
exception = await TryCallAsync(callAsync, assert).ConfigureAwait(false);
assert(exception);

AsyncAuditTrail = exception.AuditTrail;
Expand All @@ -183,10 +175,9 @@ public async Task<Auditor> TraceUnexpectedException(ClientCall callTrace, Action

private Auditor AssertAuditTrails(ClientCall callTrace, int nthCall)
{
AuditTrail.Count.Should()
.Be(AsyncAuditTrail.Count,
$"{nthCall} has a mismatch between sync and async. \r\nasync:{AuditTrail}\r\nsync:{AsyncAuditTrail}");

if (AuditTrail.Count != AsyncAuditTrail.Count)
throw new Exception($"{nthCall} has a mismatch between sync and async. \r\nasync:{AuditTrail}\r\nsync:{AsyncAuditTrail}");

AssertTrailOnResponse(callTrace, AuditTrail, true, nthCall);
AssertTrailOnResponse(callTrace, AuditTrail, false, nthCall);

Expand Down Expand Up @@ -223,7 +214,7 @@ private static string AuditTrailToString(List<Elasticsearch.Net.Audit> auditTrai
public async Task<Auditor> TraceCalls(params ClientCall[] audits)
{
var auditor = this;
foreach (var a in audits.Select((a, i) => new { a, i })) auditor = await auditor.TraceCall(a.a, a.i);
foreach (var a in audits.Select((a, i) => new { a, i })) auditor = await auditor.TraceCall(a.a, a.i).ConfigureAwait(false);
return auditor;
}

Expand All @@ -235,11 +226,11 @@ private static void AssertTrailOnResponse(ClientCall callTrace, List<Elasticsear
var actualAuditTrail = auditTrail.Aggregate(new StringBuilder(Environment.NewLine),
(sb, a) => sb.AppendLine($"-> {a}"),
sb => sb.ToString());

callTrace.Select(c => c.Event)
.Should()
.ContainInOrder(auditTrail.Select(a => a.Event),
$"the {nthClientCall} client call's {typeOfTrail} should assert ALL audit trail items{actualAuditTrail}");
var traceEvents =callTrace.Select(c => c.Event).ToList();
var auditEvents = auditTrail.Select(a => a.Event).ToList();
if (!traceEvents.SequenceEqual(auditEvents))
throw new Exception($"the {nthClientCall} client call's {typeOfTrail} should assert ALL audit trail items{actualAuditTrail}");

foreach (var t in auditTrail.Select((a, i) => new { a, i }))
{
Expand All @@ -248,13 +239,51 @@ private static void AssertTrailOnResponse(ClientCall callTrace, List<Elasticsear
var nthAuditTrailItem = (i + 1).ToOrdinal();
var because = $"thats the {{0}} specified on the {nthAuditTrailItem} item in the {nthClientCall} client call's {typeOfTrail}";
var c = callTrace[i];
audit.Event.Should().Be(c.Event, string.Format(because, "event"));
if (c.Port.HasValue) audit.Node.Uri.Port.Should().Be(c.Port.Value, string.Format(because, "port"));
if (audit.Event != c.Event)
throw new Exception(string.Format(because, "event"));
if (c.Port.HasValue && audit.Node.Uri.Port != c.Port.Value)
throw new Exception(string.Format(because, "port"));

c.SimpleAssert?.Invoke(audit);
c.AssertWithBecause?.Invoke(string.Format(because, "custom assertion"), audit);
}

callTrace.Count.Should().Be(auditTrail.Count, $"actual auditTrail {actualAuditTrail}");
if (callTrace.Count != auditTrail.Count)
throw new Exception($"callTrace has {callTrace.Count} items. Actual auditTrail {actualAuditTrail}");
}

private static TException TryCall<TException>(Action call, Action<TException> assert) where TException : ElasticsearchClientException
{
TException exception = null;
try
{
call();
}
catch (TException ex)
{
exception = ex;
assert(ex);
}
if (exception is null) throw new Exception("No exception happened while one was expected");

return exception;
}
private static async Task<TException> TryCallAsync<TException>(Func<Task> call, Action<TException> assert) where TException : ElasticsearchClientException
{
TException exception = null;
try
{
await call().ConfigureAwait(false);
}
catch (TException ex)
{
exception = ex;
assert(ex);
}
if (exception is null) throw new Exception("No exception happened while one was expected");

return exception;
}

}
}
Loading