Skip to content
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(component validation): validate component_errors_total for sources #17965

Merged
merged 18 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/validation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ pub struct RunnerMetrics {
pub sent_bytes_total: u64, // a reciprocal for received_bytes_total
pub sent_event_bytes_total: u64,
pub sent_events_total: u64,
pub errors_total: u64,
}

#[cfg(all(test, feature = "component-validation-tests"))]
Expand Down
6 changes: 4 additions & 2 deletions src/components/validation/resources/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ fn spawn_input_http_server(

buffer.into_response()
} else {
// No outstanding events to send, so just provide an empty response.
StatusCode::NO_CONTENT.into_response()
// We'll send an empty 200 in the response since some
// sources throw errors for anything other than a valid
// response.
StatusCode::OK.into_response()
neuronull marked this conversation as resolved.
Show resolved Hide resolved
}
}
});
Expand Down
6 changes: 4 additions & 2 deletions src/components/validation/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl Runner {
// send all inputs until we have no more, when we can't send more because we need to
// drive output collection to allow forward progress to be made, etc.)

// We sleep for one second here because while we do wait for the component topology to
// We sleep for two seconds here because while we do wait for the component topology to
// mark itself as started, starting the topology does not necessarily mean that all
// component tasks are actually ready for input, etc.
//
Expand Down Expand Up @@ -542,7 +542,9 @@ fn spawn_input_driver(
};

// account for failure case
if !modified {
if modified {
input_runner_metrics.errors_total += 1;
} else {
input_runner_metrics.sent_events_total += 1;

input_runner_metrics.sent_event_bytes_total +=
Expand Down
2 changes: 1 addition & 1 deletion src/components/validation/validators/component_spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl Validator for ComponentSpecValidator {
TestCaseExpectation::Success => {
if inputs.len() != outputs.len() {
return Err(vec![format!(
"Sent {} inputs but only received {} outputs.",
"Sent {} inputs but received {} outputs.",
inputs.len(),
outputs.len()
)]);
Expand Down
14 changes: 14 additions & 0 deletions src/components/validation/validators/component_spec/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub enum SourceMetricType {
ReceivedBytesTotal,
SentEventsTotal,
SentEventBytesTotal,
ErrorsTotal,
}

impl SourceMetricType {
Expand All @@ -24,6 +25,7 @@ impl SourceMetricType {
SourceMetricType::ReceivedBytesTotal => "component_received_bytes_total",
SourceMetricType::SentEventsTotal => "component_sent_events_total",
SourceMetricType::SentEventBytesTotal => "component_sent_event_bytes_total",
SourceMetricType::ErrorsTotal => "component_errors_total",
}
}
}
Expand All @@ -47,6 +49,7 @@ pub fn validate_sources(
validate_component_received_bytes_total,
validate_component_sent_events_total,
validate_component_sent_event_bytes_total,
validate_component_errors_total,
];

for v in validations.iter() {
Expand Down Expand Up @@ -226,3 +229,14 @@ fn validate_component_sent_event_bytes_total(
expected_bytes,
)
}

fn validate_component_errors_total(
telemetry_events: &[Event],
runner_metrics: &RunnerMetrics,
) -> Result<Vec<String>, Vec<String>> {
validate_events_total(
telemetry_events,
&SourceMetricType::ErrorsTotal,
runner_metrics.errors_total,
)
}
Loading