mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-29 16:24:26 +01:00
spawn on search queue per test
This commit is contained in:
parent
fa1a0beb0c
commit
1040e5e2b4
@ -10,6 +10,7 @@ use std::time::Duration;
|
|||||||
use actix_http::body::MessageBody;
|
use actix_http::body::MessageBody;
|
||||||
use actix_web::dev::ServiceResponse;
|
use actix_web::dev::ServiceResponse;
|
||||||
use actix_web::http::StatusCode;
|
use actix_web::http::StatusCode;
|
||||||
|
use actix_web::web::Data;
|
||||||
use byte_unit::{Byte, Unit};
|
use byte_unit::{Byte, Unit};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use meilisearch::option::{IndexerOpts, MaxMemory, MaxThreads, Opt};
|
use meilisearch::option::{IndexerOpts, MaxMemory, MaxThreads, Opt};
|
||||||
@ -56,13 +57,7 @@ impl Server<Owned> {
|
|||||||
let options = default_settings(dir.path());
|
let options = default_settings(dir.path());
|
||||||
|
|
||||||
let (index_scheduler, auth) = setup_meilisearch(&options).unwrap();
|
let (index_scheduler, auth) = setup_meilisearch(&options).unwrap();
|
||||||
let service = Service {
|
let service = Service { index_scheduler, auth, options, api_key: None };
|
||||||
index_scheduler,
|
|
||||||
auth,
|
|
||||||
search_queue: Self::new_search_queue(&options),
|
|
||||||
options,
|
|
||||||
api_key: None,
|
|
||||||
};
|
|
||||||
|
|
||||||
Server { service, _dir: Some(dir), _marker: PhantomData }
|
Server { service, _dir: Some(dir), _marker: PhantomData }
|
||||||
}
|
}
|
||||||
@ -77,13 +72,7 @@ impl Server<Owned> {
|
|||||||
options.master_key = Some("MASTER_KEY".to_string());
|
options.master_key = Some("MASTER_KEY".to_string());
|
||||||
|
|
||||||
let (index_scheduler, auth) = setup_meilisearch(&options).unwrap();
|
let (index_scheduler, auth) = setup_meilisearch(&options).unwrap();
|
||||||
let service = Service {
|
let service = Service { index_scheduler, auth, options, api_key: None };
|
||||||
index_scheduler,
|
|
||||||
auth,
|
|
||||||
search_queue: Self::new_search_queue(&options),
|
|
||||||
options,
|
|
||||||
api_key: None,
|
|
||||||
};
|
|
||||||
|
|
||||||
Server { service, _dir: Some(dir), _marker: PhantomData }
|
Server { service, _dir: Some(dir), _marker: PhantomData }
|
||||||
}
|
}
|
||||||
@ -96,13 +85,7 @@ impl Server<Owned> {
|
|||||||
|
|
||||||
pub async fn new_with_options(options: Opt) -> Result<Self, anyhow::Error> {
|
pub async fn new_with_options(options: Opt) -> Result<Self, anyhow::Error> {
|
||||||
let (index_scheduler, auth) = setup_meilisearch(&options)?;
|
let (index_scheduler, auth) = setup_meilisearch(&options)?;
|
||||||
let service = Service {
|
let service = Service { index_scheduler, auth, options, api_key: None };
|
||||||
index_scheduler,
|
|
||||||
auth,
|
|
||||||
search_queue: Self::new_search_queue(&options),
|
|
||||||
options,
|
|
||||||
api_key: None,
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(Server { service, _dir: None, _marker: PhantomData })
|
Ok(Server { service, _dir: None, _marker: PhantomData })
|
||||||
}
|
}
|
||||||
@ -204,13 +187,7 @@ impl Server<Shared> {
|
|||||||
let options = default_settings(dir.path());
|
let options = default_settings(dir.path());
|
||||||
|
|
||||||
let (index_scheduler, auth) = setup_meilisearch(&options).unwrap();
|
let (index_scheduler, auth) = setup_meilisearch(&options).unwrap();
|
||||||
let service = Service {
|
let service = Service { index_scheduler, auth, api_key: None, options };
|
||||||
index_scheduler,
|
|
||||||
auth,
|
|
||||||
api_key: None,
|
|
||||||
search_queue: Self::new_search_queue(&options),
|
|
||||||
options,
|
|
||||||
};
|
|
||||||
|
|
||||||
Server { service, _dir: Some(dir), _marker: PhantomData }
|
Server { service, _dir: Some(dir), _marker: PhantomData }
|
||||||
}
|
}
|
||||||
@ -283,12 +260,6 @@ impl Server<Shared> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<State> Server<State> {
|
impl<State> Server<State> {
|
||||||
fn new_search_queue(options: &Opt) -> Arc<SearchQueue> {
|
|
||||||
let search_queue =
|
|
||||||
SearchQueue::new(options.experimental_search_queue_size, NonZeroUsize::new(1).unwrap());
|
|
||||||
Arc::new(search_queue)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn init_web_app(
|
pub async fn init_web_app(
|
||||||
&self,
|
&self,
|
||||||
) -> impl actix_web::dev::Service<
|
) -> impl actix_web::dev::Service<
|
||||||
@ -308,11 +279,15 @@ impl<State> Server<State> {
|
|||||||
as Box<dyn tracing_subscriber::Layer<SubscriberForSecondLayer> + Send + Sync>)
|
as Box<dyn tracing_subscriber::Layer<SubscriberForSecondLayer> + Send + Sync>)
|
||||||
.with_filter(tracing_subscriber::filter::Targets::new()),
|
.with_filter(tracing_subscriber::filter::Targets::new()),
|
||||||
);
|
);
|
||||||
|
let search_queue = SearchQueue::new(
|
||||||
|
self.service.options.experimental_search_queue_size,
|
||||||
|
NonZeroUsize::new(1).unwrap(),
|
||||||
|
);
|
||||||
|
|
||||||
actix_web::test::init_service(create_app(
|
actix_web::test::init_service(create_app(
|
||||||
self.service.index_scheduler.clone().into(),
|
self.service.index_scheduler.clone().into(),
|
||||||
self.service.auth.clone().into(),
|
self.service.auth.clone().into(),
|
||||||
self.service.search_queue.clone().into(),
|
Data::new(search_queue),
|
||||||
self.service.options.clone(),
|
self.service.options.clone(),
|
||||||
(route_layer_handle, stderr_layer_handle),
|
(route_layer_handle, stderr_layer_handle),
|
||||||
analytics::MockAnalytics::new(&self.service.options),
|
analytics::MockAnalytics::new(&self.service.options),
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
use std::num::NonZeroUsize;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use actix_web::http::header::ContentType;
|
use actix_web::http::header::ContentType;
|
||||||
use actix_web::http::StatusCode;
|
use actix_web::http::StatusCode;
|
||||||
use actix_web::test;
|
use actix_web::test;
|
||||||
use actix_web::test::TestRequest;
|
use actix_web::test::TestRequest;
|
||||||
|
use actix_web::web::Data;
|
||||||
use index_scheduler::IndexScheduler;
|
use index_scheduler::IndexScheduler;
|
||||||
use meilisearch::search_queue::SearchQueue;
|
use meilisearch::search_queue::SearchQueue;
|
||||||
use meilisearch::{analytics, create_app, Opt, SubscriberForSecondLayer};
|
use meilisearch::{analytics, create_app, Opt, SubscriberForSecondLayer};
|
||||||
@ -17,7 +19,6 @@ use crate::common::Value;
|
|||||||
pub struct Service {
|
pub struct Service {
|
||||||
pub index_scheduler: Arc<IndexScheduler>,
|
pub index_scheduler: Arc<IndexScheduler>,
|
||||||
pub auth: Arc<AuthController>,
|
pub auth: Arc<AuthController>,
|
||||||
pub search_queue: Arc<SearchQueue>,
|
|
||||||
pub options: Opt,
|
pub options: Opt,
|
||||||
pub api_key: Option<String>,
|
pub api_key: Option<String>,
|
||||||
}
|
}
|
||||||
@ -121,11 +122,15 @@ impl Service {
|
|||||||
as Box<dyn tracing_subscriber::Layer<SubscriberForSecondLayer> + Send + Sync>)
|
as Box<dyn tracing_subscriber::Layer<SubscriberForSecondLayer> + Send + Sync>)
|
||||||
.with_filter(tracing_subscriber::filter::Targets::new()),
|
.with_filter(tracing_subscriber::filter::Targets::new()),
|
||||||
);
|
);
|
||||||
|
let search_queue = SearchQueue::new(
|
||||||
|
self.options.experimental_search_queue_size,
|
||||||
|
NonZeroUsize::new(1).unwrap(),
|
||||||
|
);
|
||||||
|
|
||||||
let app = test::init_service(create_app(
|
let app = test::init_service(create_app(
|
||||||
self.index_scheduler.clone().into(),
|
self.index_scheduler.clone().into(),
|
||||||
self.auth.clone().into(),
|
self.auth.clone().into(),
|
||||||
self.search_queue.clone().into(),
|
Data::new(search_queue),
|
||||||
self.options.clone(),
|
self.options.clone(),
|
||||||
(route_layer_handle, stderr_layer_handle),
|
(route_layer_handle, stderr_layer_handle),
|
||||||
analytics::MockAnalytics::new(&self.options),
|
analytics::MockAnalytics::new(&self.options),
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
mod error;
|
mod error;
|
||||||
|
|
||||||
|
use std::num::NonZeroUsize;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use actix_web::http::header::ContentType;
|
use actix_web::http::header::ContentType;
|
||||||
|
use actix_web::web::Data;
|
||||||
use meili_snap::snapshot;
|
use meili_snap::snapshot;
|
||||||
|
use meilisearch::search_queue::SearchQueue;
|
||||||
use meilisearch::{analytics, create_app, Opt, SubscriberForSecondLayer};
|
use meilisearch::{analytics, create_app, Opt, SubscriberForSecondLayer};
|
||||||
use tracing::level_filters::LevelFilter;
|
use tracing::level_filters::LevelFilter;
|
||||||
use tracing_subscriber::layer::SubscriberExt;
|
use tracing_subscriber::layer::SubscriberExt;
|
||||||
@ -40,11 +43,15 @@ async fn basic_test_log_stream_route() {
|
|||||||
.with_span_events(tracing_subscriber::fmt::format::FmtSpan::ACTIVE)
|
.with_span_events(tracing_subscriber::fmt::format::FmtSpan::ACTIVE)
|
||||||
.with_filter(tracing_subscriber::filter::LevelFilter::from_str("OFF").unwrap()),
|
.with_filter(tracing_subscriber::filter::LevelFilter::from_str("OFF").unwrap()),
|
||||||
);
|
);
|
||||||
|
let search_queue = SearchQueue::new(
|
||||||
|
server.service.options.experimental_search_queue_size,
|
||||||
|
NonZeroUsize::new(1).unwrap(),
|
||||||
|
);
|
||||||
|
|
||||||
let app = actix_web::test::init_service(create_app(
|
let app = actix_web::test::init_service(create_app(
|
||||||
server.service.index_scheduler.clone().into(),
|
server.service.index_scheduler.clone().into(),
|
||||||
server.service.auth.clone().into(),
|
server.service.auth.clone().into(),
|
||||||
server.service.search_queue.clone().into(),
|
Data::new(search_queue),
|
||||||
server.service.options.clone(),
|
server.service.options.clone(),
|
||||||
(route_layer_handle, stderr_layer_handle),
|
(route_layer_handle, stderr_layer_handle),
|
||||||
analytics::MockAnalytics::new(&server.service.options),
|
analytics::MockAnalytics::new(&server.service.options),
|
||||||
|
Loading…
Reference in New Issue
Block a user