From d0556da7ecb10c7799102b1a50e1d734d96611f4 Mon Sep 17 00:00:00 2001 From: hatoo Date: Sat, 22 Feb 2025 15:25:31 +0900 Subject: [PATCH 1/3] Edition 2024 --- Cargo.toml | 4 ++-- Dockerfile | 2 +- tests/tests.rs | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d92cf048..9dd86b7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,14 +7,14 @@ categories = [ "development-tools::profiling", ] description = "Ohayou(おはよう), HTTP load generator, inspired by rakyll/hey with tui animation." -edition = "2021" +edition = "2024" keywords = ["cli", "load-testing", "performance", "http"] license = "MIT" name = "oha" readme = "README.md" repository = "https://github.com/hatoo/oha" version = "1.8.0" -rust-version = "1.77" +rust-version = "1.85" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/Dockerfile b/Dockerfile index 85965f6e..6337f8b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG RUST_VERSION=1.79 +ARG RUST_VERSION=1.85 FROM docker.io/library/rust:${RUST_VERSION} AS build WORKDIR /app COPY . /app diff --git a/tests/tests.rs b/tests/tests.rs index aa1d183c..46951d18 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -5,18 +5,18 @@ use std::{ future::Future, io::Write, net::{Ipv6Addr, SocketAddr}, - sync::{atomic::AtomicU16, Arc}, + sync::{Arc, atomic::AtomicU16}, }; use assert_cmd::Command; -use axum::{extract::Path, response::Redirect, routing::get, Router}; +use axum::{Router, extract::Path, response::Redirect, routing::get}; use http::{HeaderMap, Request, Response}; use http_body_util::BodyExt; use http_mitm_proxy::MitmProxy; use hyper::{ body::{Body, Incoming}, http, - service::{service_fn, HttpService}, + service::{HttpService, service_fn}, }; use hyper_util::rt::{TokioExecutor, TokioIo}; @@ -974,8 +974,8 @@ async fn test_json_schema() { } } -fn setup_mtls_server( - dir: &std::path::Path, +fn setup_mtls_server<'a>( + dir: std::path::PathBuf, ) -> (u16, impl Future>) { let port = PORT.fetch_add(1, std::sync::atomic::Ordering::Relaxed); let addr = SocketAddr::from(([127, 0, 0, 1], port)); @@ -1041,7 +1041,7 @@ fn setup_mtls_server( #[tokio::test] async fn test_mtls() { let dir = tempfile::tempdir().unwrap(); - let (port, server) = setup_mtls_server(dir.path()); + let (port, server) = setup_mtls_server(dir.path().to_path_buf()); tokio::spawn(server); From 6d4acbfd0961a0355f354f74ce3b0db9d932cc53 Mon Sep 17 00:00:00 2001 From: hatoo Date: Sat, 22 Feb 2025 15:27:56 +0900 Subject: [PATCH 2/3] cargo fmt --- src/aws_auth.rs | 2 +- src/client.rs | 10 +++++----- src/lib.rs | 2 +- src/main.rs | 2 +- src/monitor.rs | 4 ++-- src/result_data.rs | 2 +- src/url_generator.rs | 10 ++++++---- 7 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/aws_auth.rs b/src/aws_auth.rs index aa37c6b6..725d54ce 100644 --- a/src/aws_auth.rs +++ b/src/aws_auth.rs @@ -3,8 +3,8 @@ use anyhow::Result; use bytes::Bytes; use hyper::{ - header::{self, HeaderName}, HeaderMap, + header::{self, HeaderName}, }; use url::Url; diff --git a/src/client.rs b/src/client.rs index 4f5c42c2..9e51dc43 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1,14 +1,14 @@ use bytes::Bytes; use http_body_util::{BodyExt, Full}; -use hyper::{http, Method}; +use hyper::{Method, http}; use hyper_util::rt::{TokioExecutor, TokioIo}; use rand::prelude::*; use std::{ borrow::Cow, io::Write, sync::{ - atomic::{AtomicBool, Ordering::Relaxed}, Arc, + atomic::{AtomicBool, Ordering::Relaxed}, }, time::Instant, }; @@ -20,10 +20,10 @@ use tokio::{ use url::{ParseError, Url}; use crate::{ + ConnectToEntry, aws_auth::AwsSignatureConfig, pcg64si::Pcg64Si, url_generator::{UrlGenerator, UrlGeneratorError}, - ConnectToEntry, }; type SendRequestHttp1 = hyper::client::conn::http1::SendRequest>; @@ -1868,8 +1868,8 @@ pub mod fast { use crate::{ client::{ - is_cancel_error, is_hyper_error, set_connection_time, setup_http2, ClientError, - ClientStateHttp1, + ClientError, ClientStateHttp1, is_cancel_error, is_hyper_error, set_connection_time, + setup_http2, }, result_data::ResultData, }; diff --git a/src/lib.rs b/src/lib.rs index 8c84b3e2..2504c7f0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,11 +5,11 @@ use crossterm::tty::IsTty; use hickory_resolver::config::{ResolverConfig, ResolverOpts}; use humantime::Duration; use hyper::{ + HeaderMap, http::{ self, header::{HeaderName, HeaderValue}, }, - HeaderMap, }; use printer::{PrintConfig, PrintMode}; use rand_regex::Regex; diff --git a/src/main.rs b/src/main.rs index 54f546fb..04cf1145 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use clap::Parser; -use oha::{run, Opts}; +use oha::{Opts, run}; fn main() { let num_workers_threads = std::env::var("TOKIO_WORKER_THREADS") diff --git a/src/monitor.rs b/src/monitor.rs index b046267b..cb268d0d 100644 --- a/src/monitor.rs +++ b/src/monitor.rs @@ -1,17 +1,17 @@ use byte_unit::Byte; use crossterm::{ - event::{Event, KeyCode, KeyEvent, KeyModifiers}, ExecutableCommand, + event::{Event, KeyCode, KeyEvent, KeyModifiers}, }; use hyper::http; use ratatui::crossterm; use ratatui::{ + Terminal, backend::CrosstermBackend, layout::{Constraint, Direction, Layout}, style::{Color, Style}, text::{Line, Span}, widgets::{BarChart, Block, Borders, Gauge, Paragraph}, - Terminal, }; use std::{collections::BTreeMap, io}; diff --git a/src/result_data.rs b/src/result_data.rs index c82b7918..fc9cbc2b 100644 --- a/src/result_data.rs +++ b/src/result_data.rs @@ -3,7 +3,7 @@ use std::{ time::{Duration, Instant}, }; -use average::{concatenate, Estimate, Max, Mean, Min}; +use average::{Estimate, Max, Mean, Min, concatenate}; use hyper::StatusCode; use crate::{ diff --git a/src/url_generator.rs b/src/url_generator.rs index 628dfd1d..9aeae41c 100644 --- a/src/url_generator.rs +++ b/src/url_generator.rs @@ -103,10 +103,12 @@ mod tests { ); let url = url_generator.generate(&mut rand::rng()).unwrap(); assert_eq!(url.host(), Some(Host::Ipv4(Ipv4Addr::new(127, 0, 0, 1)))); - assert!(Regex::new(path_regex) - .unwrap() - .captures(url.path()) - .is_some()); + assert!( + Regex::new(path_regex) + .unwrap() + .captures(url.path()) + .is_some() + ); } #[test] From 79bcfb6a33e1926bd907376d24e0008ae0f16345 Mon Sep 17 00:00:00 2001 From: hatoo Date: Sat, 22 Feb 2025 15:31:55 +0900 Subject: [PATCH 3/3] oops --- tests/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests.rs b/tests/tests.rs index 46951d18..a20a47b3 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -974,7 +974,7 @@ async fn test_json_schema() { } } -fn setup_mtls_server<'a>( +fn setup_mtls_server( dir: std::path::PathBuf, ) -> (u16, impl Future>) { let port = PORT.fetch_add(1, std::sync::atomic::Ordering::Relaxed);