Skip to content

Commit

Permalink
Add test to showcase the bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rdettai committed Aug 20, 2024
1 parent 53f2125 commit 2368c07
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions quickwit/quickwit-cli/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,45 @@ async fn test_ingest_docs_cli() {
));
}

#[tokio::test]
async fn test_ingest_docs_cli_twice() {
quickwit_common::setup_logging_for_tests();
let index_id = append_random_suffix("test-index-simple");
let test_env = create_test_env(index_id.clone(), TestStorageType::LocalFileSystem)
.await
.unwrap();
test_env.start_server().await.unwrap();
create_logs_index(&test_env).await.unwrap();
let index_uid = test_env.index_metadata().await.unwrap().index_uid;

for _ in 0..2 {
let args = LocalIngestDocsArgs {
config_uri: test_env.resource_files.config.clone(),
index_id: index_id.clone(),
input_path_opt: Some(test_env.resource_files.log_docs.clone()),
input_format: SourceInputFormat::Json,
overwrite: false,
clear_cache: true,
vrl_script: None,
};

local_ingest_docs_cli(args).await.unwrap();
}

let splits_metadata: Vec<SplitMetadata> = test_env
.metastore()
.await
.list_splits(ListSplitsRequest::try_from_index_uid(index_uid).unwrap())
.await
.unwrap()
.collect_splits_metadata()
.await
.unwrap();

assert_eq!(splits_metadata.len(), 1);
assert_eq!(splits_metadata[0].num_docs, 5);
}

/// Helper function to compare a json payload.
///
/// It will serialize and deserialize the value in order
Expand Down

0 comments on commit 2368c07

Please sign in to comment.