1
- // Copyright (C) 2003- 2016 Xtensive LLC.
2
- // All rights reserved .
3
- // For conditions of distribution and use, see license .
1
+ // Copyright (C) 2016-2025 Xtensive LLC.
2
+ // This code is distributed under MIT license terms .
3
+ // See the License.txt file in the project root for more information .
4
4
// Created by: Alexey Kulakov
5
5
// Created: 2016.12.09
6
6
7
7
using System ;
8
+ using System . Data . Common ;
8
9
using System . Linq ;
9
10
using System . Threading ;
10
11
using NUnit . Framework ;
11
12
using Xtensive . Core ;
12
13
using Xtensive . Orm . Providers ;
14
+ using Xtensive . Orm . Services ;
13
15
using Xtensive . Orm . Tests . ObjectModel ;
14
16
using Xtensive . Orm . Tests . ObjectModel . ChinookDO ;
15
17
@@ -25,8 +27,31 @@ protected override void CheckRequirements()
25
27
protected override Domain BuildDomain ( Xtensive . Orm . Configuration . DomainConfiguration configuration )
26
28
{
27
29
var domain = base . BuildDomain ( configuration ) ;
28
- Thread . Sleep ( TimeSpan . FromSeconds ( 6 ) ) ;
30
+ if ( StorageProviderInfo . Instance . Provider == StorageProvider . SqlServer ) {
31
+ using ( var session = domain . OpenSession ( ) )
32
+ using ( var tx = session . OpenTransaction ( ) ) {
33
+ var sqlAccessor = session . Services . Get < DirectSqlAccessor > ( ) ;
34
+ var timeout = DateTime . UtcNow . AddSeconds ( 20 ) ;
35
+ while ( ! CheckFtIndexesPopulated ( sqlAccessor . CreateCommand ( ) ) && DateTime . UtcNow < timeout ) {
36
+ Console . WriteLine ( "There are unpopulated FT indexes. Waiting" ) ;
37
+ Thread . Sleep ( TimeSpan . FromSeconds ( 2 ) ) ;
38
+ }
39
+ return domain ;
40
+ }
41
+ }
42
+ else {
43
+ Thread . Sleep ( TimeSpan . FromSeconds ( 6 ) ) ;
44
+ }
29
45
return domain ;
46
+
47
+
48
+ static bool CheckFtIndexesPopulated ( DbCommand sqlCommand )
49
+ {
50
+ using ( sqlCommand ) {
51
+ sqlCommand . CommandText = $ "SELECT COUNT(*) FROM [{ WellKnownDatabases . MultiDatabase . MainDb } ].sys.fulltext_indexes WHERE has_crawl_completed=0";
52
+ return ( ( int ) sqlCommand . ExecuteScalar ( ) ) == 0 ;
53
+ }
54
+ }
30
55
}
31
56
32
57
[ Test ]
0 commit comments