@@ -10,18 +10,18 @@ public class DBConfigSetting
1010 public string ConnectionString { get ; set ; } = null ! ;
1111}
1212
13- public class ClickHouse_healthcheck_should
13+ public class ClickHouse_healthcheck_should ( ClickHouseContainerFixture clickHouseFixture ) : IClassFixture < ClickHouseContainerFixture >
1414{
15- private const string ConnectionString = "Host=127.0.0.1;Port=8123;Database=default;Username=default;Password=Password12!;" ;
15+ private readonly string _connectionString = clickHouseFixture . GetConnectionString ( ) ;
1616
1717 [ Fact ]
1818 public async Task be_healthy_if_ClickHouse_is_available ( )
1919 {
2020 var webHostBuilder = new WebHostBuilder ( )
21- . ConfigureServices ( static services =>
21+ . ConfigureServices ( services =>
2222 {
2323 services . AddHealthChecks ( )
24- . AddClickHouse ( static _ => new ClickHouseConnection ( ConnectionString ) , tags : new string [ ] { "ClickHouse" } ) ;
24+ . AddClickHouse ( _ => new ClickHouseConnection ( _connectionString ) , tags : new string [ ] { "ClickHouse" } ) ;
2525 } )
2626 . Configure ( static app =>
2727 {
@@ -42,10 +42,10 @@ public async Task be_healthy_if_ClickHouse_is_available()
4242 public async Task be_unhealthy_if_sql_query_is_not_valid ( )
4343 {
4444 var webHostBuilder = new WebHostBuilder ( )
45- . ConfigureServices ( static services =>
45+ . ConfigureServices ( services =>
4646 {
4747 services . AddHealthChecks ( )
48- . AddClickHouse ( static _ => new ClickHouseConnection ( ConnectionString ) , "SELECT 1 FROM InvalidDB" , tags : new string [ ] { "ClickHouse" } ) ;
48+ . AddClickHouse ( _ => new ClickHouseConnection ( _connectionString ) , "SELECT 1 FROM InvalidDB" , tags : new string [ ] { "ClickHouse" } ) ;
4949 } )
5050 . Configure ( static app =>
5151 {
@@ -68,8 +68,11 @@ public async Task be_unhealthy_if_ClickHouse_is_not_available()
6868 var webHostBuilder = new WebHostBuilder ( )
6969 . ConfigureServices ( services =>
7070 {
71- services . AddHealthChecks ( )
72- . AddClickHouse ( static _ => new ClickHouseConnection ( "Host=200.0.0.1;Port=8123;Database=default;Username=default;Password=Password12!;" ) , tags : new string [ ] { "ClickHouse" } ) ;
71+ services
72+ . AddHealthChecks ( )
73+ . AddClickHouse ( static _ => new ClickHouseConnection ( "Host=200.0.0.1;Port=8123;Database=default;Username=default;Password=Password12!;" ) ,
74+ tags : [ "ClickHouse" ] ,
75+ timeout : TimeSpan . FromSeconds ( 15 ) ) ;
7376 } )
7477 . Configure ( app =>
7578 {
@@ -94,7 +97,7 @@ public async Task be_healthy_if_ClickHouse_is_available_by_iServiceProvider_regi
9497 {
9598 services . AddSingleton ( new DBConfigSetting
9699 {
97- ConnectionString = ConnectionString
100+ ConnectionString = _connectionString
98101 } ) ;
99102
100103 services . AddHealthChecks ( )
@@ -126,8 +129,12 @@ public async Task be_unhealthy_if_ClickHouse_is_not_available_registered()
126129 ConnectionString = "Server=200.0.0.1;Port=8010;User ID=postgres;Password=Password12!;database=postgres"
127130 } ) ;
128131
129- services . AddHealthChecks ( )
130- . AddClickHouse ( static sp => new ClickHouseConnection ( sp . GetRequiredService < DBConfigSetting > ( ) . ConnectionString ) , tags : new string [ ] { "ClickHouse" } ) ;
132+ services
133+ . AddHealthChecks ( )
134+ . AddClickHouse (
135+ static sp => new ClickHouseConnection ( sp . GetRequiredService < DBConfigSetting > ( ) . ConnectionString ) ,
136+ tags : [ "ClickHouse" ] ,
137+ timeout : TimeSpan . FromSeconds ( 15 ) ) ;
131138 } )
132139 . Configure ( app =>
133140 {
0 commit comments