Skip to content

Commit

Permalink
fix(clickhouse sink): fix healthcheck uri (vectordotdev#19067)
Browse files Browse the repository at this point in the history
fix(clickhouse sink): fix healhcheck uri
  • Loading branch information
dsmith3197 authored Nov 6, 2023
1 parent 53ffbc3 commit 7a7b53b
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/sinks/clickhouse/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,17 @@ impl SinkConfig for ClickhouseConfig {
}
}

fn get_healthcheck_uri(endpoint: &Uri) -> String {
let mut uri = endpoint.to_string();
if !uri.ends_with('/') {
uri.push('/');
}
uri.push_str("?query=SELECT%201");
uri
}

async fn healthcheck(client: HttpClient, endpoint: Uri, auth: Option<Auth>) -> crate::Result<()> {
let uri = format!("{}/?query=SELECT%201", endpoint);
let uri = get_healthcheck_uri(&endpoint);
let mut request = Request::get(uri).body(Body::empty()).unwrap();

if let Some(auth) = auth {
Expand All @@ -154,4 +163,20 @@ mod tests {
fn generate_config() {
crate::test_util::test_generate_config::<ClickhouseConfig>();
}

#[test]
fn test_get_healthcheck_uri() {
assert_eq!(
get_healthcheck_uri(&"http://localhost:8123".parse().unwrap()),
"http://localhost:8123/?query=SELECT%201"
);
assert_eq!(
get_healthcheck_uri(&"http://localhost:8123/".parse().unwrap()),
"http://localhost:8123/?query=SELECT%201"
);
assert_eq!(
get_healthcheck_uri(&"http://localhost:8123/path/".parse().unwrap()),
"http://localhost:8123/path/?query=SELECT%201"
);
}
}

0 comments on commit 7a7b53b

Please sign in to comment.