Skip to content

Commit

Permalink
ET-5253 Clean-up for unification
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Jenss committed Dec 4, 2023
1 parent bace028 commit a146f1f
Show file tree
Hide file tree
Showing 19 changed files with 85 additions and 88 deletions.
4 changes: 2 additions & 2 deletions integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ use tracing_subscriber::{
Layer,
};
use xayn_test_utils::{asset::ort_target, env::clear_env, workspace::find_workspace_dir};
use xayn_web_api::{config, start, AppHandle, Application, Ingestion};
use xayn_web_api::{config, start, AppHandle, Application, WebApi};
use xayn_web_api_db_ctrl::{Silo, Tenant};
use xayn_web_api_shared::{
elastic,
Expand Down Expand Up @@ -723,7 +723,7 @@ pub fn build_test_config_from_parts_and_names(
},
);

if app_name == Ingestion::NAME {
if app_name == WebApi::NAME {
let python_workspace = workspace.join("./snippet-extractor").display().to_string();
let tokenizer = model_dir.join("tokenizer.json").display().to_string();
let limit_to_two_threads = (num_cpus::get() as f32).recip() * 2.;
Expand Down
3 changes: 0 additions & 3 deletions web-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ pub use crate::{
web_api::WebApi,
};

pub type Ingestion = WebApi;
pub type Personalization = WebApi;

/// Allow migration tests to have access to the elastic search mapping this uses.
//FIXME: Remove once we only test migrations upward from a version with `web-api-db-ctrl`
pub static ELASTIC_MAPPING: &str = include_str!("../../web-api-db-ctrl/elasticsearch/mapping.json");
16 changes: 8 additions & 8 deletions web-api/tests/document_candidates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use reqwest::{Client, StatusCode, Url};
use serde::Deserialize;
use serde_json::{json, Value};
use xayn_integration_tests::{send_assert, send_assert_json, test_app, UNCHANGED_CONFIG};
use xayn_web_api::Ingestion;
use xayn_web_api::WebApi;

async fn ingest(client: &Client, url: &Url) -> Result<(), Error> {
send_assert(
Expand Down Expand Up @@ -72,7 +72,7 @@ async fn set(client: &Client, url: &Url, ids: impl IntoIterator<Item = &str>) ->

#[test]
fn test_candidates_all() {
test_app::<Ingestion, _>(UNCHANGED_CONFIG, |client, url, _| async move {
test_app::<WebApi, _>(UNCHANGED_CONFIG, |client, url, _| async move {
assert!(get(&client, &url).await?.ids().is_empty());
ingest(&client, &url).await?;
assert_eq!(get(&client, &url).await?.ids(), ["d1", "d2", "d3"].into());
Expand All @@ -84,7 +84,7 @@ fn test_candidates_all() {

#[test]
fn test_candidates_some() {
test_app::<Ingestion, _>(UNCHANGED_CONFIG, |client, url, _| async move {
test_app::<WebApi, _>(UNCHANGED_CONFIG, |client, url, _| async move {
assert!(get(&client, &url).await?.ids().is_empty());
ingest(&client, &url).await?;
assert_eq!(get(&client, &url).await?.ids(), ["d1", "d2", "d3"].into());
Expand All @@ -96,7 +96,7 @@ fn test_candidates_some() {

#[test]
fn test_candidates_none() {
test_app::<Ingestion, _>(UNCHANGED_CONFIG, |client, url, _| async move {
test_app::<WebApi, _>(UNCHANGED_CONFIG, |client, url, _| async move {
assert!(get(&client, &url).await?.ids().is_empty());
ingest(&client, &url).await?;
assert_eq!(get(&client, &url).await?.ids(), ["d1", "d2", "d3"].into());
Expand All @@ -108,7 +108,7 @@ fn test_candidates_none() {

#[test]
fn test_candidates_not_default() {
test_app::<Ingestion, _>(UNCHANGED_CONFIG, |client, url, _| async move {
test_app::<WebApi, _>(UNCHANGED_CONFIG, |client, url, _| async move {
assert!(get(&client, &url).await?.ids().is_empty());
send_assert(
&client,
Expand Down Expand Up @@ -154,7 +154,7 @@ struct ServerError {

#[test]
fn test_candidates_warning() {
test_app::<Ingestion, _>(UNCHANGED_CONFIG, |client, url, _| async move {
test_app::<WebApi, _>(UNCHANGED_CONFIG, |client, url, _| async move {
assert!(get(&client, &url).await?.ids().is_empty());
ingest(&client, &url).await?;
assert_eq!(get(&client, &url).await?.ids(), ["d1", "d2", "d3"].into());
Expand Down Expand Up @@ -182,7 +182,7 @@ fn test_candidates_warning() {

#[test]
fn test_candidates_reingestion() {
test_app::<Ingestion, _>(UNCHANGED_CONFIG, |client, url, _| async move {
test_app::<WebApi, _>(UNCHANGED_CONFIG, |client, url, _| async move {
assert!(get(&client, &url).await?.ids().is_empty());
send_assert(
&client,
Expand Down Expand Up @@ -254,7 +254,7 @@ fn test_deprecated_candidates() {
Ok(())
}

test_app::<Ingestion, _>(UNCHANGED_CONFIG, |client, url, _| async move {
test_app::<WebApi, _>(UNCHANGED_CONFIG, |client, url, _| async move {
deprecated_candidates(&client, &url, "/candidates").await?;
deprecated_candidates(&client, &url, "/documents/candidates").await?;

Expand Down
6 changes: 3 additions & 3 deletions web-api/tests/document_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use reqwest::StatusCode;
use serde::Deserialize;
use serde_json::{json, Value};
use xayn_integration_tests::{send_assert, send_assert_json, test_app, UNCHANGED_CONFIG};
use xayn_web_api::Ingestion;
use xayn_web_api::WebApi;

#[derive(Debug, Deserialize)]
struct DocumentPropertiesResponse {
Expand All @@ -33,7 +33,7 @@ enum Error {
}

fn document_properties(is_candidate: bool) {
test_app::<Ingestion, _>(UNCHANGED_CONFIG, |client, url, _| async move {
test_app::<WebApi, _>(UNCHANGED_CONFIG, |client, url, _| async move {
send_assert(
&client,
client
Expand Down Expand Up @@ -151,7 +151,7 @@ struct DocumentPropertyResponse {
}

fn document_property(is_candidate: bool) {
test_app::<Ingestion, _>(UNCHANGED_CONFIG, |client, url, _| async move {
test_app::<WebApi, _>(UNCHANGED_CONFIG, |client, url, _| async move {
send_assert(
&client,
client
Expand Down
4 changes: 2 additions & 2 deletions web-api/tests/elastic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use serde_json::{json, Value};
use xayn_integration_tests::{test_app, TEST_EMBEDDING_SIZE, UNCHANGED_CONFIG};
use xayn_test_utils::assert_approx_eq;
use xayn_web_api::Ingestion;
use xayn_web_api::WebApi;
use xayn_web_api_shared::{
elastic::{BulkInstruction, Error, SerdeDiscard},
serde::json_object,
Expand All @@ -32,7 +32,7 @@ fn emb(emb: &[f32]) -> Result<Value, serde_json::Error> {
// just to be sure that the behavior hasn't changed
#[test]
fn test_normalized_es_knn_scores() {
test_app::<Ingestion, _>(UNCHANGED_CONFIG, |_, _, services| async move {
test_app::<WebApi, _>(UNCHANGED_CONFIG, |_, _, services| async move {
let client = services
.silo
.elastic_client()
Expand Down
6 changes: 3 additions & 3 deletions web-api/tests/et_4957_es_deletion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use xayn_integration_tests::{
Services,
UNCHANGED_CONFIG,
};
use xayn_web_api::{Ingestion, Personalization};
use xayn_web_api::WebApi;
use xayn_web_api_shared::json_object;

async fn get_candidates(client: &Client, url: &Url) -> Result<HashSet<String>, Error> {
Expand Down Expand Up @@ -216,7 +216,7 @@ fn string_set(x: impl IntoIterator<Item = impl Into<String>>) -> HashSet<String>

#[test]
fn test_deletes_them_from_elastic_search() {
test_two_apps::<Ingestion, Personalization, _>(
test_two_apps::<WebApi, WebApi, _>(
UNCHANGED_CONFIG,
UNCHANGED_CONFIG,
|client, ingestion_url, personalization_url, services| async move {
Expand Down Expand Up @@ -332,7 +332,7 @@ fn test_deletes_them_from_elastic_search() {

#[test]
fn test_deletes_them_from_elastic_search_2() {
test_app::<Ingestion, _>(
test_app::<WebApi, _>(
UNCHANGED_CONFIG,
|client, ingestion_url, services| async move {
ingest(
Expand Down
20 changes: 10 additions & 10 deletions web-api/tests/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use reqwest::{Client, StatusCode, Url};
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
use xayn_integration_tests::{send_assert, send_assert_json, test_two_apps, UNCHANGED_CONFIG};
use xayn_web_api::{Ingestion, Personalization};
use xayn_web_api::WebApi;

#[derive(Serialize)]
struct IngestedDocument {
Expand Down Expand Up @@ -93,7 +93,7 @@ struct BadRequest {

#[test]
fn test_filter_boolean() {
test_two_apps::<Ingestion, Personalization, _>(
test_two_apps::<WebApi, WebApi, _>(
UNCHANGED_CONFIG,
UNCHANGED_CONFIG,
|client, ingestion_url, personalization_url, _| async move {
Expand Down Expand Up @@ -178,7 +178,7 @@ fn test_filter_boolean() {

#[test]
fn test_filter_keyword() {
test_two_apps::<Ingestion, Personalization, _>(
test_two_apps::<WebApi, WebApi, _>(
UNCHANGED_CONFIG,
UNCHANGED_CONFIG,
|client, ingestion_url, personalization_url, _| async move {
Expand Down Expand Up @@ -263,7 +263,7 @@ fn test_filter_keyword() {

#[test]
fn test_filter_keyword_array_single() {
test_two_apps::<Ingestion, Personalization, _>(
test_two_apps::<WebApi, WebApi, _>(
UNCHANGED_CONFIG,
UNCHANGED_CONFIG,
|client, ingestion_url, personalization_url, _| async move {
Expand Down Expand Up @@ -378,7 +378,7 @@ fn test_filter_keyword_array_single() {

#[test]
fn test_filter_keyword_array_multiple() {
test_two_apps::<Ingestion, Personalization, _>(
test_two_apps::<WebApi, WebApi, _>(
UNCHANGED_CONFIG,
UNCHANGED_CONFIG,
|client, ingestion_url, personalization_url, _| async move {
Expand Down Expand Up @@ -509,7 +509,7 @@ fn test_filter_keyword_array_multiple() {

#[test]
fn test_filter_combine() {
test_two_apps::<Ingestion, Personalization, _>(
test_two_apps::<WebApi, WebApi, _>(
UNCHANGED_CONFIG,
UNCHANGED_CONFIG,
|client, ingestion_url, personalization_url, _| async move {
Expand Down Expand Up @@ -677,7 +677,7 @@ fn test_filter_combine() {

#[test]
fn test_filter_number() {
test_two_apps::<Ingestion, Personalization, _>(
test_two_apps::<WebApi, WebApi, _>(
UNCHANGED_CONFIG,
UNCHANGED_CONFIG,
|client, ingestion_url, personalization_url, _| async move {
Expand Down Expand Up @@ -783,7 +783,7 @@ fn test_filter_number() {

#[test]
fn test_filter_date() {
test_two_apps::<Ingestion, Personalization, _>(
test_two_apps::<WebApi, WebApi, _>(
UNCHANGED_CONFIG,
UNCHANGED_CONFIG,
|client, ingestion_url, personalization_url, _| async move {
Expand Down Expand Up @@ -897,7 +897,7 @@ fn test_filter_date() {

#[test]
fn test_filter_no_value() {
test_two_apps::<Ingestion, Personalization, _>(
test_two_apps::<WebApi, WebApi, _>(
UNCHANGED_CONFIG,
UNCHANGED_CONFIG,
|client, ingestion_url, personalization_url, _| async move {
Expand Down Expand Up @@ -1004,7 +1004,7 @@ fn test_filter_no_value() {

#[test]
fn test_deprecated_published_after() {
test_two_apps::<Ingestion, Personalization, _>(
test_two_apps::<WebApi, WebApi, _>(
UNCHANGED_CONFIG,
UNCHANGED_CONFIG,
|client, ingestion_url, personalization_url, _| async move {
Expand Down
4 changes: 2 additions & 2 deletions web-api/tests/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ use std::time::Duration;

use reqwest::{Client, StatusCode};
use xayn_integration_tests::{send_assert, test_app, UNCHANGED_CONFIG};
use xayn_web_api::Ingestion;
use xayn_web_api::WebApi;

#[test]
fn test_health() {
test_app::<Ingestion, _>(UNCHANGED_CONFIG, |_client, url, _| async move {
test_app::<WebApi, _>(UNCHANGED_CONFIG, |_client, url, _| async move {
// make sure not to use any presets from `test_app`, like e.g. the
// X-Xayn-Tenant-Id header.
let client = Client::builder()
Expand Down
22 changes: 11 additions & 11 deletions web-api/tests/ingestion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use xayn_integration_tests::{
with_text_extractor_options,
UNCHANGED_CONFIG,
};
use xayn_web_api::{Ingestion, Personalization};
use xayn_web_api::WebApi;

async fn ingest(client: &Client, url: &Url) -> Result<(), anyhow::Error> {
send_assert(
Expand Down Expand Up @@ -72,7 +72,7 @@ struct Error {

#[test]
fn test_ingestion_created() {
test_app::<Ingestion, _>(UNCHANGED_CONFIG, |client, url, _| async move {
test_app::<WebApi, _>(UNCHANGED_CONFIG, |client, url, _| async move {
ingest(&client, &url).await?;
send_assert(
&client,
Expand Down Expand Up @@ -103,7 +103,7 @@ fn test_ingestion_created() {

#[test]
fn test_ingestion_bad_request() {
test_app::<Ingestion, _>(UNCHANGED_CONFIG, |client, url, _| async move {
test_app::<WebApi, _>(UNCHANGED_CONFIG, |client, url, _| async move {
let long_snippet = vec!["a"; 2049].join("");
let error = send_assert_json::<Error>(
&client,
Expand Down Expand Up @@ -217,7 +217,7 @@ fn test_ingestion_created_with_file() {
.map(Into::into)
.collect();

test_app::<Ingestion, _>(
test_app::<WebApi, _>(
with_text_extractor_options(allowed_content_type, None),
|client, url, _| async move {
send_assert(
Expand Down Expand Up @@ -270,7 +270,7 @@ fn test_ingestion_created_with_file_bad_request() {
);

let txt_content = txt_content_data.clone();
test_app::<Ingestion, _>(
test_app::<WebApi, _>(
with_text_extractor_options(vec![], None),
|client, url, _| async move {
send_assert(
Expand Down Expand Up @@ -353,7 +353,7 @@ fn test_ingestion_created_with_file_bad_request() {
);

let txt_content = txt_content_data;
test_app::<Ingestion, _>(
test_app::<WebApi, _>(
with_text_extractor_options(vec![], Some(1)),
|client, url, _| async move {
send_assert(
Expand All @@ -378,7 +378,7 @@ fn test_ingestion_created_with_file_bad_request() {

#[test]
fn test_deletion() {
test_app::<Ingestion, _>(UNCHANGED_CONFIG, |client, url, _| async move {
test_app::<WebApi, _>(UNCHANGED_CONFIG, |client, url, _| async move {
ingest(&client, &url).await?;
send_assert(
&client,
Expand Down Expand Up @@ -418,7 +418,7 @@ struct SemanticSearchResponse {

#[test]
fn test_reingestion_candidates() {
test_two_apps::<Ingestion, Personalization, _>(
test_two_apps::<WebApi, WebApi, _>(
UNCHANGED_CONFIG,
UNCHANGED_CONFIG,
|client, ingestion_url, personalization_url, _| async move {
Expand Down Expand Up @@ -508,7 +508,7 @@ fn test_reingestion_candidates() {
// new and changed documents have been logged and manually check the databases
#[test]
fn test_reingestion_snippets() {
test_app::<Ingestion, _>(UNCHANGED_CONFIG, |client, url, _| async move {
test_app::<WebApi, _>(UNCHANGED_CONFIG, |client, url, _| async move {
send_assert(
&client,
client
Expand Down Expand Up @@ -555,7 +555,7 @@ struct OrderPropertyResponse {

#[test]
fn test_ingestion_same_id() {
test_app::<Ingestion, _>(UNCHANGED_CONFIG, |client, url, _| async move {
test_app::<WebApi, _>(UNCHANGED_CONFIG, |client, url, _| async move {
send_assert(
&client,
client
Expand Down Expand Up @@ -598,7 +598,7 @@ fn test_ingestion_same_id() {

#[test]
fn test_ingestion_validation() {
test_app::<Ingestion, _>(
test_app::<WebApi, _>(
Some(toml! {
[ingestion]
max_snippet_size = 10
Expand Down
Loading

0 comments on commit a146f1f

Please sign in to comment.