@@ -30,6 +30,8 @@ use predicates::prelude::*;
3030use quickwit_cli:: index:: { create_index_cli, search_index, CreateIndexArgs , SearchIndexArgs } ;
3131use quickwit_common:: rand:: append_random_suffix;
3232use quickwit_common:: uri:: Uri ;
33+ use quickwit_core:: get_cache_path;
34+ use quickwit_indexing:: source:: INGEST_SOURCE_ID ;
3335use quickwit_metastore:: { quickwit_metastore_uri_resolver, Metastore } ;
3436use serde_json:: { json, Number , Value } ;
3537use serial_test:: serial;
@@ -50,13 +52,14 @@ fn create_logs_index(test_env: &TestEnv) {
5052 . success ( ) ;
5153}
5254
53- fn ingest_docs ( input_path : & Path , test_env : & TestEnv ) {
55+ fn ingest_docs_with_options ( input_path : & Path , test_env : & TestEnv , options : & str ) {
5456 make_command (
5557 format ! (
56- "index ingest --index {} --input-path {} --config {}" ,
58+ "index ingest --index {} --input-path {} --config {} {} " ,
5759 test_env. index_id,
5860 input_path. display( ) ,
5961 test_env. resource_files[ "config" ] . display( ) ,
62+ options
6063 )
6164 . as_str ( ) ,
6265 )
@@ -69,6 +72,10 @@ fn ingest_docs(input_path: &Path, test_env: &TestEnv) {
6972 ) ) ;
7073}
7174
75+ fn ingest_docs ( input_path : & Path , test_env : & TestEnv ) {
76+ ingest_docs_with_options ( input_path, test_env, "" ) ;
77+ }
78+
7279#[ test]
7380fn test_cmd_help ( ) -> anyhow:: Result < ( ) > {
7481 let mut cmd = make_command ( "--help" ) ;
@@ -187,14 +194,44 @@ fn test_cmd_ingest_on_non_existing_file() -> Result<()> {
187194 Ok ( ( ) )
188195}
189196
197+ #[ test]
198+ fn test_cmd_ingest_clean_cache ( ) -> Result < ( ) > {
199+ let index_id = append_random_suffix ( "test-index-clean-cache" ) ;
200+ let test_env = create_test_env ( index_id, TestStorageType :: LocalFileSystem ) ?;
201+ create_logs_index ( & test_env) ;
202+
203+ ingest_docs_with_options (
204+ test_env. resource_files [ "logs" ] . as_path ( ) ,
205+ & test_env,
206+ "--clean_cache" ,
207+ ) ;
208+
209+ // check cache path
210+ let cache_path = get_cache_path (
211+ & test_env. data_dir_path ,
212+ & test_env. index_id ,
213+ INGEST_SOURCE_ID ,
214+ ) ;
215+ assert_eq ! ( false , cache_path. exists( ) ) ;
216+
217+ Ok ( ( ) )
218+ }
219+
190220#[ test]
191221fn test_cmd_ingest_simple ( ) -> Result < ( ) > {
192222 let index_id = append_random_suffix ( "test-index-simple" ) ;
193223 let test_env = create_test_env ( index_id, TestStorageType :: LocalFileSystem ) ?;
194224 create_logs_index ( & test_env) ;
195-
196225 ingest_docs ( test_env. resource_files [ "logs" ] . as_path ( ) , & test_env) ;
197226
227+ // check cache path
228+ let cache_path = get_cache_path (
229+ & test_env. data_dir_path ,
230+ & test_env. index_id ,
231+ INGEST_SOURCE_ID ,
232+ ) ;
233+ assert_eq ! ( true , cache_path. exists( ) ) ;
234+
198235 // Using piped input
199236 let log_path = test_env. resource_files [ "logs" ] . clone ( ) ;
200237 make_command (
0 commit comments