-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix to #21402 - Test using OData #22367
Conversation
382b0e5
to
1728bb2
Compare
test/EFCore.OData.Tests/Query/ComplexNavigationsODataQueryTests.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we using OData end to end to generate queries? There is quite a lot of code here which builds/arranges stuff, is this what we are adding to simulate OData or some of it is part of OData query handling?
|
||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
modelBuilder.Entity<Level1>().Property(e => e.Id).ValueGeneratedNever(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any OData specific configuration here?
If not, can we just reuse our context definitions from specs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hit some issues with efcore specific stuff, e.g. keyless entities (but that was early on in the development process, could check again). Also the proper context needs to be injected into controllers. Did the easy thing for now just to get tests going. Was planning to tweak this in future checkins
test/EFCore.OData.Tests/Query/ComplexNavigationsODataQueryTests.cs
Outdated
Show resolved
Hide resolved
test/EFCore.OData.Tests/Query/ComplexNavigationsODataQueryTests.cs
Outdated
Show resolved
Hide resolved
test/EFCore.OData.Tests/Query/NorthwindODataQueryTestFixture.cs
Outdated
Show resolved
Hide resolved
You should add an entry to |
test/EFCore.OData.Tests/Query/ComplexNavigationsODataQueryTests.cs
Outdated
Show resolved
Hide resolved
e.Ignore(o => o.ShipPostalCode); | ||
e.Ignore(o => o.ShipRegion); | ||
e.Ignore(o => o.ShipVia); | ||
e.Ignore(o => o.ShippedDate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are so many properties ignored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what we do in northwind, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we reuse existing code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copied from the original northwind
Do the test initialize their own databases? I.e. if you drop all databases and just run these tests |
@AndriySvyryd tests fixture inherits from NorthwindQuerySqlServerFixture so it automatically provisions the database when necessary. |
We shouldn't use the same database across test assemblies as that causes a race condition. Either rename it, use a different model or merge with SQL Server FTs. |
Will rename. I'm bit scared of adding all the odata dependencies to our existing test suites. |
b23da19
to
82f5eaf
Compare
refactored and updated @smitpatel @AndriySvyryd |
5e8f44d
to
52eb707
Compare
test/EFCore.OData.FunctionalTests/Query/ComplexNavigationsODataContext.cs
Show resolved
Hide resolved
test/EFCore.OData.FunctionalTests/Query/GearsOfWarODataQueryTests.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -0,0 +1,19 @@ | |||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This concerns me, but then again it might be totally fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit odd. Even in AspNetCore we only use Microsoft.NET.Sdk for tests. Why do you need .Web here? Because of the shared framework dependencies it brings in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need HttpGet/ControllerBase/ModelBinder from MVC to run these tests. Reference to Web SDK is needed.
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks> | ||
<AssemblyName>Microsoft.EntityFrameworkCore.OData.FunctionalTests</AssemblyName> | ||
<RootNamespace>Microsoft.EntityFrameworkCore</RootNamespace> | ||
<IsPackable>true</IsPackable> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to publish this one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added it because CI was complaining, will check again without as I changed some stuff there
test/EFCore.OData.FunctionalTests/Query/ComplexNavigationsODataQueryTestFixture.cs
Outdated
Show resolved
Hide resolved
test/EFCore.OData.FunctionalTests/Query/GearsOfWarODataQueryTestFixture.cs
Outdated
Show resolved
Hide resolved
test/EFCore.OData.FunctionalTests/Query/GearsOfWarODataQueryTestFixture.cs
Outdated
Show resolved
Hide resolved
test/EFCore.OData.FunctionalTests/Query/NorthwindODataQueryTestFixture.cs
Outdated
Show resolved
Hide resolved
@smitpatel @bricelam do you have a clue why the helix job has failed? the tests seem to be all passing/skipped |
Looking at previous iterations of the run and windows is still running, there is some still running process. Runs are getting timed out (even though xunit test run finished). |
7528096
to
3ed7c55
Compare
3ed7c55
to
edc05e6
Compare
test/EFCore.OData.FunctionalTests/Query/ComplexNavigationsODataQueryTestFixture.cs
Outdated
Show resolved
Hide resolved
6aae7bf
to
ca22bab
Compare
test/EFCore.OData.FunctionalTests/Query/ODataQueryTestFixtureInitializer.cs
Outdated
Show resolved
Hide resolved
test/EFCore.OData.FunctionalTests/Query/ODataQueryTestFixtureInitializer.cs
Outdated
Show resolved
Hide resolved
test/EFCore.OData.FunctionalTests/Query/ComplexNavigationsODataQueryTestFixture.cs
Outdated
Show resolved
Hide resolved
ca22bab
to
9d1411f
Compare
@smitpatel ping for the final check |
|
||
public IHttpClientFactory ClientFactory { get; private set; } | ||
|
||
public override async Task DisposeAsync() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we moved _selfHostServer to the interface too and implemented this as DIM? 💡
test/EFCore.OData.FunctionalTests/Query/NorthwindODataQueryTests.cs
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,19 @@ | |||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit odd. Even in AspNetCore we only use Microsoft.NET.Sdk for tests. Why do you need .Web here? Because of the shared framework dependencies it brings in?
test/EFCore.OData.FunctionalTests/Properties/launchSettings.json
Outdated
Show resolved
Hide resolved
|
||
namespace Microsoft.EntityFrameworkCore.Query | ||
{ | ||
public sealed class EndpointRouteConfiguration : IEndpointRouteBuilder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems overkill. @javiercn ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree,
I'm not sure what you are trying to achieve here, but there's definitely a better way to do it than this.
test/EFCore.OData.FunctionalTests/Query/ODataQueryTestFixtureInitializer.cs
Outdated
Show resolved
Hide resolved
test/EFCore.OData.FunctionalTests/Query/ODataQueryTestFixtureInitializer.cs
Show resolved
Hide resolved
test/EFCore.OData.FunctionalTests/Query/ODataQueryTestFixtureInitializer.cs
Outdated
Show resolved
Hide resolved
@Tratcher iirc I used blank Asp.net core web app as the basis for the project - I modified the project to Microsoft.NET.Sdk and it works fine |
9d1411f
to
d673162
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The host changes look good. I'm still not sure why you needed to implement a IEndpointRouteBuilder.
|
||
namespace Microsoft.EntityFrameworkCore.Query | ||
{ | ||
public class ODataQueryTestFixtureInitializer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is overkill, I would recommend you replace all/most of the infrastructure with the library we ship to do this type of testing. See here for details
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just saw that you are spinning up kestrel, I would avoid that if you can, because it'll make tests faster and much more stable.
d673162
to
8c19f14
Compare
Adding infrastructure and rudimentary tests using OData. Ported Northwind, ComplexNavigations and GearsOfWar models. Only setup for sqlserver currently. Resolves #21402
8c19f14
to
d9a4350
Compare
Adding infrastructure and rudimentary tests using OData. Ported Northwind, ComplexNavigations and GearsOfWar models. Only setup for sqlserver currently.
Resolves #21402