-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add flags to control telemetry behaviors #25849
Changes from all commits
c551e1a
725e0e4
d640a93
3328494
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,14 @@ use std::{ | |
|
||
use crate::{ConfigProvider, TestServer}; | ||
use assert_cmd::cargo::CommandCargoExt; | ||
use assert_cmd::Command as AssertCmd; | ||
use observability_deps::tracing::debug; | ||
use pretty_assertions::assert_eq; | ||
use serde_json::{json, Value}; | ||
use test_helpers::assert_contains; | ||
use test_helpers::tempfile::NamedTempFile; | ||
#[cfg(feature = "system-py")] | ||
use test_helpers::tempfile::TempDir; | ||
use test_helpers::{assert_contains, assert_not_contains}; | ||
|
||
const WRITE_REPORTS_PLUGIN_CODE: &str = r#" | ||
def process_writes(influxdb3_local, table_batches, args=None): | ||
|
@@ -107,6 +108,121 @@ fn create_plugin_file(code: &str) -> NamedTempFile { | |
file | ||
} | ||
|
||
#[test_log::test(tokio::test)] | ||
async fn test_telemetry_disabled_with_debug_msg() { | ||
let serve_args = &[ | ||
"serve", | ||
"--writer-id", | ||
"the-best-writer", | ||
"--object-store", | ||
"memory", | ||
]; | ||
|
||
let expected_disabled: &str = "Initializing TelemetryStore with upload disabled."; | ||
|
||
// validate we get a debug message indicating upload disabled | ||
let output = AssertCmd::cargo_bin("influxdb3") | ||
.unwrap() | ||
.args(serve_args) | ||
.arg("-vv") | ||
.arg("--disable-telemetry-upload") | ||
.timeout(std::time::Duration::from_millis(500)) | ||
.assert() | ||
.failure() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I added the
I did look through the
Yeah, I see the it has the mechanism built in to kill the process after the test without timeout using the To be clear, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did think the test happens after killing the process as well with the timeout - just wasn't sure if there was easy wins in extending |
||
.get_output() | ||
.stdout | ||
.clone(); | ||
let output = String::from_utf8(output).expect("must be able to convert output to String"); | ||
assert_contains!(output, expected_disabled); | ||
} | ||
|
||
#[test_log::test(tokio::test)] | ||
async fn test_telemetry_disabled() { | ||
let serve_args = &[ | ||
"serve", | ||
"--writer-id", | ||
"the-best-writer", | ||
"--object-store", | ||
"memory", | ||
]; | ||
|
||
let expected_disabled: &str = "Initializing TelemetryStore with upload disabled."; | ||
// validate no message when debug output disabled | ||
let output = AssertCmd::cargo_bin("influxdb3") | ||
.unwrap() | ||
.args(serve_args) | ||
.arg("-v") | ||
.arg("--disable-telemetry-upload") | ||
.timeout(std::time::Duration::from_millis(500)) | ||
.assert() | ||
.failure() | ||
.get_output() | ||
.stdout | ||
.clone(); | ||
let output = String::from_utf8(output).expect("must be able to convert output to String"); | ||
assert_not_contains!(output, expected_disabled); | ||
} | ||
|
||
#[test_log::test(tokio::test)] | ||
async fn test_telemetry_enabled_with_debug_msg() { | ||
let serve_args = &[ | ||
"serve", | ||
"--writer-id", | ||
"the-best-writer", | ||
"--object-store", | ||
"memory", | ||
]; | ||
|
||
let expected_enabled: &str = | ||
"Initializing TelemetryStore with upload enabled for http://localhost:9999."; | ||
|
||
// validate debug output shows which endpoint we are hitting when telemetry enabled | ||
let output = AssertCmd::cargo_bin("influxdb3") | ||
.unwrap() | ||
.args(serve_args) | ||
.arg("-vv") | ||
.arg("--telemetry-endpoint") | ||
.arg("http://localhost:9999") | ||
.timeout(std::time::Duration::from_millis(500)) | ||
.assert() | ||
.failure() | ||
.get_output() | ||
.stdout | ||
.clone(); | ||
let output = String::from_utf8(output).expect("must be able to convert output to String"); | ||
assert_contains!(output, expected_enabled); | ||
} | ||
|
||
#[test_log::test(tokio::test)] | ||
async fn test_telementry_enabled() { | ||
let serve_args = &[ | ||
"serve", | ||
"--writer-id", | ||
"the-best-writer", | ||
"--object-store", | ||
"memory", | ||
]; | ||
|
||
let expected_enabled: &str = | ||
"Initializing TelemetryStore with upload enabled for http://localhost:9999."; | ||
|
||
// validate no telemetry endpoint reported when debug output not enabled | ||
let output = AssertCmd::cargo_bin("influxdb3") | ||
.unwrap() | ||
.args(serve_args) | ||
.arg("-v") | ||
.arg("--telemetry-endpoint") | ||
.arg("http://localhost:9999") | ||
.timeout(std::time::Duration::from_millis(500)) | ||
.assert() | ||
.failure() | ||
.get_output() | ||
.stdout | ||
.clone(); | ||
let output = String::from_utf8(output).expect("must be able to convert output to String"); | ||
assert_not_contains!(output, expected_enabled); | ||
} | ||
|
||
#[test_log::test(tokio::test)] | ||
async fn test_show_databases() { | ||
let server = TestServer::spawn().await; | ||
|
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.
Thanks!