Skip to content

Commit 3d7a066

Browse files
committed
Fix SQL Server tests
Upgrade Helix project
1 parent 352ef4f commit 3d7a066

51 files changed

Lines changed: 1027 additions & 237 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agents/skills/cosmos-provider/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ Non-relational provider with its own parallel query pipeline. Uses JSON for docu
1919
## Azure Cosmos DB Emulator for Tests
2020

2121
- `TestEnvironment.InitializeAsync()` auto-starts a `Testcontainers.CosmosDb` container when `Test__Cosmos__DefaultConnection` is not set. Set the env var to use an existing emulator instead.
22-
- Skip tests requiring unsupported features on the Linux emulator with `[CosmosCondition(CosmosCondition.IsNotLinuxEmulator)]`.
22+
- Skip tests requiring unsupported features on the Linux emulator with ` [ConditionalFact(typeof(CosmosTestEnvironment), nameof(CosmosTestEnvironment.IsNotLinuxEmulator))]`.

azure-pipelines-internal-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ extends:
197197
- job: Linux_Cosmos
198198
displayName: 'Linux Cosmos'
199199
condition: notin(variables['Build.Reason'], 'PullRequest', 'Schedule')
200-
timeoutInMinutes: 210
200+
timeoutInMinutes: 300
201201
pool:
202202
name: $(DncEngInternalBuildPool)
203203
demands: ImageOverride -equals 1es-ubuntu-2204

eng/Versions.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<OpenTelemetryExporterInMemoryVersion>1.15.1</OpenTelemetryExporterInMemoryVersion>
5353
<SQLitePCLRawVersion>3.0.3</SQLitePCLRawVersion>
5454
<SQLite3MCPCLRawBundleVersion>2.3.2</SQLite3MCPCLRawBundleVersion>
55+
<XUnitV3Version>4.0.0-pre.108</XUnitV3Version>
5556
<MicrosoftDotNetXUnitV3ExtensionsVersion>11.0.0-beta.26263.112</MicrosoftDotNetXUnitV3ExtensionsVersion>
5657
<MicrosoftTestingPlatformVersion>2.2.2</MicrosoftTestingPlatformVersion>
5758
</PropertyGroup>

eng/helix.proj

Lines changed: 49 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -41,89 +41,97 @@
4141
</ItemGroup>
4242

4343
<ItemGroup>
44-
<XUnitProject Include="$(RepoRoot)/test/**/*.csproj"/>
45-
<XUnitProject Include="$(RepoRoot)/test/**/*.fsproj"/>
46-
<XUnitProject Remove="$(RepoRoot)/test/EFCore.Specification.Tests/*.csproj"/>
47-
<XUnitProject Remove="$(RepoRoot)/test/EFCore.AspNet.Specification.Tests/*.csproj"/>
48-
<XUnitProject Remove="$(RepoRoot)/test/EFCore.Relational.Specification.Tests/*.csproj"/>
44+
<XUnitV3Project Include="$(RepoRoot)/test/**/*.csproj"/>
45+
<XUnitV3Project Include="$(RepoRoot)/test/**/*.fsproj"/>
46+
<XUnitV3Project Remove="$(RepoRoot)/test/EFCore.Specification.Tests/*.csproj"/>
47+
<XUnitV3Project Remove="$(RepoRoot)/test/EFCore.AspNet.Specification.Tests/*.csproj"/>
48+
<XUnitV3Project Remove="$(RepoRoot)/test/EFCore.Relational.Specification.Tests/*.csproj"/>
4949
<!-- The trimming and NativeAOT test projects are console programs -->
50-
<XUnitProject Remove="$(RepoRoot)/test/EFCore.TrimmingTests/*.csproj"/>
51-
<XUnitProject Remove="$(RepoRoot)/test/EFCore.NativeAotTests/*.csproj"/>
50+
<XUnitV3Project Remove="$(RepoRoot)/test/EFCore.TrimmingTests/*.csproj"/>
51+
<XUnitV3Project Remove="$(RepoRoot)/test/EFCore.NativeAotTests/*.csproj"/>
5252
<!-- API baseline tests require source files and cannot run in Helix -->
53-
<XUnitProject Remove="$(RepoRoot)/test/EFCore.ApiBaseline.Tests/*.csproj"/>
53+
<XUnitV3Project Remove="$(RepoRoot)/test/EFCore.ApiBaseline.Tests/*.csproj"/>
54+
</ItemGroup>
55+
56+
<!--
57+
Skip tests tagged with the "failing" category. Microsoft.DotNet.XUnitV3Extensions attributes
58+
such as [ConditionalClass]/[ConditionalAssembly] add `category=failing` to tests whose
59+
condition evaluates to false; this filter is what actually skips them at the runner.
60+
-->
61+
<ItemGroup>
62+
<XUnitV3Project Update="@(XUnitV3Project)">
63+
<Arguments>$(XUnitV3Arguments) --filter-not-trait category=failing</Arguments>
64+
</XUnitV3Project>
5465
</ItemGroup>
5566

