@@ -49,7 +49,7 @@ public async Task CanCreateGetAndDeleteVectorStores()
4949 _vectorStoresToDelete . RemoveAt ( _vectorStoresToDelete . Count - 1 ) ;
5050
5151 IReadOnlyList < OpenAIFile > testFiles = await GetNewTestFiles ( 5 ) ;
52- VectorStoreCreationOptions creationOptions = new VectorStoreCreationOptions ( )
52+ VectorStoreCreationOptions creationOptions = new ( )
5353 {
5454 FileIds = { testFiles [ 0 ] . Id } ,
5555 Name = "test vector store" ,
@@ -106,46 +106,7 @@ public async Task CanCreateGetAndDeleteVectorStores()
106106 }
107107
108108 [ Test ]
109- [ SyncOnly ]
110- public void CanEnumerateVectorStores ( )
111- {
112- VectorStoreClient client = GetTestClient ( ) ;
113- for ( int i = 0 ; i < 10 ; i ++ )
114- {
115- VectorStore vectorStore = client . CreateVectorStore ( new VectorStoreCreationOptions ( )
116- {
117- Name = $ "Test Vector Store { i } ",
118- } ) ;
119- Validate ( vectorStore ) ;
120- Assert . That ( vectorStore . Name , Is . EqualTo ( $ "Test Vector Store { i } ") ) ;
121- }
122-
123- int lastIdSeen = int . MaxValue ;
124- int count = 0 ;
125-
126- foreach ( VectorStore vectorStore in client . GetVectorStores ( new VectorStoreCollectionOptions ( ) { Order = VectorStoreCollectionOrder . Descending } ) )
127- {
128- Assert . That ( vectorStore . Id , Is . Not . Null ) ;
129- if ( vectorStore . Name ? . StartsWith ( "Test Vector Store " ) == true )
130- {
131- string idString = vectorStore . Name [ "Test Vector Store " . Length ..] ;
132-
133- Assert . That ( int . TryParse ( idString , out int seenId ) , Is . True ) ;
134- Assert . That ( seenId , Is . LessThan ( lastIdSeen ) ) ;
135- lastIdSeen = seenId ;
136- }
137- if ( lastIdSeen == 0 || ++ count >= 100 )
138- {
139- break ;
140- }
141- }
142-
143- Assert . That ( lastIdSeen , Is . EqualTo ( 0 ) ) ;
144- }
145-
146- [ AsyncOnly ]
147- [ Test ]
148- public async Task CanEnumerateVectorStoresAsync ( )
109+ public async Task CanEnumerateVectorStores ( )
149110 {
150111 VectorStoreClient client = GetTestClient ( ) ;
151112 for ( int i = 0 ; i < 5 ; i ++ )
@@ -160,7 +121,10 @@ public async Task CanEnumerateVectorStoresAsync()
160121 Assert . That ( vectorStore . Name , Is . EqualTo ( $ "Test Vector Store { i } ") ) ;
161122 }
162123
163- Thread . Sleep ( 5000 ) ;
124+ if ( Mode != RecordedTestMode . Playback )
125+ {
126+ await Task . Delay ( 5000 ) ;
127+ }
164128
165129 int lastIdSeen = int . MaxValue ;
166130 int count = 0 ;
@@ -214,7 +178,10 @@ public async Task CanAssociateFiles()
214178 _vectorStoreFilesToRemove . RemoveAt ( 0 ) ;
215179
216180 // Errata: removals aren't immediately reflected when requesting the list
217- Thread . Sleep ( 2000 ) ;
181+ if ( Mode != RecordedTestMode . Playback )
182+ {
183+ Thread . Sleep ( 2000 ) ;
184+ }
218185
219186 int count = 0 ;
220187
@@ -227,9 +194,8 @@ public async Task CanAssociateFiles()
227194 Assert . That ( count , Is . EqualTo ( 2 ) ) ;
228195 }
229196
230- [ AsyncOnly ]
231197 [ Test ]
232- public async Task Pagination_CanRehydrateVectorStoreFileCollectionAsync ( )
198+ public async Task Pagination_CanRehydrateVectorStoreFileCollection ( )
233199 {
234200 VectorStoreClient client = GetTestClient ( ) ;
235201 VectorStore vectorStore = await client . CreateVectorStoreAsync ( ) ;
@@ -255,7 +221,10 @@ public async Task Pagination_CanRehydrateVectorStoreFileCollectionAsync()
255221 Assert . That ( removalResult . FileId , Is . EqualTo ( files [ 0 ] . Id ) ) ;
256222
257223 // Errata: removals aren't immediately reflected when requesting the list
258- Thread . Sleep ( 2000 ) ;
224+ if ( Mode != RecordedTestMode . Playback )
225+ {
226+ Thread . Sleep ( 2000 ) ;
227+ }
259228
260229 // We added 6 files and will get pages with 2 items, so expect three pages in the collection.
261230
@@ -304,91 +273,8 @@ public async Task Pagination_CanRehydrateVectorStoreFileCollectionAsync()
304273 Assert . That ( pageCount , Is . EqualTo ( 2 ) ) ;
305274 }
306275
307- [ SyncOnly ]
308276 [ Test ]
309- public void Pagination_CanRehydrateVectorStoreFileCollection ( )
310- {
311- VectorStoreClient client = GetTestClient ( ) ;
312- VectorStore vectorStore = client . CreateVectorStore ( ) ;
313- Validate ( vectorStore ) ;
314-
315- List < OpenAIFile > files = [ ] ;
316-
317- OpenAIFileClient fileClient = GetProxiedOpenAIClient < OpenAIFileClient > ( TestScenario . Files ) ;
318- for ( int i = 0 ; i < 6 ; i ++ )
319- {
320- OpenAIFile file = fileClient . UploadFile (
321- BinaryData . FromString ( $ "This is a test file { i } ") . ToStream ( ) ,
322- $ "test_file_{ i . ToString ( ) . PadLeft ( 3 , '0' ) } .txt",
323- FileUploadPurpose . Assistants ) ;
324- Validate ( file ) ;
325- files . Add ( file ) ;
326- }
327-
328- foreach ( OpenAIFile file in files )
329- {
330- VectorStoreFile vectorStoreFile = client . AddFileToVectorStore ( vectorStore . Id , file . Id ) ;
331- Validate ( vectorStoreFile ) ;
332- Assert . Multiple ( ( ) =>
333- {
334- Assert . That ( vectorStoreFile . FileId , Is . EqualTo ( file . Id ) ) ;
335- Assert . That ( vectorStoreFile . VectorStoreId , Is . EqualTo ( vectorStore . Id ) ) ;
336- Assert . That ( vectorStoreFile . LastError , Is . Null ) ;
337- Assert . That ( vectorStoreFile . CreatedAt , Is . GreaterThan ( s_2024 ) ) ;
338- Assert . That ( vectorStoreFile . Status , Is . EqualTo ( VectorStoreFileStatus . InProgress ) ) ;
339- } ) ;
340- }
341-
342- FileFromStoreRemovalResult removalResult = client . RemoveFileFromVectorStore ( vectorStore . Id , files [ 0 ] . Id ) ;
343- Assert . That ( removalResult . FileId , Is . EqualTo ( files [ 0 ] . Id ) ) ;
344-
345- // Errata: removals aren't immediately reflected when requesting the list
346- Thread . Sleep ( 2000 ) ;
347-
348- CollectionResult < VectorStoreFile > vectorStoreFiles = client . GetVectorStoreFiles ( vectorStore . Id , new VectorStoreFileCollectionOptions ( ) { PageSizeLimit = 2 } ) ;
349- IEnumerable < ClientResult > pages = vectorStoreFiles . GetRawPages ( ) ;
350- IEnumerator < ClientResult > pageEnumerator = pages . GetEnumerator ( ) ;
351- pageEnumerator . MoveNext ( ) ;
352- ClientResult firstPage = pageEnumerator . Current ;
353- ContinuationToken nextPageToken = vectorStoreFiles . GetContinuationToken ( firstPage ) ;
354-
355- // Simulate rehydration of the collection
356- BinaryData rehydrationBytes = nextPageToken . ToBytes ( ) ;
357- ContinuationToken rehydrationToken = ContinuationToken . FromBytes ( rehydrationBytes ) ;
358-
359- CollectionResult < VectorStoreFile > rehydratedVectorStoreFiles = client . GetVectorStoreFiles ( vectorStore . Id , new VectorStoreFileCollectionOptions { AfterId = rehydrationToken . ToBytes ( ) . ToString ( ) , PageSizeLimit = 2 } ) ;
360- IEnumerable < ClientResult > rehydratedPages = rehydratedVectorStoreFiles . GetRawPages ( ) ;
361- IEnumerator < ClientResult > rehydratedPageEnumerator = rehydratedPages . GetEnumerator ( ) ;
362-
363- int pageCount = 0 ;
364-
365- while ( pageEnumerator . MoveNext ( ) && rehydratedPageEnumerator . MoveNext ( ) )
366- {
367- ClientResult page = pageEnumerator . Current ;
368- ClientResult rehydratedPage = rehydratedPageEnumerator . Current ;
369-
370- List < VectorStoreFile > itemsInPage = GetVectorStoreFilesFromPage ( page ) . ToList ( ) ;
371- List < VectorStoreFile > itemsInRehydratedPage = GetVectorStoreFilesFromPage ( rehydratedPage ) . ToList ( ) ;
372-
373- Assert . That ( itemsInRehydratedPage . Count , Is . EqualTo ( itemsInPage . Count ) ) ;
374-
375- for ( int i = 0 ; i < itemsInPage . Count ; i ++ )
376- {
377- Assert . That ( itemsInRehydratedPage [ 0 ] . FileId , Is . EqualTo ( itemsInPage [ 0 ] . FileId ) ) ;
378- Assert . That ( itemsInRehydratedPage [ 0 ] . VectorStoreId , Is . EqualTo ( itemsInPage [ 0 ] . VectorStoreId ) ) ;
379- Assert . That ( itemsInRehydratedPage [ 0 ] . CreatedAt , Is . EqualTo ( itemsInPage [ 0 ] . CreatedAt ) ) ;
380- Assert . That ( itemsInRehydratedPage [ 0 ] . Size , Is . EqualTo ( itemsInPage [ 0 ] . Size ) ) ;
381- }
382-
383- pageCount ++ ;
384- }
385-
386- Assert . That ( pageCount , Is . GreaterThanOrEqualTo ( 1 ) ) ;
387- }
388-
389- [ AsyncOnly ]
390- [ Test ]
391- public async Task CanPaginateGetVectorStoreFilesInBatchAsync ( )
277+ public async Task CanPaginateGetVectorStoreFilesInBatch ( )
392278 {
393279 VectorStoreClient client = GetTestClient ( ) ;
394280 VectorStore vectorStore = await client . CreateVectorStoreAsync ( ) ;
@@ -405,7 +291,10 @@ public async Task CanPaginateGetVectorStoreFilesInBatchAsync()
405291 Assert . That ( fileBatch . VectorStoreId , Is . EqualTo ( vectorStore . Id ) ) ;
406292 } ) ;
407293
408- await Task . Delay ( TimeSpan . FromSeconds ( 1 ) ) ;
294+ if ( Mode != RecordedTestMode . Playback )
295+ {
296+ await Task . Delay ( TimeSpan . FromSeconds ( 1 ) ) ;
297+ }
409298
410299 // Test basic pagination with PageSizeLimit
411300 var options = new VectorStoreFileCollectionOptions { PageSizeLimit = 3 } ;
@@ -461,9 +350,8 @@ public async Task CanPaginateGetVectorStoreFilesInBatchAsync()
461350 Assert . That ( itemsInPages , Is . EqualTo ( 10 ) ) ;
462351 }
463352
464- [ AsyncOnly ]
465353 [ Test ]
466- public async Task CanTestGetVectorStoreFilesInBatchAsyncCollectionOptions ( )
354+ public async Task CanTestGetVectorStoreFilesInBatchCollectionOptions ( )
467355 {
468356 VectorStoreClient client = GetTestClient ( ) ;
469357 VectorStore vectorStore = await client . CreateVectorStoreAsync ( ) ;
@@ -565,9 +453,8 @@ public async Task CanTestGetVectorStoreFilesInBatchAsyncCollectionOptions()
565453 }
566454 }
567455
568- [ AsyncOnly ]
569456 [ Test ]
570- public async Task CanRehydrateGetVectorStoreFilesInBatchAsyncPagination ( )
457+ public async Task CanRehydrateGetVectorStoreFilesInBatchPagination ( )
571458 {
572459 VectorStoreClient client = GetTestClient ( ) ;
573460 VectorStore vectorStore = await client . CreateVectorStoreAsync ( ) ;
@@ -577,7 +464,10 @@ public async Task CanRehydrateGetVectorStoreFilesInBatchAsyncPagination()
577464
578465 VectorStoreFileBatch fileBatch = await client . AddFileBatchToVectorStoreAsync ( vectorStore . Id , testFiles ? . Select ( file => file . Id ) ) ;
579466 Validate ( fileBatch ) ;
580- await Task . Delay ( TimeSpan . FromSeconds ( 1 ) ) ;
467+ if ( Mode != RecordedTestMode . Playback )
468+ {
469+ await Task . Delay ( TimeSpan . FromSeconds ( 1 ) ) ;
470+ }
581471
582472 // We added 6 files and will get pages with 2 items, so expect three pages in the collection.
583473 AsyncCollectionResult < VectorStoreFile > vectorStoreFiles = client . GetVectorStoreFilesInBatchAsync (
@@ -656,7 +546,10 @@ public async Task CanUseBatchIngestion()
656546 Assert . That ( fileBatch . Status , Is . EqualTo ( VectorStoreFileBatchStatus . InProgress ) ) ;
657547 } ) ;
658548
659- await Task . Delay ( TimeSpan . FromSeconds ( 1 ) ) ;
549+ if ( Mode != RecordedTestMode . Playback )
550+ {
551+ await Task . Delay ( TimeSpan . FromSeconds ( 1 ) ) ;
552+ }
660553
661554 await foreach ( VectorStoreFile vectorStoreFile in client . GetVectorStoreFilesAsync ( fileBatch . VectorStoreId ) )
662555 {
@@ -787,15 +680,18 @@ private async Task<IReadOnlyList<OpenAIFile>> GetNewTestFiles(int count)
787680 {
788681 List < OpenAIFile > files = [ ] ;
789682
790- OpenAIFileClient client = GetProxiedOpenAIClient < OpenAIFileClient > ( TestScenario . Files ) ;
791- for ( int i = 0 ; i < count ; i ++ )
683+ using ( Recording . DisableRequestBodyRecording ( ) ) // Temp pending https://github.com/Azure/azure-sdk-tools/issues/11901
792684 {
793- OpenAIFile file = await client . UploadFileAsync (
794- BinaryData . FromString ( $ "This is a test file { i } ") . ToStream ( ) ,
795- $ "test_file_{ i . ToString ( ) . PadLeft ( 3 , '0' ) } .txt",
796- FileUploadPurpose . Assistants ) ;
797- Validate ( file ) ;
798- files . Add ( file ) ;
685+ OpenAIFileClient client = GetProxiedOpenAIClient < OpenAIFileClient > ( TestScenario . Files ) ;
686+ for ( int i = 0 ; i < count ; i ++ )
687+ {
688+ OpenAIFile file = await client . UploadFileAsync (
689+ BinaryData . FromString ( $ "This is a test file { i } ") . ToStream ( ) ,
690+ $ "test_file_{ i . ToString ( ) . PadLeft ( 3 , '0' ) } .txt",
691+ FileUploadPurpose . Assistants ) ;
692+ Validate ( file ) ;
693+ files . Add ( file ) ;
694+ }
799695 }
800696
801697 return files ;
@@ -804,8 +700,13 @@ private async Task<IReadOnlyList<OpenAIFile>> GetNewTestFiles(int count)
804700 [ TearDown ]
805701 protected async Task Cleanup ( )
806702 {
807- OpenAIFileClient fileClient = GetProxiedOpenAIClient < OpenAIFileClient > ( TestScenario . Files ) ;
808- VectorStoreClient vectorStoreClient = GetProxiedOpenAIClient < VectorStoreClient > ( TestScenario . VectorStores ) ;
703+ if ( Mode == RecordedTestMode . Playback )
704+ {
705+ return ;
706+ }
707+
708+ OpenAIFileClient fileClient = GetTestClient < OpenAIFileClient > ( TestScenario . Files ) ;
709+ VectorStoreClient vectorStoreClient = GetTestClient < VectorStoreClient > ( TestScenario . VectorStores ) ;
809710 RequestOptions requestOptions = new ( )
810711 {
811712 ErrorOptions = ClientErrorBehaviors . NoThrow ,
0 commit comments