1
- using Microsoft . Extensions . Configuration ;
1
+ using Microsoft . Extensions . Configuration ;
2
2
using Microsoft . Extensions . DependencyInjection ;
3
3
using Microsoft . Extensions . Logging ;
4
4
using AM . Extensions . Logging . ElasticSearch ;
10
10
using Nest ;
11
11
using Xunit . Abstractions ;
12
12
using LogLevel = Microsoft . Extensions . Logging . LogLevel ;
13
+ using ElasticLogger . Test . Entities ;
14
+ using ElasticLogger . Test . Fixture ;
13
15
14
16
namespace ElasticLogger . Test
15
17
{
16
- public class ElasticsearchLoggerFilterTests : IClassFixture < ESFixture >
18
+ public class ElasticsearchLoggerFilterTests : IClassFixture < ElasticsearchFixture >
17
19
{
18
20
private readonly ITestOutputHelper _output ;
19
- private readonly ESFixture _fixture ;
21
+ private readonly ElasticsearchFixture _fixture ;
20
22
21
- public ElasticsearchLoggerFilterTests ( ESFixture fixture , ITestOutputHelper output )
23
+ public ElasticsearchLoggerFilterTests ( ElasticsearchFixture fixture , ITestOutputHelper output )
22
24
{
23
25
_fixture = fixture ;
24
26
_output = output ;
25
27
}
26
28
29
+ private ConnectionSettings connectionSettings ( Uri endpoint )
30
+ {
31
+ var connSettings = new ConnectionSettings ( endpoint ) ;
32
+ connSettings . ServerCertificateValidationCallback ( ( obj , cert , chain , policyerrors ) => true ) ;
33
+ return connSettings ;
34
+ }
35
+
27
36
[ Fact ]
28
37
public async Task No_categories_for_es_should_use_default ( )
29
38
{
@@ -62,7 +71,7 @@ public async Task No_categories_for_es_should_use_default()
62
71
logger . LogTrace ( "bananas taste yucky" ) ;
63
72
64
73
var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
65
- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
74
+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
66
75
await client . PingAsync ( ) ;
67
76
await delayTask ;
68
77
@@ -123,7 +132,7 @@ public async Task Configured_categories_dont_log_for_config()
123
132
logger . LogTrace ( "bananas taste yucky" ) ;
124
133
125
134
var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
126
- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
135
+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
127
136
await client . PingAsync ( ) ;
128
137
await delayTask ;
129
138
@@ -179,7 +188,7 @@ public async Task No_elasticsearch_section_should_use_default_log_level()
179
188
logger . LogTrace ( "bananas taste yucky" ) ;
180
189
181
190
var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
182
- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
191
+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
183
192
await client . PingAsync ( ) ;
184
193
await delayTask ;
185
194
@@ -285,7 +294,7 @@ private async Task LevelTesterPositive(string source, LogLevel logLevel)
285
294
logger . Log ( logLevel , new EventId ( ) , circularRefObj , null , ( circle , exception ) => "" ) ;
286
295
287
296
var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
288
- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
297
+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
289
298
await client . PingAsync ( ) ;
290
299
await delayTask ;
291
300
@@ -335,7 +344,7 @@ private async Task LevelTesterNegative(string source, LogLevel logLevel)
335
344
logger . Log ( logLevel , new EventId ( ) , circularRefObj , null , ( circle , exception ) => "" ) ;
336
345
337
346
var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
338
- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
347
+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
339
348
await client . PingAsync ( ) ;
340
349
await delayTask ;
341
350
@@ -357,7 +366,7 @@ private async Task LevelTesterNegative(string source, LogLevel logLevel)
357
366
public async Task Load_ES_with_explicit_type_write_and_search ( )
358
367
{
359
368
await _fixture . ReadyAsync ( ) ;
360
- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
369
+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
361
370
await client . PingAsync ( ) ;
362
371
363
372
var tweet = new Tweet
@@ -418,7 +427,7 @@ public async Task Missing_ElasticSearch_Section_In_Config_Should_Use_Logging_Def
418
427
logger . LogTrace ( "bananas taste yucky" ) ;
419
428
420
429
var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
421
- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
430
+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
422
431
await client . PingAsync ( ) ;
423
432
await delayTask ;
424
433
@@ -470,7 +479,8 @@ public async Task Missing_ElasticSearch_Section_In_Config_Should_Use_Logging_Def
470
479
logger . LogError ( "bananas taste yucky" ) ;
471
480
472
481
var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
473
- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
482
+
483
+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
474
484
await client . PingAsync ( ) ;
475
485
await delayTask ;
476
486
@@ -487,6 +497,8 @@ public async Task Missing_ElasticSearch_Section_In_Config_Should_Use_Logging_Def
487
497
Assert . Single ( dyndocs . Documents ) ;
488
498
}
489
499
500
+
501
+
490
502
[ Fact ]
491
503
public async Task Existing_ElasticSearch_Section_In_Config_Should_Be_Used_For_Log_Levels_Positive_Match ( )
492
504
{
@@ -523,7 +535,7 @@ public async Task Existing_ElasticSearch_Section_In_Config_Should_Be_Used_For_Lo
523
535
logger . LogTrace ( "bananas taste yucky" ) ;
524
536
525
537
var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
526
- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
538
+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
527
539
await client . PingAsync ( ) ;
528
540
await delayTask ;
529
541
@@ -576,7 +588,7 @@ public async Task Existing_ElasticSearch_Section_In_Config_Should_Be_Used_For_Lo
576
588
logger . LogCritical ( "bananas taste yucky" ) ;
577
589
578
590
var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
579
- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
591
+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
580
592
await client . PingAsync ( ) ;
581
593
await delayTask ;
582
594
@@ -630,7 +642,7 @@ public async Task Existing_ElasticSearch_Section_With_Category_Should_Match_Top_
630
642
logger . LogInformation ( "bananas taste yucky" ) ;
631
643
632
644
var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
633
- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
645
+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
634
646
await client . PingAsync ( ) ;
635
647
await delayTask ;
636
648
@@ -684,7 +696,7 @@ public async Task Existing_ElasticSearch_Section_With_Category_Should_Match_Top_
684
696
logger . LogInformation ( "bananas taste yucky" ) ;
685
697
686
698
var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
687
- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
699
+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
688
700
await client . PingAsync ( ) ;
689
701
await delayTask ;
690
702
@@ -738,7 +750,7 @@ public async Task Existing_ElasticSearch_Section_With_Category_Should_Match_Bott
738
750
logger . LogCritical ( "bananas taste yucky" ) ;
739
751
740
752
var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
741
- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
753
+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
742
754
await client . PingAsync ( ) ;
743
755
await delayTask ;
744
756
@@ -792,7 +804,7 @@ public async Task Existing_ElasticSearch_Section_With_Category_Should_Match_Bott
792
804
logger . LogInformation ( "bananas taste yucky" ) ;
793
805
794
806
var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
795
- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
807
+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
796
808
await client . PingAsync ( ) ;
797
809
await delayTask ;
798
810
0 commit comments