-
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
Implement functional migration tests #19353
Conversation
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.
Here are some specific comments
b.Property<string>("NormalizedName") | ||
.HasMaxLength(256); | ||
[ConditionalFact(Skip = "Column 'FullName' in table 'People' is of a type that is invalid for use as a key column in an index.")] | ||
public override async Task AlterColumnOperation_change_computed_with_index() |
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 fails with Column 'FullName' in table 'People' is of a type that is invalid for use as a key column in an index.
, is that expected?
|
||
[ConditionalFact] | ||
public virtual void Can_get_active_provider() | ||
public virtual async Task CreateTableOperation_all_settings() |
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 test is somewhat useless since a database must support everything in order to run it (e.g. Sqlite disables it). Better to just remove and leave the feature-by-feature tests?
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 doesn't SQLite support here?
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.
Schema, check constraints...
Am going to leave as-is (ignored for Sqlite) and we can re-discuss in cleanup if this test is valuable or not...
test/EFCore.SqlServer.FunctionalTests/MigrationsSqlServerTest.cs
Outdated
Show resolved
Hide resolved
|
||
b.HasKey("LoginProvider", "ProviderKey"); | ||
[ConditionalFact(Skip = "Doesn't work")] | ||
public virtual async Task AlterColumnOperation_remove_identity() |
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.
Like AlterColumnOperation_make_identity, this fails with: To change the IDENTITY property of a column, the column needs to be dropped and recreated., is this expected?
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.
Expected.
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.
Removed, thanks.
} | ||
|
||
public override void Can_generate_one_up_script() | ||
// In Sqlite, comments are only generated when creating a table |
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 can only see comments generated for CreateTableOperation... I'm guessing this is intentional?
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.
Yes. It's not possible to add these with ALTER TABLE..ADD statements.
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.
Thanks, will leave these overrides to assert the actual behavior.
{ | ||
// Build the source and target models. Add current/latest product version if one wasn't set. | ||
var sourceModelBuilder = Fixture.TestHelp |
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.
For higher fidelity the source builder shouldn't have conventions, that's how the snapshot is built and we have had several bugs that were hidden by conventions. However it will require more configuration to actually set up the tests.
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
Regarding MigrationsModelDifferTest, I agree we can probably remove it.
|
||
[ConditionalFact] | ||
public virtual void Can_get_active_provider() | ||
public virtual async Task CreateTableOperation_all_settings() |
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 doesn't SQLite support here?
|
||
b.HasKey("LoginProvider", "ProviderKey"); | ||
[ConditionalFact(Skip = "Doesn't work")] | ||
public virtual async Task AlterColumnOperation_remove_identity() |
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.
Expected.
test/EFCore.SqlServer.FunctionalTests/MigrationsSqlServerTest.cs
Outdated
Show resolved
Hide resolved
|
||
b.ToTable("AspNetUserLogins"); | ||
}); | ||
// AlterColumnOperation_remove_identity_legacy |
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 test is important to make sure that old model snapshots are handled correctly. Do we still have coverage for this?
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'll leave this test (and others like it) in MigrationSqlGeneratorTestBase and we can rediscuss later (will note in cleanup issue).
} | ||
|
||
public override void Can_generate_one_up_script() | ||
// In Sqlite, comments are only generated when creating a table |
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.
Yes. It's not possible to add these with ALTER TABLE..ADD statements.
552280c
to
9b8292d
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.
@bricelam @AndriySvyryd did a final big cleanup pass and addressed all comments. Another quick sign-off would be great.
- The tests now use a conventionless model builder.
- I've removed everything in the MigrationSqlGeneratorTest (unit) test suites that is covered by the newer MigrationsTest (functional) test suite. Some things still remain, we should ideally take another look at some point (Remaining clean up for migration tests #19668). I haven't touched the ModelDifferTests because this PR is already big enough (again, Remaining clean up for migration tests #19668).
- I've renamed the migration tests and grouped them by type (table, column, index...) and then by operation (create, alter, drop...).
|
||
[ConditionalFact] | ||
public virtual void Can_get_active_provider() | ||
public virtual async Task CreateTableOperation_all_settings() |
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.
Schema, check constraints...
Am going to leave as-is (ignored for Sqlite) and we can re-discuss in cleanup if this test is valuable or not...
|
||
b.HasKey("LoginProvider", "ProviderKey"); | ||
[ConditionalFact(Skip = "Doesn't work")] | ||
public virtual async Task AlterColumnOperation_remove_identity() |
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.
Removed, thanks.
|
||
b.ToTable("AspNetUserLogins"); | ||
}); | ||
// AlterColumnOperation_remove_identity_legacy |
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'll leave this test (and others like it) in MigrationSqlGeneratorTestBase and we can rediscuss later (will note in cleanup issue).
test/EFCore.SqlServer.FunctionalTests/MigrationsSqlServerTest.cs
Outdated
Show resolved
Hide resolved
} | ||
|
||
public override void Can_generate_one_up_script() | ||
// In Sqlite, comments are only generated when creating a table |
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.
Thanks, will leave these overrides to assert the actual behavior.
|
||
b.HasKey("Id"); | ||
[C |
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.
You'll need to create a test condition for online indexes.
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.
Thanks. Added an enum value to SqlServerCondition and configured config.json to false for LocalDB, but am not sure how to set up true in CI. Will merge now and we can fix as part of #19668.
28eeadb
to
1a03e66
Compare
This adds functional migration tests which perform DDL operations on the database.
The total running time of the SQL Server suite is roughly the same as before, thanks to test parallelism and async I/O. ❤️
Closes #19039
Replaces #19258