mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-09-23 21:26:26 +00:00
Refactor around meili_path
This commit is contained in:
@ -128,31 +128,12 @@ async fn execute_run(
|
|||||||
binary_path: Option<&Path>,
|
binary_path: Option<&Path>,
|
||||||
run_number: u16,
|
run_number: u16,
|
||||||
) -> anyhow::Result<tokio::task::JoinHandle<anyhow::Result<std::fs::File>>> {
|
) -> anyhow::Result<tokio::task::JoinHandle<anyhow::Result<std::fs::File>>> {
|
||||||
meili_process::delete_db();
|
|
||||||
|
|
||||||
let run_command = match binary_path {
|
|
||||||
Some(binary_path) => tokio::process::Command::new(binary_path),
|
|
||||||
None => {
|
|
||||||
meili_process::build().await?;
|
|
||||||
let mut command = tokio::process::Command::new("cargo");
|
|
||||||
command
|
|
||||||
.arg("run")
|
|
||||||
.arg("--release")
|
|
||||||
.arg("-p")
|
|
||||||
.arg("meilisearch")
|
|
||||||
.arg("--bin")
|
|
||||||
.arg("meilisearch")
|
|
||||||
.arg("--");
|
|
||||||
command
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let meilisearch = meili_process::start(
|
let meilisearch = meili_process::start(
|
||||||
meili_client,
|
meili_client,
|
||||||
master_key,
|
master_key,
|
||||||
&workload.extra_cli_args,
|
&workload.extra_cli_args,
|
||||||
&workload.name,
|
&workload.name,
|
||||||
run_command,
|
binary_path,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
use std::path::Path;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use anyhow::{bail, Context as _};
|
use anyhow::{bail, Context as _};
|
||||||
@ -48,7 +49,7 @@ pub async fn kill(mut meilisearch: tokio::process::Child) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
pub async fn build() -> anyhow::Result<()> {
|
async fn build() -> anyhow::Result<()> {
|
||||||
let mut command = TokioCommand::new("cargo");
|
let mut command = TokioCommand::new("cargo");
|
||||||
command.arg("build").arg("--release").arg("-p").arg("meilisearch");
|
command.arg("build").arg("--release").arg("-p").arg("meilisearch");
|
||||||
|
|
||||||
@ -69,8 +70,27 @@ pub async fn start(
|
|||||||
master_key: Option<&str>,
|
master_key: Option<&str>,
|
||||||
extra_cli_args: &[String],
|
extra_cli_args: &[String],
|
||||||
_workload: &str,
|
_workload: &str,
|
||||||
mut command: TokioCommand,
|
binary_path: Option<&Path>,
|
||||||
) -> anyhow::Result<tokio::process::Child> {
|
) -> anyhow::Result<tokio::process::Child> {
|
||||||
|
delete_db();
|
||||||
|
|
||||||
|
let mut command = match binary_path {
|
||||||
|
Some(binary_path) => tokio::process::Command::new(binary_path),
|
||||||
|
None => {
|
||||||
|
build().await?;
|
||||||
|
let mut command = tokio::process::Command::new("cargo");
|
||||||
|
command
|
||||||
|
.arg("run")
|
||||||
|
.arg("--release")
|
||||||
|
.arg("-p")
|
||||||
|
.arg("meilisearch")
|
||||||
|
.arg("--bin")
|
||||||
|
.arg("meilisearch")
|
||||||
|
.arg("--");
|
||||||
|
command
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
command.arg("--db-path").arg("./_xtask_benchmark.ms");
|
command.arg("--db-path").arg("./_xtask_benchmark.ms");
|
||||||
if let Some(master_key) = master_key {
|
if let Some(master_key) = master_key {
|
||||||
command.arg("--master-key").arg(master_key);
|
command.arg("--master-key").arg(master_key);
|
||||||
@ -119,6 +139,6 @@ async fn wait_for_health(
|
|||||||
bail!("meilisearch is not responding")
|
bail!("meilisearch is not responding")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn delete_db() {
|
async fn delete_db() {
|
||||||
let _ = std::fs::remove_dir_all("./_xtask_benchmark.ms");
|
let _ = tokio::fs::remove_dir_all("./_xtask_benchmark.ms").await;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user