mirror of
https://github.com/NLnetLabs/krill.git
synced 2026-09-10 11:37:40 +02:00
Update invocation of start_krill_daemon to match changed fn signature and fold fold duplicate start krill in test mode logic into one place.
This commit is contained in:
@@ -460,12 +460,7 @@ impl Config {
|
||||
}
|
||||
|
||||
pub fn test(data_dir: &PathBuf) -> Self {
|
||||
let config = Self::test_config(data_dir);
|
||||
if config.init_logging().is_err() {
|
||||
trace!("Logging already initialised");
|
||||
}
|
||||
config.verify().unwrap();
|
||||
config
|
||||
Self::test_config(data_dir)
|
||||
}
|
||||
|
||||
pub fn pubd_test(data_dir: &PathBuf) -> Self {
|
||||
|
||||
@@ -1673,7 +1673,7 @@ mod tests {
|
||||
|
||||
#[tokio::test]
|
||||
async fn start_krill_daemon() {
|
||||
let dir = test::start_krill().await;
|
||||
let dir = test::start_krill(None).await;
|
||||
let _ = fs::remove_dir_all(dir);
|
||||
}
|
||||
|
||||
|
||||
@@ -314,13 +314,13 @@ mod tests {
|
||||
|
||||
use tokio::time::delay_for;
|
||||
|
||||
use crate::commons::api::rrdp::PublicationDeltaError;
|
||||
use crate::commons::api::rrdp::{CurrentObjects, RrdpSession};
|
||||
use crate::commons::api::{ListElement, PublishDeltaBuilder};
|
||||
use crate::commons::crypto::{IdCert, IdCertBuilder};
|
||||
use crate::commons::util::file::CurrentFile;
|
||||
use crate::pubd::Publisher;
|
||||
use crate::test;
|
||||
use crate::{commons::api::rrdp::PublicationDeltaError, test::init_config};
|
||||
|
||||
use super::*;
|
||||
use crate::test::{https, rsync};
|
||||
@@ -343,6 +343,7 @@ mod tests {
|
||||
|
||||
fn make_server(work_dir: &PathBuf) -> PubServer {
|
||||
let config = Arc::new(Config::test(work_dir));
|
||||
init_config(&config);
|
||||
|
||||
let signer = KrillSigner::build(work_dir).unwrap();
|
||||
let signer = Arc::new(signer);
|
||||
|
||||
+16
-2
@@ -79,12 +79,25 @@ fn test_config(dir: &PathBuf) -> Config {
|
||||
Config::test(dir)
|
||||
}
|
||||
|
||||
pub fn init_config(config: &Config) {
|
||||
if config.init_logging().is_err() {
|
||||
trace!("Logging already initialised");
|
||||
}
|
||||
config.verify().unwrap();
|
||||
}
|
||||
|
||||
/// Starts krill server for testing, with embedded TA and repo.
|
||||
/// Creates a random base directory in the 'work' folder, and returns
|
||||
/// it. Be sure to clean it up when the test is done.
|
||||
pub async fn start_krill() -> PathBuf {
|
||||
pub async fn start_krill(config: Option<Config>) -> PathBuf {
|
||||
let dir = tmp_dir();
|
||||
let config = test_config(&dir);
|
||||
let config = if let Some(mut config) = config {
|
||||
config.set_data_dir(dir.clone());
|
||||
config
|
||||
} else {
|
||||
test_config(&dir)
|
||||
};
|
||||
init_config(&config);
|
||||
|
||||
let uris = {
|
||||
let rsync_base = uri::Rsync::from_str("rsync://localhost/repo/").unwrap();
|
||||
@@ -102,6 +115,7 @@ pub async fn start_krill() -> PathBuf {
|
||||
pub async fn start_krill_pubd() -> PathBuf {
|
||||
let dir = tmp_dir();
|
||||
let mut config = test_config(&dir);
|
||||
init_config(&config);
|
||||
|
||||
config.port = 3001;
|
||||
config.service_uri = "https://localhost:3001/".to_string();
|
||||
|
||||
+1
-1
@@ -214,7 +214,7 @@ async fn functional() {
|
||||
//
|
||||
// * RTAs can be created and co-signed under multiple CAs
|
||||
|
||||
let d = start_krill().await;
|
||||
let d = start_krill(None).await;
|
||||
|
||||
let ta = ta_handle();
|
||||
let testbed = handle_for("testbed");
|
||||
|
||||
@@ -12,8 +12,6 @@ async fn multi_user_config_file_with_ta_test() {
|
||||
use krill::commons::api::Handle;
|
||||
use krill::{cli::report::ApiResponse, test::*};
|
||||
|
||||
krill::constants::enable_testbed();
|
||||
|
||||
ui::run_krill_ui_test("multi_user_config_file_with_ta", false).await;
|
||||
|
||||
// Check the Krill event history after the actions performed against Krill
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ async fn add_and_remove_certificate_authority() {
|
||||
use krill::daemon::ca::testbed_ca_handle;
|
||||
use krill::test::*;
|
||||
|
||||
let dir = start_krill().await;
|
||||
let dir = start_krill(None).await;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// establish/verify starting conditions
|
||||
|
||||
+3
-19
@@ -4,13 +4,9 @@ mod openid_connect_mock;
|
||||
use tokio::task;
|
||||
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
use std::sync::Arc;
|
||||
|
||||
use krill::daemon::config::Config;
|
||||
use krill::daemon::http::server;
|
||||
use krill::daemon::krillserver::KrillMode;
|
||||
use krill::test::*;
|
||||
|
||||
pub async fn run_krill_ui_test(test_name: &str, _with_openid_server: bool) {
|
||||
@@ -30,21 +26,9 @@ pub async fn run_krill_ui_test(test_name: &str, _with_openid_server: bool) {
|
||||
}
|
||||
|
||||
async fn do_run_krill_ui_test(test_name: &str) {
|
||||
let dir = sub_dir(&PathBuf::from("work"));
|
||||
let test_dir = dir.to_string_lossy().to_string();
|
||||
|
||||
krill::constants::enable_test_mode();
|
||||
krill::constants::enable_test_announcements();
|
||||
|
||||
let data_dir = PathBuf::from(test_dir);
|
||||
let mut config = Config::read_config(&format!("test-resources/ui/{}.conf", test_name)).unwrap();
|
||||
config.set_data_dir(data_dir);
|
||||
config.init_logging().unwrap();
|
||||
config.verify().unwrap();
|
||||
|
||||
tokio::spawn(server::start_krill_daemon(Arc::new(config), KrillMode::Testbed));
|
||||
println!("Waiting for Krill server to start");
|
||||
assert!(krill_server_ready().await);
|
||||
let config_path = &format!("test-resources/ui/{}.conf", test_name);
|
||||
let config = Config::read_config(&config_path).unwrap();
|
||||
start_krill(Some(config)).await;
|
||||
|
||||
let test_name = test_name.to_string();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user