From 70f160b3296e0dec38890e712f78f6d859a886f6 Mon Sep 17 00:00:00 2001 From: Pascal Seitz Date: Mon, 2 Aug 2021 10:53:52 +0100 Subject: [PATCH 1/3] add long running test in ci --- .github/workflows/long_running.yml | 26 ++++++++++++++++++++++++++ src/functional_test.rs | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/long_running.yml diff --git a/.github/workflows/long_running.yml b/.github/workflows/long_running.yml new file mode 100644 index 000000000..8707bf99e --- /dev/null +++ b/.github/workflows/long_running.yml @@ -0,0 +1,26 @@ +name: Rust + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +env: + CARGO_TERM_COLOR: always + NUM_FUNCTIONAL_TEST_ITERATIONS: 2000000 + +jobs: + functional_test_unsorted: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run indexing_unsorted + run: cargo test indexing_unsorted -- --ignored + functional_test_sorted: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run indexing_sorted + run: cargo test indexing_sorted -- --ignored + diff --git a/src/functional_test.rs b/src/functional_test.rs index bb61ec25e..2775d2be3 100644 --- a/src/functional_test.rs +++ b/src/functional_test.rs @@ -123,7 +123,7 @@ fn test_functional_indexing_sorted() -> crate::Result<()> { #[test] #[ignore] -fn test_functional_indexing() -> crate::Result<()> { +fn test_functional_indexing_unsorted() -> crate::Result<()> { let mut schema_builder = Schema::builder(); let id_field = schema_builder.add_u64_field("id", INDEXED); From 605e8603dc909de5b12bf9d16fa278962def5810 Mon Sep 17 00:00:00 2001 From: Pascal Seitz Date: Mon, 2 Aug 2021 15:29:49 +0100 Subject: [PATCH 2/3] add positions to long running test --- .github/workflows/long_running.yml | 2 +- src/functional_test.rs | 38 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/.github/workflows/long_running.yml b/.github/workflows/long_running.yml index 8707bf99e..cdae0aa04 100644 --- a/.github/workflows/long_running.yml +++ b/.github/workflows/long_running.yml @@ -8,7 +8,7 @@ on: env: CARGO_TERM_COLOR: always - NUM_FUNCTIONAL_TEST_ITERATIONS: 2000000 + NUM_FUNCTIONAL_TEST_ITERATIONS: 200000 jobs: functional_test_unsorted: diff --git a/src/functional_test.rs b/src/functional_test.rs index 2775d2be3..f76e42e7b 100644 --- a/src/functional_test.rs +++ b/src/functional_test.rs @@ -1,3 +1,4 @@ +use crate::schema; use crate::Index; use crate::IndexSettings; use crate::IndexSortByField; @@ -71,6 +72,13 @@ fn test_functional_indexing_sorted() -> crate::Result<()> { let id_field = schema_builder.add_u64_field("id", INDEXED | FAST); let multiples_field = schema_builder.add_u64_field("multiples", INDEXED); + let text_field_options = TextOptions::default() + .set_indexing_options( + TextFieldIndexing::default() + .set_index_option(schema::IndexRecordOption::WithFreqsAndPositions), + ) + .set_stored(); + let text_field = schema_builder.add_text_field("text_field", text_field_options); let schema = schema_builder.build(); let mut index_builder = Index::builder().schema(schema); @@ -115,12 +123,34 @@ fn test_functional_indexing_sorted() -> crate::Result<()> { for i in 1u64..10u64 { doc.add_u64(multiples_field, random_val * i); } + doc.add_text(text_field, get_text()); index_writer.add_document(doc); } } Ok(()) } +const LOREM: &str = "Doc Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed \ + do eiusmod tempor incididunt ut labore et dolore magna aliqua. \ + Ut enim ad minim veniam, quis nostrud exercitation ullamco \ + laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure \ + dolor in reprehenderit in voluptate velit esse cillum dolore eu \ + fugiat nulla pariatur. Excepteur sint occaecat cupidatat non \ + proident, sunt in culpa qui officia deserunt mollit anim id est \ + laborum."; +fn get_text() -> String { + use rand::seq::SliceRandom; + let mut rng = thread_rng(); + let tokens: Vec<_> = LOREM.split(" ").collect(); + let random_val = rng.gen_range(0..20); + + (0..random_val) + .map(|_| tokens.choose(&mut rng).unwrap()) + .cloned() + .collect::>() + .join(" ") +} + #[test] #[ignore] fn test_functional_indexing_unsorted() -> crate::Result<()> { @@ -128,6 +158,13 @@ fn test_functional_indexing_unsorted() -> crate::Result<()> { let id_field = schema_builder.add_u64_field("id", INDEXED); let multiples_field = schema_builder.add_u64_field("multiples", INDEXED); + let text_field_options = TextOptions::default() + .set_indexing_options( + TextFieldIndexing::default() + .set_index_option(schema::IndexRecordOption::WithFreqsAndPositions), + ) + .set_stored(); + let text_field = schema_builder.add_text_field("text_field", text_field_options); let schema = schema_builder.build(); let index = Index::create_from_tempdir(schema)?; @@ -163,6 +200,7 @@ fn test_functional_indexing_unsorted() -> crate::Result<()> { for i in 1u64..10u64 { doc.add_u64(multiples_field, random_val * i); } + doc.add_text(text_field, get_text()); index_writer.add_document(doc); } } From 022ab9d2983ecff3bb89be74c6cf7e063f3f8cd7 Mon Sep 17 00:00:00 2001 From: Pascal Seitz Date: Mon, 2 Aug 2021 15:44:00 +0100 Subject: [PATCH 3/3] don't run as pr --- .github/workflows/long_running.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/long_running.yml b/.github/workflows/long_running.yml index cdae0aa04..49303f733 100644 --- a/.github/workflows/long_running.yml +++ b/.github/workflows/long_running.yml @@ -3,12 +3,10 @@ name: Rust on: push: branches: [ main ] - pull_request: - branches: [ main ] env: CARGO_TERM_COLOR: always - NUM_FUNCTIONAL_TEST_ITERATIONS: 200000 + NUM_FUNCTIONAL_TEST_ITERATIONS: 20000 jobs: functional_test_unsorted: