mirror of
https://github.com/NLnetLabs/krill.git
synced 2026-09-13 13:07:40 +02:00
This PR refactors how requests are processed in Krill. It creates a clear distinction between the HTTP server running async on a Tokio runtime and the core of Krill running as regular sync code on a thread pool. This means that those portions of the core that were previously async, notable the HTTP requests to remote parents and publishers, end up blocking a thread now. For most things this should be fine. For potentially long-running tasks, we have a separate thread pool so they won’t block all of Krill.
64 lines
1.7 KiB
Rust
64 lines
1.7 KiB
Rust
//! Perform functional tests on a Krill instance, using the API
|
|
|
|
use krill::cli::client::KrillClient;
|
|
use krill::config::Benchmark;
|
|
use log::LevelFilter;
|
|
|
|
mod common;
|
|
|
|
#[tokio::test(flavor = "multi_thread")]
|
|
async fn benchmark() {
|
|
let (mut config, _dir) = common::TestConfig::mem_storage()
|
|
.enable_testbed()
|
|
.enable_second_signer()
|
|
.finalize();
|
|
|
|
let cas = 10;
|
|
let ca_roas = 10;
|
|
config.benchmark = Some(Benchmark { cas, ca_roas });
|
|
config.log_level = LevelFilter::Info;
|
|
let server = common::KrillServer::start_with_config(config, None).await;
|
|
|
|
wait_for_nr_cas_under_testbed(server.client(), cas).await;
|
|
// We expect all CAs, plus the testbed and the ta as publishers
|
|
wait_for_nr_cas_under_publication_server(server.client(), cas + 2).await;
|
|
|
|
server.abort().await;
|
|
}
|
|
|
|
async fn wait_for_nr_cas_under_testbed(
|
|
client: &KrillClient,
|
|
nr: usize
|
|
) {
|
|
let handle = common::ca_handle("testbed");
|
|
for _ in 0..300 {
|
|
if client.ca_details(&handle).await.unwrap().children.len() == nr {
|
|
return;
|
|
}
|
|
common::sleep_seconds(1).await
|
|
}
|
|
panic!("not all CAs appeared in time");
|
|
}
|
|
|
|
|
|
async fn wait_for_nr_cas_under_publication_server(
|
|
client: &KrillClient,
|
|
publishers_expected: usize,
|
|
) {
|
|
let mut publishers_found = client.publishers_list().await.unwrap()
|
|
.publishers.len();
|
|
for _ in 0..300 {
|
|
if publishers_found == publishers_expected {
|
|
return;
|
|
}
|
|
common::sleep_seconds(1).await;
|
|
publishers_found = client.publishers_list().await.unwrap()
|
|
.publishers.len();
|
|
}
|
|
|
|
panic!(
|
|
"Expected {publishers_expected} publishers, but found {publishers_found}"
|
|
);
|
|
}
|
|
|