Skip to content

Commit

Permalink
Fix flaky integ tests (#5348)
Browse files Browse the repository at this point in the history
* Pass TcpListener to quickwit_serve in integ tests

* Use static dispatch instead of enum

* Simplify cluster sandbox API

* Increase wait_for_split to match higher commit timeouts
  • Loading branch information
rdettai authored Sep 2, 2024
1 parent ab1a782 commit 34a162f
Show file tree
Hide file tree
Showing 18 changed files with 488 additions and 367 deletions.
2 changes: 2 additions & 0 deletions quickwit/quickwit-cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use quickwit_common::runtimes::RuntimesConfig;
use quickwit_common::uri::{Protocol, Uri};
use quickwit_config::service::QuickwitService;
use quickwit_config::NodeConfig;
use quickwit_serve::tcp_listener::DefaultTcpListenerResolver;
use quickwit_serve::{serve_quickwit, BuildInfo, EnvFilterReloadFn};
use quickwit_telemetry::payload::{QuickwitFeature, QuickwitTelemetryInfo, TelemetryEvent};
use tokio::signal;
Expand Down Expand Up @@ -114,6 +115,7 @@ impl RunCliCommand {
runtimes_config,
metastore_resolver,
storage_resolver,
DefaultTcpListenerResolver,
shutdown_signal,
env_filter_reload_fn,
)
Expand Down
10 changes: 9 additions & 1 deletion quickwit/quickwit-config/src/node_config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,17 @@ impl NodeConfig {
self.storage_configs.redact();
}

/// Creates a config with defaults suitable for testing.
///
/// Uses the default ports without ensuring that they are available.
#[cfg(any(test, feature = "testsuite"))]
pub fn for_test() -> Self {
serialize::node_config_for_test()
serialize::node_config_for_tests_from_ports(7280, 7281)
}

#[cfg(any(test, feature = "testsuite"))]
pub fn for_test_from_ports(rest_listen_port: u16, grpc_listen_port: u16) -> Self {
serialize::node_config_for_tests_from_ports(rest_listen_port, grpc_listen_port)
}
}

Expand Down
9 changes: 4 additions & 5 deletions quickwit/quickwit-config/src/node_config/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,13 @@ impl RestConfigBuilder {
}

#[cfg(any(test, feature = "testsuite"))]
pub fn node_config_for_test() -> NodeConfig {
use quickwit_common::net::find_available_tcp_port;

pub fn node_config_for_tests_from_ports(
rest_listen_port: u16,
grpc_listen_port: u16,
) -> NodeConfig {
let node_id = NodeId::new(default_node_id().unwrap());
let enabled_services = QuickwitService::supported_services();
let listen_address = Host::default();
let rest_listen_port = find_available_tcp_port().expect("OS should find an available port");
let rest_listen_addr = listen_address
.with_port(rest_listen_port)
.to_socket_addr()
Expand All @@ -426,7 +426,6 @@ pub fn node_config_for_test() -> NodeConfig {
.with_port(rest_listen_port)
.to_socket_addr()
.expect("default host should be an IP address");
let grpc_listen_port = find_available_tcp_port().expect("OS should find an available port");
let grpc_listen_addr = listen_address
.with_port(grpc_listen_port)
.to_socket_addr()
Expand Down
2 changes: 1 addition & 1 deletion quickwit/quickwit-integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ quickwit-metastore = { workspace = true, features = ["testsuite"] }
quickwit-opentelemetry = { workspace = true, features = ["testsuite"] }
quickwit-proto = { workspace = true, features = ["testsuite"] }
quickwit-rest-client = { workspace = true }
quickwit-serve = { workspace = true }
quickwit-serve = { workspace = true, features = ["testsuite"] }
quickwit-storage = { workspace = true, features = ["testsuite"] }
Loading

0 comments on commit 34a162f

Please sign in to comment.