Skip to content

Commit c27622b

Browse files
committed
Merge branch '7.1' into 7.1-filter-ms-tables
2 parents 5070e1b + f6a7388 commit c27622b

File tree

2 files changed

+56
-7
lines changed

2 files changed

+56
-7
lines changed

Orm/Xtensive.Orm.Tests/Linq/ContainsTableTest.cs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
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.
44
// Created by: Alexey Kulakov
55
// Created: 2016.12.09
66

77
using System;
8+
using System.Data.Common;
89
using System.Linq;
910
using System.Threading;
1011
using NUnit.Framework;
1112
using Xtensive.Core;
1213
using Xtensive.Orm.Providers;
14+
using Xtensive.Orm.Services;
1315
using Xtensive.Orm.Tests.ObjectModel;
1416
using Xtensive.Orm.Tests.ObjectModel.ChinookDO;
1517

@@ -25,8 +27,31 @@ protected override void CheckRequirements()
2527
protected override Domain BuildDomain(Xtensive.Orm.Configuration.DomainConfiguration configuration)
2628
{
2729
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+
}
2945
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+
}
3055
}
3156

3257
[Test]

Orm/Xtensive.Orm.Tests/Linq/FreeTextTest.cs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
// Copyright (C) 2009-2021 Xtensive LLC.
1+
// Copyright (C) 2009-2025 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Alexis Kochetov
55
// Created: 2009.12.14
66

77
using System;
8+
using System.Data.Common;
89
using System.Collections.Generic;
10+
using System.Linq;
911
using System.Threading;
1012
using NUnit.Framework;
1113
using Xtensive.Orm.Providers;
14+
using Xtensive.Orm.Services;
1215
using Xtensive.Orm.Tests.ObjectModel;
1316
using Xtensive.Orm.Tests.ObjectModel.ChinookDO;
14-
using System.Linq;
1517

1618
namespace Xtensive.Orm.Tests.Linq
1719
{
@@ -25,8 +27,30 @@ protected override void CheckRequirements()
2527
protected override Domain BuildDomain(Xtensive.Orm.Configuration.DomainConfiguration configuration)
2628
{
2729
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+
Thread.Sleep(TimeSpan.FromSeconds(2));
37+
}
38+
return domain;
39+
}
40+
}
41+
else {
42+
Thread.Sleep(TimeSpan.FromSeconds(6));
43+
}
2944
return domain;
45+
46+
47+
static bool CheckFtIndexesPopulated(DbCommand sqlCommand)
48+
{
49+
using (sqlCommand) {
50+
sqlCommand.CommandText = $"SELECT COUNT(*) FROM [{WellKnownDatabases.MultiDatabase.MainDb}].sys.fulltext_indexes WHERE has_crawl_completed=0";
51+
return ((int) sqlCommand.ExecuteScalar()) == 0;
52+
}
53+
}
3054
}
3155

3256
[Test]

0 commit comments

Comments
 (0)