From c744bebab8b57b86bc712d373c3642f4e7979eb5 Mon Sep 17 00:00:00 2001 From: Toby Lawrence Date: Mon, 4 Nov 2024 19:24:41 +0000 Subject: [PATCH] chore: update Rust to 1.82.0 --- .../ground-truth/src/analysis/metric.rs | 10 ------ .../ground-truth/src/analysis/mod.rs | 10 ------ bin/correctness/ground-truth/src/sync.rs | 9 ------ bin/correctness/millstone/src/config.rs | 24 -------------- bin/correctness/millstone/src/corpus.rs | 31 +++++-------------- rust-toolchain.toml | 2 +- 6 files changed, 9 insertions(+), 77 deletions(-) diff --git a/bin/correctness/ground-truth/src/analysis/metric.rs b/bin/correctness/ground-truth/src/analysis/metric.rs index a9853359..9bf3bd05 100644 --- a/bin/correctness/ground-truth/src/analysis/metric.rs +++ b/bin/correctness/ground-truth/src/analysis/metric.rs @@ -30,11 +30,6 @@ impl NormalizedMetricContext { pub fn name(&self) -> &str { &self.name } - - /// Returns the tags of the metric. - pub fn tags(&self) -> &[String] { - &self.tags - } } impl fmt::Display for NormalizedMetricContext { @@ -176,11 +171,6 @@ impl NormalizedMetrics { Ok(Self { metrics }) } - /// Returns `true` if the set of metrics is empty. - pub fn is_empty(&self) -> bool { - self.metrics.is_empty() - } - /// Returns the number of metrics in the set. pub fn len(&self) -> usize { self.metrics.len() diff --git a/bin/correctness/ground-truth/src/analysis/mod.rs b/bin/correctness/ground-truth/src/analysis/mod.rs index 892b7128..b1626811 100644 --- a/bin/correctness/ground-truth/src/analysis/mod.rs +++ b/bin/correctness/ground-truth/src/analysis/mod.rs @@ -25,16 +25,6 @@ impl RawTestResults { } } - /// Returns the raw metrics received from DogStatsD. - pub fn dsd_metrics(&self) -> &[Metric] { - &self.dsd_metrics - } - - /// Returns the raw metrics received from Agent Data Plane. - pub fn adp_metrics(&self) -> &[Metric] { - &self.adp_metrics - } - /// Analyzes the raw metrics from DogStatsD and Agent Data Plane, comparing them to one another. /// /// # Errors diff --git a/bin/correctness/ground-truth/src/sync.rs b/bin/correctness/ground-truth/src/sync.rs index a83414fd..eb600bb9 100644 --- a/bin/correctness/ground-truth/src/sync.rs +++ b/bin/correctness/ground-truth/src/sync.rs @@ -57,15 +57,6 @@ pub struct TaskToken { state: Arc, } -impl TaskToken { - /// Mark this task as done. - /// - /// If no other tasks are still running, this will wake up the waiting task, if any. - pub fn done(self) { - drop(self) - } -} - impl Drop for TaskToken { fn drop(&mut self) { // If we're the last worker attached to the coordinator, wake up the waiting task, if any. diff --git a/bin/correctness/millstone/src/config.rs b/bin/correctness/millstone/src/config.rs index 4e6871f7..b9d00ae3 100644 --- a/bin/correctness/millstone/src/config.rs +++ b/bin/correctness/millstone/src/config.rs @@ -4,7 +4,6 @@ use std::{ path::{Path, PathBuf}, }; -use bytesize::ByteSize; use saluki_error::{generic_error, ErrorContext as _, GenericError}; use serde::Deserialize; @@ -49,29 +48,6 @@ impl TryFrom for TargetAddress { } } -#[derive(Clone, Deserialize)] -#[serde(try_from = "ByteSize")] -pub struct NonZeroByteSize(ByteSize); - -impl NonZeroByteSize { - /// Returns the number of bytes represented by this value. - pub fn as_u64(&self) -> u64 { - self.0.as_u64() - } -} - -impl TryFrom for NonZeroByteSize { - type Error = String; - - fn try_from(value: ByteSize) -> Result { - if value.as_u64() == 0 { - Err("value must be non-zero".to_string()) - } else { - Ok(Self(value)) - } - } -} - #[derive(Clone, Deserialize)] pub enum Payload { /// DogStatsD-encoded metrics. diff --git a/bin/correctness/millstone/src/corpus.rs b/bin/correctness/millstone/src/corpus.rs index 4b267a12..57d26a5b 100644 --- a/bin/correctness/millstone/src/corpus.rs +++ b/bin/correctness/millstone/src/corpus.rs @@ -12,7 +12,6 @@ use crate::config::{Config, CorpusBlueprint, Payload, TargetAddress}; /// A generated test corpus. pub struct Corpus { payloads: Vec, - max_payload_size: usize, } impl Corpus { @@ -28,7 +27,7 @@ impl Corpus { let payload_name = blueprint.payload.name(); let rng = StdRng::from_seed(config.seed); - let (payloads, max_payload_size, total_size_bytes) = generate_payloads(rng, blueprint)?; + let (payloads, total_size_bytes) = generate_payloads(rng, blueprint)?; info!( "Generated test corpus with {} payloads ({}) in {} format.", @@ -36,15 +35,7 @@ impl Corpus { total_size_bytes.to_string_as(true), payload_name ); - Ok(Self { - payloads, - max_payload_size, - }) - } - - /// Returns the maximum size of any payload in the corpus, in bytes. - pub fn max_payload_size(&self) -> usize { - self.max_payload_size + Ok(Self { payloads }) } /// Consumes the corpus and returns the raw payloads. @@ -73,13 +64,13 @@ fn get_finalized_corpus_blueprint(config: &Config) -> Result(mut rng: R, blueprint: CorpusBlueprint) -> Result<(Vec, usize, ByteSize), GenericError> +fn generate_payloads(mut rng: R, blueprint: CorpusBlueprint) -> Result<(Vec, ByteSize), GenericError> where R: Rng, { let mut payloads = Vec::new(); - let max_payload_size = match blueprint.payload { + match blueprint.payload { Payload::DogStatsD(config) => { // We set our `max_bytes` to 8192, which is the default packet size for the Datadog Agent's DogStatsD // server. It _can_ be increased beyond that, but rarely is, and so that's the fixed size we're going to @@ -87,37 +78,31 @@ where let generator = DogStatsD::new(config, &mut rng)?; generate_payloads_inner(&generator, rng, &mut payloads, blueprint.size, 8192)? } - }; + } let total_size = payloads.iter().map(|p| p.len() as u64).sum(); if payloads.is_empty() { Err(generic_error!("No payloads were generated.")) } else { - Ok((payloads, max_payload_size, ByteSize(total_size))) + Ok((payloads, ByteSize(total_size))) } } fn generate_payloads_inner( generator: &G, mut rng: R, payloads: &mut Vec, size: NonZeroUsize, max_bytes: usize, -) -> Result +) -> Result<(), GenericError> where G: lading_payload::Serialize, R: Rng, { - let mut max_payload_size = 0; - for _ in 0..size.get() { let mut payload = BytesMut::new(); let mut payload_writer = (&mut payload).writer(); generator.to_bytes(&mut rng, max_bytes, &mut payload_writer)?; - if payload.len() > max_payload_size { - max_payload_size = payload.len(); - } - payloads.push(payload.freeze()); } - Ok(max_payload_size) + Ok(()) } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 4d2dee85..2e2b8c85 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.80.0" +channel = "1.82.0"