@@ -144,7 +144,7 @@ impl TestEnvironment {
144144 . await
145145 . map_err ( |e| format ! ( "Failed to create cell schema: {:?}" , e) ) ?
146146 . map_err ( |e| format ! ( "Failed to create cell schema: {:?}" , e) ) ?;
147- initialize_schemas ( morph) . await ;
147+ initialize_schemas ( morph) . await . unwrap ( ) ;
148148 Ok ( self )
149149 }
150150
@@ -167,7 +167,7 @@ impl TestEnvironment {
167167 Ok ( self )
168168 }
169169
170- pub async fn create_index ( & mut self ) -> Result < ( ) , String > {
170+ pub async fn create_index ( & self ) -> Result < ( ) , String > {
171171 if self . morpheus . is_none ( ) {
172172 return Err ( "Morpheus not initialized" . to_string ( ) ) ;
173173 }
@@ -188,7 +188,7 @@ impl TestEnvironment {
188188 }
189189
190190 /// Create the HNSW graph from cells
191- pub async fn index_cells ( & mut self ) -> Result < ( ) , String > {
191+ pub async fn index_cells ( & self ) -> Result < ( ) , String > {
192192 if self . morpheus . is_none ( ) {
193193 return Err ( "Morpheus not initialized" . to_string ( ) ) ;
194194 }
@@ -212,8 +212,14 @@ impl TestEnvironment {
212212 )
213213 . await
214214 . map_err ( |e| format ! ( "Failed to create job: {:?}" , e) ) ?;
215- partition_svr. next_iteration ( job_id) . await . map_err ( |e| format ! ( "Failed to run job with next iteration: {:?}" , e) ) ?;
216- partition_svr. index_cell ( job_id, cell_id) . await . map_err ( |e| format ! ( "Failed to index cell: {:?}" , e) ) ?;
215+ partition_svr
216+ . next_iteration ( job_id)
217+ . await
218+ . map_err ( |e| format ! ( "Failed to run job with next iteration: {:?}" , e) ) ?;
219+ partition_svr
220+ . index_cell ( job_id, cell_id)
221+ . await
222+ . map_err ( |e| format ! ( "Failed to index cell: {:?}" , e) ) ?;
217223 // let mut search = partition.new_search(CELL_SCHEMA_ID, VECTOR_FIELD_ID, &vector, 1, MetricEncoding::L2)
218224 // .await
219225 // .map_err(|e| format!("Failed to create search: {:?}", e))?;
@@ -351,26 +357,66 @@ mod tests {
351357
352358 // Test that the data cell contains the vector
353359 if let OwnedValue :: Map ( map) = & data_cell. data {
354- assert_eq ! ( map. get_by_key_id( field_id) , & OwnedValue :: PrimArray ( test_vector. vector. clone( ) ) ) ;
360+ assert_eq ! (
361+ map. get_by_key_id( field_id) ,
362+ & OwnedValue :: PrimArray ( test_vector. vector. clone( ) )
363+ ) ;
355364 } else {
356365 panic ! ( "Data cell data is not a map" ) ;
357366 }
358367 }
359368
360369 #[ tokio:: test]
361370 async fn server_startup ( ) {
362- TestEnvironment :: new (
363- 5000 , 1 , VECTOR_FIELD_ID , CELL_SCHEMA_ID )
371+ let env = TestEnvironment :: new ( 5000 , 1 , VECTOR_FIELD_ID , CELL_SCHEMA_ID )
364372 . with_test_vectors ( vec ! [ vec![ 1.0 , 2.0 , 3.0 ] ] )
365373 . with_job_logger ( )
366374 . with_job_id ( JobId :: new ( 1 , 1 ) )
367- . initialize_server ( ) . await
368- . initialize_schemas ( ) . await . unwrap ( )
369- . initialize_cells ( ) . await . unwrap ( )
370- . create_index ( ) . await . unwrap ( ) ;
375+ . initialize_server ( )
376+ . await
377+ . initialize_schemas ( )
378+ . await
379+ . unwrap ( )
380+ . initialize_cells ( )
381+ . await
382+ . unwrap ( ) ;
383+ env. create_index ( ) . await . unwrap ( ) ;
371384 }
372385}
386+ #[ tokio:: test]
387+ async fn server_startup ( ) {
388+ let env = TestEnvironment :: new ( 5000 , 1 , VECTOR_FIELD_ID , CELL_SCHEMA_ID )
389+ . with_test_vectors ( vec ! [ vec![ 1.0 , 2.0 , 3.0 ] ] )
390+ . with_job_logger ( )
391+ . with_job_id ( JobId :: new ( 1 , 1 ) )
392+ . initialize_server ( )
393+ . await
394+ . initialize_schemas ( )
395+ . await
396+ . unwrap ( )
397+ . initialize_cells ( )
398+ . await
399+ . unwrap ( ) ;
400+ env. create_index ( ) . await . unwrap ( ) ;
401+ }
373402
403+ #[ tokio:: test]
404+ async fn index_one_cell ( ) {
405+ let env = TestEnvironment :: new ( 5001 , 1 , VECTOR_FIELD_ID , CELL_SCHEMA_ID )
406+ . with_test_vectors ( vec ! [ vec![ 1.0 , 2.0 , 3.0 ] ] )
407+ . with_job_logger ( )
408+ . with_job_id ( JobId :: new ( 1 , 1 ) )
409+ . initialize_server ( )
410+ . await
411+ . initialize_schemas ( )
412+ . await
413+ . unwrap ( )
414+ . initialize_cells ( )
415+ . await
416+ . unwrap ( ) ;
417+ env. create_index ( ) . await . unwrap ( ) ;
418+ env. index_cells ( ) . await . unwrap ( ) ;
419+ }
374420// Example of how to set up a functional test (commented out since it needs user implementation)
375421/*
376422#[async_std::test]
0 commit comments