Skip to content

Commit aa60520

Browse files
authored
feat(component validation): validate component_errors_total for sources (#17965)
closes #16841 This one already had some infrastructure in place with the `TestEvent::Modified` variant. Requires #17956 .
1 parent 52a8036 commit aa60520

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

src/components/validation/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ pub struct RunnerMetrics {
181181
pub sent_bytes_total: u64, // a reciprocal for received_bytes_total
182182
pub sent_event_bytes_total: u64,
183183
pub sent_events_total: u64,
184+
pub errors_total: u64,
184185
}
185186

186187
#[cfg(all(test, feature = "component-validation-tests"))]

src/components/validation/resources/http.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ fn spawn_input_http_server(
107107

108108
buffer.into_response()
109109
} else {
110-
// No outstanding events to send, so just provide an empty response.
111-
StatusCode::NO_CONTENT.into_response()
110+
// We'll send an empty 200 in the response since some
111+
// sources throw errors for anything other than a valid
112+
// response.
113+
StatusCode::OK.into_response()
112114
}
113115
}
114116
});

src/components/validation/runner/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ impl Runner {
282282
// send all inputs until we have no more, when we can't send more because we need to
283283
// drive output collection to allow forward progress to be made, etc.)
284284

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

544544
// account for failure case
545-
if !modified {
545+
if modified {
546+
input_runner_metrics.errors_total += 1;
547+
} else {
546548
input_runner_metrics.sent_events_total += 1;
547549

548550
input_runner_metrics.sent_event_bytes_total +=

src/components/validation/validators/component_spec/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl Validator for ComponentSpecValidator {
5050
TestCaseExpectation::Success => {
5151
if inputs.len() != outputs.len() {
5252
return Err(vec![format!(
53-
"Sent {} inputs but only received {} outputs.",
53+
"Sent {} inputs but received {} outputs.",
5454
inputs.len(),
5555
outputs.len()
5656
)]);

src/components/validation/validators/component_spec/sources.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub enum SourceMetricType {
1414
ReceivedBytesTotal,
1515
SentEventsTotal,
1616
SentEventBytesTotal,
17+
ErrorsTotal,
1718
}
1819

1920
impl SourceMetricType {
@@ -24,6 +25,7 @@ impl SourceMetricType {
2425
SourceMetricType::ReceivedBytesTotal => "component_received_bytes_total",
2526
SourceMetricType::SentEventsTotal => "component_sent_events_total",
2627
SourceMetricType::SentEventBytesTotal => "component_sent_event_bytes_total",
28+
SourceMetricType::ErrorsTotal => "component_errors_total",
2729
}
2830
}
2931
}
@@ -47,6 +49,7 @@ pub fn validate_sources(
4749
validate_component_received_bytes_total,
4850
validate_component_sent_events_total,
4951
validate_component_sent_event_bytes_total,
52+
validate_component_errors_total,
5053
];
5154

5255
for v in validations.iter() {
@@ -226,3 +229,14 @@ fn validate_component_sent_event_bytes_total(
226229
expected_bytes,
227230
)
228231
}
232+
233+
fn validate_component_errors_total(
234+
telemetry_events: &[Event],
235+
runner_metrics: &RunnerMetrics,
236+
) -> Result<Vec<String>, Vec<String>> {
237+
validate_events_total(
238+
telemetry_events,
239+
&SourceMetricType::ErrorsTotal,
240+
runner_metrics.errors_total,
241+
)
242+
}

0 commit comments

Comments
 (0)