From fda0c2cef143e99b857c7508d3bde0eb9844e660 Mon Sep 17 00:00:00 2001 From: Mpdreamz Date: Mon, 4 Mar 2019 20:16:07 +0100 Subject: [PATCH 1/2] fix #3582 #3483 introduced SIMPLE_JSON_TYPEDEF to be defined which caused netstandard and netfx exceptions when deserializing sniff responses, but would light up in different places as well (cherry picked from commit c49736a3bef8f1f8bdd96f4233e90535b3223259) --- .../Serialization/SimpleJson.cs | 1 - .../LowLevel/SniffOnLowLevelClient.cs | 29 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/Tests/Tests/ClientConcepts/LowLevel/SniffOnLowLevelClient.cs diff --git a/src/Elasticsearch.Net/Serialization/SimpleJson.cs b/src/Elasticsearch.Net/Serialization/SimpleJson.cs index 0c5ac95602b..b699ac86936 100644 --- a/src/Elasticsearch.Net/Serialization/SimpleJson.cs +++ b/src/Elasticsearch.Net/Serialization/SimpleJson.cs @@ -48,7 +48,6 @@ // original json parsing code from http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html -#define SIMPLE_JSON_TYPEINFO using System; using System.CodeDom.Compiler; using System.Collections; diff --git a/src/Tests/Tests/ClientConcepts/LowLevel/SniffOnLowLevelClient.cs b/src/Tests/Tests/ClientConcepts/LowLevel/SniffOnLowLevelClient.cs new file mode 100644 index 00000000000..191352be7b9 --- /dev/null +++ b/src/Tests/Tests/ClientConcepts/LowLevel/SniffOnLowLevelClient.cs @@ -0,0 +1,29 @@ +using System; +using System.Linq; +using Elastic.Xunit.XunitPlumbing; +using Elasticsearch.Net; +using FluentAssertions; +using Tests.Core.Client.Settings; +using Tests.Core.ManagedElasticsearch.Clusters; +using Tests.Framework; + +namespace Tests.ClientConcepts.LowLevel +{ + public class SniffOnLowLevelClient : IClusterFixture + { + private readonly ReadOnlyCluster _cluster; + + public SniffOnLowLevelClient(ReadOnlyCluster cluster) => _cluster = cluster; + + [I] public void CanSniffUsingJustTheLowLevelClient() + { + var uri = TestConnectionSettings.CreateUri(_cluster.Nodes.First().Port ?? 9200); + var sniffingConnectionPool = new SniffingConnectionPool(new[] { uri }); + var elasticClient = new ElasticLowLevelClient(new ConnectionConfiguration(sniffingConnectionPool)); + + Func act = () => elasticClient.ClusterHealth(); + act.Invoking(s => s.Invoke()).ShouldNotThrow(); + } + + } +} From 5016c233970ce729cfa2502af6b295405196dc7d Mon Sep 17 00:00:00 2001 From: Mpdreamz Date: Mon, 4 Mar 2019 20:26:08 +0100 Subject: [PATCH 2/2] update assertion to be 5.x specific --- .../Tests/ClientConcepts/LowLevel/SniffOnLowLevelClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tests/Tests/ClientConcepts/LowLevel/SniffOnLowLevelClient.cs b/src/Tests/Tests/ClientConcepts/LowLevel/SniffOnLowLevelClient.cs index 191352be7b9..c5887447601 100644 --- a/src/Tests/Tests/ClientConcepts/LowLevel/SniffOnLowLevelClient.cs +++ b/src/Tests/Tests/ClientConcepts/LowLevel/SniffOnLowLevelClient.cs @@ -21,7 +21,7 @@ [I] public void CanSniffUsingJustTheLowLevelClient() var sniffingConnectionPool = new SniffingConnectionPool(new[] { uri }); var elasticClient = new ElasticLowLevelClient(new ConnectionConfiguration(sniffingConnectionPool)); - Func act = () => elasticClient.ClusterHealth(); + Func> act = () => elasticClient.ClusterHealth(); act.Invoking(s => s.Invoke()).ShouldNotThrow(); }