5667
<!-- Work-around for https://github.com/dotnet/runtime/issues/70758 -->
5768
<ItemGroup Condition = "'$(HelixTargetQueue.StartsWith(`OSX`))'">
58-
<XUnitProject Update="$(RepoRoot)/test/EFCore.InMemory.FunctionalTests/*.csproj;$(RepoRoot)/test/EFCore.Sqlite.FunctionalTests/*.csproj;$(RepoRoot)/test/ef.Tests/*.csproj">
69+
<XUnitV3Project Update="$(RepoRoot)/test/EFCore.InMemory.FunctionalTests/*.csproj;$(RepoRoot)/test/EFCore.Sqlite.FunctionalTests/*.csproj;$(RepoRoot)/test/ef.Tests/*.csproj">
5970
<PreCommands>$(PreCommands); export COMPlus_EnableWriteXorExecute=0</PreCommands>
60-
</XUnitProject>
71+
</XUnitV3Project>
6172
</ItemGroup>
6273

6374
<ItemGroup Condition = "'$(HelixTargetQueue.StartsWith(`Windows.10.Amd64`))'">
64-
<XUnitProject Remove="$(CosmosTests)"/>
65-
<XUnitProject Remove="$(SqlServerTests)"/>
66-
<XUnitProject Update="@(XUnitProject)">
75+
<XUnitV3Project Remove="$(CosmosTests)"/>
76+
<XUnitV3Project Remove="$(SqlServerTests)"/>
77+
<XUnitV3Project Update="@(XUnitV3Project)">
6778
<PreCommands>$(PreCommands); set "Test__SqlServer__DefaultConnection=Data Source="</PreCommands>
68-
</XUnitProject>
79+
</XUnitV3Project>
6980
</ItemGroup>
7081

7182
<ItemGroup Condition = "'$(HelixTargetQueue.StartsWith(`Windows.11.Arm64`))'">
72-
<XUnitProject Remove="$(SqlServerTests)"/>
73-
<XUnitProject Remove="$(CosmosTests)"/>
74-
<XUnitProject Update="@(XUnitProject)">
83+
<XUnitV3Project Remove="$(SqlServerTests)"/>
84+
<XUnitV3Project Remove="$(CosmosTests)"/>
85+
<XUnitV3Project Update="@(XUnitV3Project)">
7586
<PreCommands>$(PreCommands); set "Test__SqlServer__DefaultConnection=Data Source="</PreCommands>
76-
</XUnitProject>
87+
</XUnitV3Project>
7788
</ItemGroup>
7889

7990
<ItemGroup Condition = "'$(HelixTargetQueue.StartsWith(`Windows.11.Amd64.Client`))'">
80-
<XUnitProject Remove="$(RepoRoot)/test/**/*.csproj"/>
81-
<XUnitProject Remove="$(RepoRoot)/test/**/*.fsproj"/>
82-
<XUnitProject Include="$(SqlServerTests)">
91+
<XUnitV3Project Remove="$(RepoRoot)/test/**/*.csproj"/>
92+
<XUnitV3Project Remove="$(RepoRoot)/test/**/*.fsproj"/>
93+
<XUnitV3Project Include="$(SqlServerTests)">
8394
<PreCommands>$(PreCommands); SqlLocalDB start</PreCommands>
84-
</XUnitProject>
95+
</XUnitV3Project>
8596
</ItemGroup>
8697

8798
<ItemGroup Condition = "'$(HelixTargetQueue.StartsWith(`Windows.Server2025.Amd64`))'">
88-
<XUnitProject Remove="$(RepoRoot)/test/**/*.csproj"/>
89-
<XUnitProject Remove="$(RepoRoot)/test/**/*.fsproj"/>
90-
<XUnitProject Include="$(CosmosTests)">
99+
<XUnitV3Project Remove="$(RepoRoot)/test/**/*.csproj"/>
100+
<XUnitV3Project Remove="$(RepoRoot)/test/**/*.fsproj"/>
101+
<XUnitV3Project Include="$(CosmosTests)">
91102
<PreCommands>$(PreCommands); call %HELIX_CORRELATION_PAYLOAD%\testing\WaitCosmosEmulator.cmd; set Test__Cosmos__DefaultConnection=https://localhost:8081; set Test__Cosmos__SkipConnectionCheck=true</PreCommands>
92-
</XUnitProject>
103+
</XUnitV3Project>
93104
</ItemGroup>
94105

