This repository has been archived by the owner on Jun 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 197
Elasticsearch.Net 7.0.0 support, V7 templates #249
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"sdk": { | ||
"version": "2.1.4" | ||
"version": "2.1.500" | ||
} | ||
} |
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
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
66 changes: 66 additions & 0 deletions
66
test/Serilog.Sinks.Elasticsearch.Tests/Templating/Sendsv7TemplateTests.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,66 @@ | ||
using System; | ||
using System.Reflection; | ||
using FluentAssertions; | ||
using Newtonsoft.Json.Linq; | ||
using Xunit; | ||
|
||
namespace Serilog.Sinks.Elasticsearch.Tests.Templating | ||
{ | ||
public class Sendsv7TemplateTests : ElasticsearchSinkTestsBase | ||
{ | ||
private readonly Tuple<Uri, string> _templatePut; | ||
|
||
public Sendsv7TemplateTests() | ||
{ | ||
_options.AutoRegisterTemplate = true; | ||
_options.AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv7; | ||
|
||
var loggerConfig = new LoggerConfiguration() | ||
.MinimumLevel.Debug() | ||
.Enrich.WithMachineName() | ||
.WriteTo.ColoredConsole() | ||
.WriteTo.Elasticsearch(_options); | ||
|
||
var logger = loggerConfig.CreateLogger(); | ||
using (logger as IDisposable) | ||
{ | ||
logger.Error("Test exception. Should not contain an embedded exception object."); | ||
} | ||
|
||
this._seenHttpPosts.Should().NotBeNullOrEmpty().And.HaveCount(1); | ||
this._seenHttpPuts.Should().NotBeNullOrEmpty().And.HaveCount(1); | ||
_templatePut = this._seenHttpPuts[0]; | ||
} | ||
|
||
[Fact] | ||
public void ShouldRegisterTheCorrectTemplateOnRegistration() | ||
{ | ||
|
||
var method = typeof(Sendsv7TemplateTests).GetMethod(nameof(ShouldRegisterTheCorrectTemplateOnRegistration)); | ||
JsonEquals(_templatePut.Item2, method, "template_v7.json"); | ||
} | ||
|
||
[Fact] | ||
public void TemplatePutToCorrectUrl() | ||
{ | ||
var uri = _templatePut.Item1; | ||
uri.AbsolutePath.Should().Be("/_template/serilog-events-template"); | ||
} | ||
|
||
protected void JsonEquals(string json, MethodBase method, string fileName = null) | ||
{ | ||
#if DOTNETCORE | ||
var assembly = typeof(Sendsv7TemplateTests).GetTypeInfo().Assembly; | ||
#else | ||
var assembly = Assembly.GetExecutingAssembly(); | ||
#endif | ||
var expected = TestDataHelper.ReadEmbeddedResource(assembly, fileName ?? "template.json"); | ||
|
||
var nJson = JObject.Parse(json); | ||
var nOtherJson = JObject.Parse(expected); | ||
var equals = JToken.DeepEquals(nJson, nOtherJson); | ||
if (equals) return; | ||
expected.Should().BeEquivalentTo(json); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 500 here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ffMathy oh that's just from my initial setup cause I don't have 2.1.4 locally and when I did that I was just experimenting, didn't consider I'd end up making a PR...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see.