mirror of
https://github.com/NLnetLabs/krill.git
synced 2026-09-28 12:24:52 +02:00
Initially, this PR was intended to more clearly separate code between Krill “business logic” – now bundled in a KrillManager –, and the HTTP server code that serves the API. The former now lives in the server module, the latter in the daemon module together with all the code to spin up a Krill daemon driving the HTTP server. However, along the way it turned into a complete redesign of how the HTTP server code works. Request handling has been split into three stages that forces implementers to check for permissions (or actively choose to not check), and read the body (or check that there isn’t one). Dispatching of the request has been restructured which should make it easier to follow what goes on where. This PR increases the minimum Rust version to 1.81.
65 lines
1.7 KiB
Rust
65 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).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, but found {}",
|
|
publishers_expected, publishers_found
|
|
);
|
|
}
|
|
|