Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aggregator: fix flakiness of tests that uses the snapshotter and simplify http server tests #2243

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mithril-aggregator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-aggregator"
version = "0.6.17"
version = "0.6.18"
description = "A Mithril Aggregator server"
authors = { workspace = true }
edition = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ mod handlers {
#[cfg(test)]
mod tests {
use super::*;
use crate::{
http_server::SERVER_BASE_PATH, initialize_dependencies, services::MockMessageService,
};
use crate::{initialize_dependencies, services::MockMessageService};
use mithril_common::messages::{
CardanoDatabaseDigestListItemMessage, CardanoDatabaseSnapshotListItemMessage,
CardanoDatabaseSnapshotMessage,
Expand All @@ -194,9 +192,7 @@ mod tests {
.allow_headers(vec!["content-type"])
.allow_methods(vec![Method::GET, Method::POST, Method::OPTIONS]);

warp::any()
.and(warp::path(SERVER_BASE_PATH))
.and(routes(&state).with(cors))
warp::any().and(routes(&state).with(cors))
}

#[tokio::test]
Expand All @@ -214,7 +210,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -247,7 +243,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -278,7 +274,7 @@ mod tests {

request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(
dependency_manager.clone(),
)))
Expand Down Expand Up @@ -308,7 +304,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -342,7 +338,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -375,7 +371,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -408,7 +404,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -441,7 +437,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ pub mod tests {
test_utils::apispec::APISpec,
};

use crate::{
http_server::SERVER_BASE_PATH, initialize_dependencies, services::MockMessageService,
};
use crate::{initialize_dependencies, services::MockMessageService};

use super::*;

Expand All @@ -173,9 +171,7 @@ pub mod tests {
.allow_headers(vec!["content-type"])
.allow_methods(vec![Method::GET, Method::POST, Method::OPTIONS]);

warp::any()
.and(warp::path(SERVER_BASE_PATH))
.and(routes(&state).with(cors))
warp::any().and(routes(&state).with(cors))
}

#[tokio::test]
Expand All @@ -194,7 +190,7 @@ pub mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -227,7 +223,7 @@ pub mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -259,7 +255,7 @@ pub mod tests {

request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(
dependency_manager.clone(),
)))
Expand All @@ -279,7 +275,7 @@ pub mod tests {

request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{base_path}/123"))
.path(&format!("{base_path}/123"))
.reply(&setup_router(RouterState::new_with_dummy_config(
dependency_manager.clone(),
)))
Expand Down Expand Up @@ -311,7 +307,7 @@ pub mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -344,7 +340,7 @@ pub mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -377,7 +373,7 @@ pub mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -411,7 +407,7 @@ pub mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{base_path}/123"))
.path(&format!("{base_path}/123"))
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -440,7 +436,7 @@ pub mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{base_path}/invalid-epoch"))
.path(&format!("{base_path}/invalid-epoch"))
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -473,7 +469,7 @@ pub mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{base_path}/123"))
.path(&format!("{base_path}/123"))
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -506,7 +502,7 @@ pub mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{base_path}/123"))
.path(&format!("{base_path}/123"))
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ pub mod tests {
use mithril_common::test_utils::apispec::APISpec;
use mithril_persistence::sqlite::HydrationError;

use crate::{
http_server::SERVER_BASE_PATH, initialize_dependencies, services::MockMessageService,
};
use crate::{initialize_dependencies, services::MockMessageService};

use super::*;

Expand All @@ -118,9 +116,7 @@ pub mod tests {
.allow_headers(vec!["content-type"])
.allow_methods(vec![Method::GET, Method::POST, Method::OPTIONS]);

warp::any()
.and(warp::path(SERVER_BASE_PATH))
.and(routes(&state).with(cors))
warp::any().and(routes(&state).with(cors))
}

#[tokio::test]
Expand All @@ -138,7 +134,7 @@ pub mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -171,7 +167,7 @@ pub mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -202,7 +198,7 @@ pub mod tests {

request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(
dependency_manager.clone(),
)))
Expand Down Expand Up @@ -232,7 +228,7 @@ pub mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -265,7 +261,7 @@ pub mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -298,7 +294,7 @@ pub mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ pub mod tests {
use mithril_common::test_utils::apispec::APISpec;
use mithril_persistence::sqlite::HydrationError;

use crate::{
http_server::SERVER_BASE_PATH, initialize_dependencies, services::MockMessageService,
};
use crate::{initialize_dependencies, services::MockMessageService};

use super::*;

Expand All @@ -118,9 +116,7 @@ pub mod tests {
.allow_headers(vec!["content-type"])
.allow_methods(vec![Method::GET, Method::POST, Method::OPTIONS]);

warp::any()
.and(warp::path(SERVER_BASE_PATH))
.and(routes(&state).with(cors))
warp::any().and(routes(&state).with(cors))
}

#[tokio::test]
Expand All @@ -138,7 +134,7 @@ pub mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -171,7 +167,7 @@ pub mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -202,7 +198,7 @@ pub mod tests {

request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(
dependency_manager.clone(),
)))
Expand Down Expand Up @@ -232,7 +228,7 @@ pub mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -265,7 +261,7 @@ pub mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down Expand Up @@ -298,7 +294,7 @@ pub mod tests {

let response = request()
.method(method)
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.path(path)
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
dependency_manager,
))))
Expand Down
Loading
Loading