95106
<!-- Start SqlServer instance for test projects which uses SqlServer on docker. Only run SqlServer tests. -->
96107
<ItemGroup Condition = "'$(HelixTargetQueue.Contains(`helix-sqlserver`))'">
97-
<XUnitProject Remove="$(RepoRoot)/test/**/*.csproj"/>
98-
<XUnitProject Remove="$(RepoRoot)/test/**/*.fsproj"/>
99-
<XUnitProject Include="$(SqlServerTests)">
108+
<XUnitV3Project Remove="$(RepoRoot)/test/**/*.csproj"/>
109+
<XUnitV3Project Remove="$(RepoRoot)/test/**/*.fsproj"/>
110+
<XUnitV3Project Include="$(SqlServerTests)">
100111
<PreCommands>$(PreCommands); export MSSQL_SA_PASSWORD=$(MSSQL_SA_PASSWORD); export Test__SqlServer__DefaultConnection="Server=localhost;;Database=master;;User=sa;;Password=$(MSSQL_SA_PASSWORD);;Connect Timeout=60;;ConnectRetryCount=0;;TrustServerCertificate=True"; /opt/mssql/bin/sqlservr --accept-eula &amp;; sleep 120; </PreCommands>
101-
</XUnitProject>
112+
</XUnitV3Project>
102113
</ItemGroup>
103114

104115
<!-- Run Cosmos tests on Ubuntu with Docker support (testcontainer auto-starts the emulator) -->
105116
<ItemGroup Condition = "'$(HelixTargetQueue)' == 'Ubuntu.2204.Amd64.XL.Open' OR '$(HelixTargetQueue)' == 'Ubuntu.2204.Amd64.XL'">
106-
<XUnitProject Remove="$(RepoRoot)/test/**/*.csproj"/>
107-
<XUnitProject Remove="$(RepoRoot)/test/**/*.fsproj"/>
108-
<XUnitProject Include="$(CosmosTests)"/>
117+
<XUnitV3Project Remove="$(RepoRoot)/test/**/*.csproj"/>
118+
<XUnitV3Project Remove="$(RepoRoot)/test/**/*.fsproj"/>
119+
<XUnitV3Project Include="$(CosmosTests)"/>
109120
</ItemGroup>
110121

111122
<!-- Run tests that don't need SqlServer or Cosmos on bare Ubuntu -->
112123
<ItemGroup Condition = "'$(HelixTargetQueue)' == 'Ubuntu.2204.Amd64.Open' OR '$(HelixTargetQueue)' == 'Ubuntu.2204.Amd64'">
113-
<XUnitProject Remove="$(SqlServerTests)"/>
114-
<XUnitProject Remove="$(CosmosTests)"/>
124+
<XUnitV3Project Remove="$(SqlServerTests)"/>
125+
<XUnitV3Project Remove="$(CosmosTests)"/>
115126
</ItemGroup>
116127

117128
<!-- Remove test projects which require SqlServer or Cosmos from OSX -->
118129
<ItemGroup Condition = "'$(HelixTargetQueue.StartsWith(`OSX`))'">
119-
<XUnitProject Remove="$(SqlServerTests)"/>
120-
<XUnitProject Remove="$(CosmosTests)"/>
130+
<XUnitV3Project Remove="$(SqlServerTests)"/>
131+
<XUnitV3Project Remove="$(CosmosTests)"/>
121132
</ItemGroup>
122133

123134
<PropertyGroup>
124-
<XUnitPublishTargetFramework>$(NetCurrent)</XUnitPublishTargetFramework>
125-
<XUnitRuntimeTargetFramework>netcoreapp2.0</XUnitRuntimeTargetFramework>
126-
<XUnitArguments>-verbose</XUnitArguments>
127-
<XUnitWorkItemTimeout Condition = "'$(XUnitWorkItemTimeout)' == ''">02:00:00</XUnitWorkItemTimeout>
135+
<XUnitWorkItemTimeout Condition = "'$(XUnitWorkItemTimeout)' == ''">03:00:00</XUnitWorkItemTimeout>
128136
</PropertyGroup>
129137
</Project>

