Skip to content

Commit

Permalink
Merge pull request #610 from jeremyandrews/update
Browse files Browse the repository at this point in the history
Update Dependencies and Fix Clippy Warnings
  • Loading branch information
jeremyandrews authored Feb 25, 2025
2 parents 1a8280e + dc3a226 commit f0d4cf6
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 85 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## 0.17.3-dev
## 0.18.0
- update all dependencies
- [#565](https://github.com/tag1consulting/goose/pull/565) add `--accept-invalid-certs` to skip validation of https certificates
- [#568](https://github.com/tag1consulting/goose/pull/568) don't panic when truncating non utf-8 string
- [#574](https://github.com/tag1consulting/goose/pull/574) update [`http`](https://docs.rs/http), [`itertools`](https://docs.rs/itertools) [`nix`](https://docs.rs/nix), [`rustls`](https://docs.rs/rustls/), and [`serial_test`](https://docs.rs/serial_test)
Expand Down
24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "goose"
version = "0.17.3-dev"
version = "0.18.0"
authors = ["Jeremy Andrews <[email protected]>"]
edition = "2018"
description = "A load testing framework inspired by Locust."
Expand All @@ -15,16 +15,16 @@ license = "Apache-2.0"
async-trait = "0.1"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
ctrlc = "3"
downcast-rs = "1.2"
downcast-rs = "2.0"
flume = "0.11"
futures = "0.3"
gumdrop = "0.8"
http = "1.1"
itertools = "0.12"
itertools = "0.14"
lazy_static = "1.4"
log = "0.4"
num-format = "0.4"
rand = "0.8"
rand = "0.9"
regex = "1"
reqwest = { version = "0.12", default-features = false, features = [
"cookies",
Expand All @@ -34,8 +34,8 @@ reqwest = { version = "0.12", default-features = false, features = [
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
simplelog = "0.12"
strum = "0.26"
strum_macros = "0.26"
strum = "0.27"
strum_macros = "0.27"
tokio = { version = "1", features = [
"fs",
"io-util",
Expand All @@ -45,8 +45,8 @@ tokio = { version = "1", features = [
"time",
"sync",
] }
tokio-tungstenite = "0.21"
tungstenite = "0.21"
tokio-tungstenite = "0.26"
tungstenite = "0.26"
url = "2"

[features]
Expand All @@ -55,8 +55,8 @@ rustls-tls = ["reqwest/rustls-tls", "tokio-tungstenite/rustls"]
gaggle = []

[dev-dependencies]
httpmock = "0.6"
httpmock = "0.7"
native-tls = "0.2"
nix = { version = "0.27", features = ["signal"] }
rustls = "0.22"
serial_test = "2.0"
nix = { version = "0.29", features = ["signal"] }
rustls = "0.23"
serial_test = "3.2"
8 changes: 4 additions & 4 deletions examples/drupal_memcache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ async fn drupal_memcache_front_page(user: &mut GooseUser) -> TransactionResult {

/// View a node from 1 to 10,000, created by preptest.sh.
async fn drupal_memcache_node_page(user: &mut GooseUser) -> TransactionResult {
let nid = rand::thread_rng().gen_range(1..10_000);
let nid = rand::rng().random_range(1..10_000);
let _goose = user.get(format!("/node/{}", &nid).as_str()).await?;

Ok(())
}

/// View a profile from 2 to 5,001, created by preptest.sh.
async fn drupal_memcache_profile_page(user: &mut GooseUser) -> TransactionResult {
let uid = rand::thread_rng().gen_range(2..5_001);
let uid = rand::rng().random_range(2..5_001);
let _goose = user.get(format!("/user/{}", &uid).as_str()).await?;

Ok(())
Expand Down Expand Up @@ -175,7 +175,7 @@ async fn drupal_memcache_login(user: &mut GooseUser) -> TransactionResult {
};

// Log the user in.
let uid: usize = rand::thread_rng().gen_range(3..5_002);
let uid: usize = rand::rng().random_range(3..5_002);
let username = format!("user{}", uid);
let params = [
("name", username.as_str()),
Expand Down Expand Up @@ -217,7 +217,7 @@ async fn drupal_memcache_login(user: &mut GooseUser) -> TransactionResult {

/// Post a comment.
async fn drupal_memcache_post_comment(user: &mut GooseUser) -> TransactionResult {
let nid: i32 = rand::thread_rng().gen_range(1..10_000);
let nid: i32 = rand::rng().random_range(1..10_000);
let node_path = format!("node/{}", &nid);
let comment_path = format!("/comment/reply/{}", &nid);

Expand Down
4 changes: 2 additions & 2 deletions examples/umami/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use goose::prelude::*;

use crate::common;

use rand::seq::SliceRandom;
use rand::prelude::*;
use std::env;

/// Log into the website.
Expand Down Expand Up @@ -110,7 +110,7 @@ pub async fn log_in(user: &mut GooseUser) -> TransactionResult {
pub async fn edit_article(user: &mut GooseUser) -> TransactionResult {
// First, load a random article.
let nodes = common::get_nodes(&common::ContentType::Article);
let article = nodes.choose(&mut rand::thread_rng());
let article = nodes.choose(&mut rand::rng());
let goose = user.get(article.unwrap().url_en).await?;
common::validate_and_load_static_assets(user, goose, article.unwrap().title_en).await?;

Expand Down
9 changes: 4 additions & 5 deletions examples/umami/common.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use goose::goose::GooseResponse;
use goose::prelude::*;

use rand::prelude::IteratorRandom;
use rand::seq::SliceRandom;
use rand::prelude::*;
use regex::Regex;

/// The Umami website defines three content types.
Expand Down Expand Up @@ -392,18 +391,18 @@ pub fn random_words(count: usize, english: bool) -> Vec<String> {
ContentType::Recipe,
ContentType::Recipe,
];
let content_type = content_types.choose(&mut rand::thread_rng());
let content_type = content_types.choose(&mut rand::rng());
// Then randomly select a node of this content type.
let nodes = get_nodes(content_type.unwrap());
let page = nodes.choose(&mut rand::thread_rng());
let page = nodes.choose(&mut rand::rng());
// Randomly select a word from the title to use in our search.
let title = if english {
page.unwrap().title_en
} else {
page.unwrap().title_es
};
let words = title.split_whitespace();
let word = words.choose(&mut rand::thread_rng()).unwrap();
let word = words.choose(&mut rand::rng()).unwrap();
// Remove ' to avoid encoding/decoding issues when validating later.
let cleaned_word = word.replace("&#039;", "");
random_words.push(cleaned_word.to_string());
Expand Down
14 changes: 7 additions & 7 deletions examples/umami/english.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use goose::prelude::*;

use crate::common;

use rand::seq::SliceRandom;
use rand::prelude::*;

/// Load the front page in English and all static assets found on the page.
pub async fn front_page_en(user: &mut GooseUser) -> TransactionResult {
Expand All @@ -23,7 +23,7 @@ pub async fn recipe_listing_en(user: &mut GooseUser) -> TransactionResult {
/// Load a random recipe in English and all static assets found on the page.
pub async fn recipe_en(user: &mut GooseUser) -> TransactionResult {
let nodes = common::get_nodes(&common::ContentType::Recipe);
let recipe = nodes.choose(&mut rand::thread_rng());
let recipe = nodes.choose(&mut rand::rng());
let goose = user.get(recipe.unwrap().url_en).await?;
common::validate_and_load_static_assets(user, goose, recipe.unwrap().title_en).await?;

Expand All @@ -41,7 +41,7 @@ pub async fn article_listing_en(user: &mut GooseUser) -> TransactionResult {
/// Load a random article in English and all static assets found on the page.
pub async fn article_en(user: &mut GooseUser) -> TransactionResult {
let nodes = common::get_nodes(&common::ContentType::Article);
let article = nodes.choose(&mut rand::thread_rng());
let article = nodes.choose(&mut rand::rng());
let goose = user.get(article.unwrap().url_en).await?;
common::validate_and_load_static_assets(user, goose, article.unwrap().title_en).await?;

Expand All @@ -51,7 +51,7 @@ pub async fn article_en(user: &mut GooseUser) -> TransactionResult {
/// Load a random basic page in English and all static assets found on the page.
pub async fn basic_page_en(user: &mut GooseUser) -> TransactionResult {
let nodes = common::get_nodes(&common::ContentType::BasicPage);
let page = nodes.choose(&mut rand::thread_rng());
let page = nodes.choose(&mut rand::rng());
let goose = user.get(page.unwrap().url_en).await?;
common::validate_and_load_static_assets(user, goose, page.unwrap().title_en).await?;

Expand All @@ -66,10 +66,10 @@ pub async fn page_by_nid(user: &mut GooseUser) -> TransactionResult {
common::ContentType::BasicPage,
common::ContentType::Recipe,
];
let content_type = content_types.choose(&mut rand::thread_rng());
let content_type = content_types.choose(&mut rand::rng());
// Then randomly select a node of this content type.
let nodes = common::get_nodes(content_type.unwrap());
let page = nodes.choose(&mut rand::thread_rng());
let page = nodes.choose(&mut rand::rng());
// Load the page by nid instead of by URL.
let goose = user
.get(&("/node/".to_string() + &page.unwrap().nid.to_string()))
Expand All @@ -96,7 +96,7 @@ pub async fn search_en(user: &mut GooseUser) -> TransactionResult {
/// Load category listing by a random term in English and all static assets found on the page.
pub async fn term_listing_en(user: &mut GooseUser) -> TransactionResult {
let terms = common::get_terms();
let term = terms.choose(&mut rand::thread_rng());
let term = terms.choose(&mut rand::rng());
let goose = user.get(term.unwrap().url_en).await?;
common::validate_and_load_static_assets(user, goose, term.unwrap().title_en).await?;

Expand Down
10 changes: 5 additions & 5 deletions examples/umami/spanish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use goose::prelude::*;

use crate::common;

use rand::seq::SliceRandom;
use rand::prelude::*;

/// Load the front page in Spanish and all static assets found on the page.
pub async fn front_page_es(user: &mut GooseUser) -> TransactionResult {
Expand All @@ -23,7 +23,7 @@ pub async fn recipe_listing_es(user: &mut GooseUser) -> TransactionResult {
/// Load a random recipe in Spanish and all static assets found on the page.
pub async fn recipe_es(user: &mut GooseUser) -> TransactionResult {
let nodes = common::get_nodes(&common::ContentType::Recipe);
let recipe = nodes.choose(&mut rand::thread_rng());
let recipe = nodes.choose(&mut rand::rng());
let goose = user.get(recipe.unwrap().url_es).await?;
common::validate_and_load_static_assets(user, goose, recipe.unwrap().title_es).await?;

Expand All @@ -41,7 +41,7 @@ pub async fn article_listing_es(user: &mut GooseUser) -> TransactionResult {
/// Load a random article in Spanish and all static assets found on the page.
pub async fn article_es(user: &mut GooseUser) -> TransactionResult {
let nodes = common::get_nodes(&common::ContentType::Article);
let article = nodes.choose(&mut rand::thread_rng());
let article = nodes.choose(&mut rand::rng());
let goose = user.get(article.unwrap().url_es).await?;
common::validate_and_load_static_assets(user, goose, article.unwrap().title_es).await?;

Expand All @@ -51,7 +51,7 @@ pub async fn article_es(user: &mut GooseUser) -> TransactionResult {
/// Load a basic page in Spanish and all static assets found on the page.
pub async fn basic_page_es(user: &mut GooseUser) -> TransactionResult {
let nodes = common::get_nodes(&common::ContentType::BasicPage);
let page = nodes.choose(&mut rand::thread_rng());
let page = nodes.choose(&mut rand::rng());
let goose = user.get(page.unwrap().url_es).await?;
common::validate_and_load_static_assets(user, goose, page.unwrap().title_es).await?;

Expand All @@ -75,7 +75,7 @@ pub async fn search_es(user: &mut GooseUser) -> TransactionResult {
/// Load category listing by a random term in Spanish and all static assets found on the page.
pub async fn term_listing_es(user: &mut GooseUser) -> TransactionResult {
let terms = common::get_terms();
let term = terms.choose(&mut rand::thread_rng());
let term = terms.choose(&mut rand::rng());
let goose = user.get(term.unwrap().url_es).await?;
common::validate_and_load_static_assets(user, goose, term.unwrap().title_es).await?;

Expand Down
8 changes: 5 additions & 3 deletions src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,7 @@ trait ControllerExecuteCommand<T> {
// if the request was successful or not.
async fn write_to_socket(&self, socket: &mut T, response_message: Result<String, String>);
}

#[async_trait]
impl ControllerExecuteCommand<tokio::net::TcpStream> for ControllerState {
// Run the command received from a telnet Controller request.
Expand Down Expand Up @@ -1527,6 +1528,7 @@ impl ControllerExecuteCommand<tokio::net::TcpStream> for ControllerState {
};
}
}

#[async_trait]
impl ControllerExecuteCommand<ControllerWebSocketSender> for ControllerState {
// Run the command received from a WebSocket Controller request.
Expand All @@ -1546,7 +1548,7 @@ impl ControllerExecuteCommand<ControllerWebSocketSender> for ControllerState {
&& socket
.send(Message::Close(Some(tokio_tungstenite::tungstenite::protocol::CloseFrame {
code: tokio_tungstenite::tungstenite::protocol::frame::coding::CloseCode::Normal,
reason: std::borrow::Cow::Borrowed("exit"),
reason: "exit".into(),
})))
.await
.is_err()
Expand Down Expand Up @@ -1588,7 +1590,7 @@ impl ControllerExecuteCommand<ControllerWebSocketSender> for ControllerState {
&& socket
.send(Message::Close(Some(tokio_tungstenite::tungstenite::protocol::CloseFrame {
code: tokio_tungstenite::tungstenite::protocol::frame::coding::CloseCode::Normal,
reason: std::borrow::Cow::Borrowed("shutdown"),
reason: "shutdown".into(),
})))
.await
.is_err()
Expand Down Expand Up @@ -1624,7 +1626,7 @@ impl ControllerExecuteCommand<ControllerWebSocketSender> for ControllerState {
// Success is true if there is no error, false if there is an error.
success,
}) {
Ok(json) => json,
Ok(json) => json.into(),
Err(e) => {
warn!("failed to json encode response: {}", e);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/goose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,7 @@ impl GooseUser {
/// Ok(())
/// }
/// ```
pub async fn request<'a>(
pub async fn request(
&mut self,
mut request: GooseRequest<'_>,
) -> Result<GooseResponse, Box<TransactionError>> {
Expand Down
Loading

0 comments on commit f0d4cf6

Please sign in to comment.