Skip to content

Commit

Permalink
enhancement(host_metrics source): Add unit test with assert_source_co…
Browse files Browse the repository at this point in the history
…mpliance test helper (#14103)

<!--
**Your PR title must conform to the conventional commit spec!**

  <type>(<scope>)!: <description>

  * `type` = chore, enhancement, feat, fix, docs
  * `!` = OPTIONAL: signals a breaking change
  * `scope` = Optional when `type` is "chore" or "docs", available scopes https://github.com/vectordotdev/vector/blob/master/.github/semantic.yml#L20
  * `description` = short description of the change

Examples:

  * enhancement(file source): Add `sort` option to sort discovered files
  * feat(new source): Initial `statsd` source
  * fix(file source): Fix a bug discovering new files
  * chore(external docs): Clarify `batch_size` option
-->

part of #14055

part of #13995.
  • Loading branch information
neuronull authored Aug 26, 2022
1 parent e2ed87c commit a00a3f9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/sources/host_metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,8 @@ impl From<PatternWrapper> for String {

#[cfg(test)]
pub(self) mod tests {
use std::{collections::HashSet, future::Future};
use crate::test_util::components::{run_and_assert_source_compliance, SOURCE_TAGS};
use std::{collections::HashSet, future::Future, time::Duration};

use super::*;

Expand Down Expand Up @@ -743,4 +744,17 @@ pub(self) mod tests {
);
}
}

#[tokio::test]
async fn source_compliance() {
let config = HostMetricsConfig {
scrape_interval_secs: 1.0,
..Default::default()
};

let events =
run_and_assert_source_compliance(config, Duration::from_secs(2), &SOURCE_TAGS).await;

assert!(!events.is_empty());
}
}

0 comments on commit a00a3f9

Please sign in to comment.