global.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
],
1010
"errorMessage": "The required .NET SDK wasn't found. Please run ./restore.sh or .\\restore.cmd to install it."
1111
},
12+
"test": {
13+
"runner": "Microsoft.Testing.Platform"
14+
},
1215
"tools": {
1316
"dotnet": "11.0.100-preview.5.26227.104",
1417
"runtimes": {

src/EFCore/Metadata/Internal/ForeignKey.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,7 @@ public virtual IDependentKeyValueFactory DependentKeyValueFactory
951951
if (field == null)
952952
{
953953
EnsureReadOnly();
954+
((IKey)PrincipalKey).GetPrincipalKeyValueFactory();
954955
}
955956

956957
return field!;

src/EFCore/Metadata/RuntimeForeignKey.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,18 +259,25 @@ IEnumerable<IReadOnlySkipNavigation> IReadOnlyForeignKey.GetReferencingSkipNavig
259259
/// <inheritdoc />
260260
[DebuggerStepThrough]
261261
IDependentKeyValueFactory<TKey> IForeignKey.GetDependentKeyValueFactory<TKey>()
262-
=> (IDependentKeyValueFactory<TKey>)_dependentKeyValueFactory!;
262+
=> (IDependentKeyValueFactory<TKey>)((IRuntimeForeignKey)this).DependentKeyValueFactory;
263263

264264
/// <inheritdoc />
265265
[DebuggerStepThrough]
266266
IDependentKeyValueFactory IForeignKey.GetDependentKeyValueFactory()
267-
=> _dependentKeyValueFactory!;
267+
=> ((IRuntimeForeignKey)this).DependentKeyValueFactory;
268268

269269
/// <inheritdoc />
270270
IDependentKeyValueFactory IRuntimeForeignKey.DependentKeyValueFactory
271271
{
272272
[DebuggerStepThrough]
273-
get => _dependentKeyValueFactory!;
273+
get
274+
{
275+
if (_dependentKeyValueFactory == null)
276+
{
277+
((IKey)PrincipalKey).GetPrincipalKeyValueFactory();
278+
}
279+
return _dependentKeyValueFactory!;
280+
}
274281

275282
[DebuggerStepThrough]
276283
set => _dependentKeyValueFactory = value;

test/Directory.Build.props

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,23 @@
66
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)..\rulesets\EFCore.test.ruleset</CodeAnalysisRuleSet>
77
<LangVersion>preview</LangVersion>
88
<NuGetAudit>false</NuGetAudit>
9+
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
910
</PropertyGroup>
1011

11-
<PropertyGroup Condition="'$(IsUnitTestProject)' == 'true'">
12+
<PropertyGroup Condition="'$(IsTestProject)' != 'false'">
13+
<OutputType>Exe</OutputType>
1214
<TestRunnerName>XUnitV3</TestRunnerName>
15+
16+
<!--
17+
Exclude tests tagged with the "failing" category. Microsoft.DotNet.XUnitV3Extensions
18+
attributes such as [ConditionalClass]/[ConditionalAssembly] add `category=failing` to tests
19+
whose condition evaluates to false; this filter is what actually skips them at the runner.
20+
Plumbed through both Arcade's RunTests target (used by test.cmd / test.sh /
21+
eng/common/build.* with the test switch) and the Microsoft.Testing.Platform MSBuild target
22+
(used by `dotnet test` and VS Test Explorer).
23+
-->
24+
<TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments) --filter-not-trait category=failing --ignore-exit-code 8</TestRunnerAdditionalArguments>
25+
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --filter-not-trait category=failing --ignore-exit-code 8</TestingPlatformCommandLineArguments>
1326
</PropertyGroup>
1427

1528
</Project>

test/EFCore.AspNet.Specification.Tests/EFCore.AspNet.Specification.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<Nullable>disable</Nullable>
99
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1010
<IsPackable>true</IsPackable>
11+
<!-- This project contains base tests to be used by providers, but is not itself a test project with
12+
tests to be executed. Disable test discovery. -->
13+
<IsTestProject>false</IsTestProject>
1114
<IncludeSymbols>true</IncludeSymbols>
1215
<ImplicitUsings>true</ImplicitUsings>
1316
<NoWarn>$(NoWarn);8981</NoWarn>

test/EFCore.Cosmos.FunctionalTests/Query/Translations/VectorSearchTranslationsCosmosTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Microsoft.EntityFrameworkCore.Query.Translations;
88

9-
[CosmosCondition(CosmosCondition.IsNotLinuxEmulator)]
9+
[ConditionalClass(typeof(CosmosTestEnvironment), nameof(CosmosTestEnvironment.IsNotLinuxEmulator))]
1010
public class VectorSearchTranslationsCosmosTest : IClassFixture<VectorSearchTranslationsCosmosTest.VectorSearchFixture>
1111
{
1212
public VectorSearchTranslationsCosmosTest(VectorSearchFixture fixture, ITestOutputHelper testOutputHelper)

0 commit comments

Comments
 (0)