Skip to content
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 Azure SQL tests #34676

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.cs diff=csharp
*.sh eol=lf
*.sln eol=crlf
*.sql diff
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Microsoft.EntityFrameworkCore;

#nullable disable

[SqlServerCondition(SqlServerCondition.IsNotSqlAzure | SqlServerCondition.SupportsUtf8)]
[SqlServerCondition(SqlServerCondition.IsNotAzureSql | SqlServerCondition.SupportsUtf8)]
public class BuiltInDataTypesSqlServerTest : BuiltInDataTypesTestBase<BuiltInDataTypesSqlServerTest.BuiltInDataTypesSqlServerFixture>
{
private static readonly string _eol = Environment.NewLine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Microsoft.EntityFrameworkCore;

#nullable disable

[SqlServerCondition(SqlServerCondition.IsNotSqlAzure)]
[SqlServerCondition(SqlServerCondition.IsNotAzureSql)]
public class ConvertToProviderTypesSqlServerTest(ConvertToProviderTypesSqlServerTest.ConvertToProviderTypesSqlServerFixture fixture)
: ConvertToProviderTypesTestBase<
ConvertToProviderTypesSqlServerTest.ConvertToProviderTypesSqlServerFixture>(fixture)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore;

#nullable disable

[SqlServerCondition(SqlServerCondition.IsNotSqlAzure)]
[SqlServerCondition(SqlServerCondition.IsNotAzureSql)]
public class CustomConvertersSqlServerTest : CustomConvertersTestBase<CustomConvertersSqlServerTest.CustomConvertersSqlServerFixture>
{
public CustomConvertersSqlServerTest(CustomConvertersSqlServerFixture fixture)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.EntityFrameworkCore;

#nullable disable

[SqlServerCondition(SqlServerCondition.IsNotSqlAzure)]
[SqlServerCondition(SqlServerCondition.IsNotAzureSql)]
public class EverythingIsBytesSqlServerTest(EverythingIsBytesSqlServerTest.EverythingIsBytesSqlServerFixture fixture)
: BuiltInDataTypesTestBase<EverythingIsBytesSqlServerTest.EverythingIsBytesSqlServerFixture>(fixture)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.EntityFrameworkCore;

#nullable disable

[SqlServerCondition(SqlServerCondition.IsNotSqlAzure)]
[SqlServerCondition(SqlServerCondition.IsNotAzureSql)]
public class EverythingIsStringsSqlServerTest(EverythingIsStringsSqlServerTest.EverythingIsStringsSqlServerFixture fixture)
: BuiltInDataTypesTestBase<
EverythingIsStringsSqlServerTest.EverythingIsStringsSqlServerFixture>(fixture)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// ReSharper disable InconsistentNaming
namespace Microsoft.EntityFrameworkCore.Migrations
{
[SqlServerCondition(SqlServerCondition.IsNotSqlAzure | SqlServerCondition.IsNotCI)]
[SqlServerCondition(SqlServerCondition.IsNotAzureSql | SqlServerCondition.IsNotCI)]
public class MigrationsInfrastructureSqlServerTest(
MigrationsInfrastructureSqlServerTest.MigrationsInfrastructureSqlServerFixture fixture)
: MigrationsInfrastructureTestBase<MigrationsInfrastructureSqlServerTest.MigrationsInfrastructureSqlServerFixture>(fixture)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5161,6 +5161,7 @@ CREATE TABLE HypotheticalIndexTable (
"DROP TABLE HypotheticalIndexTable;");

[ConditionalFact]
[SqlServerCondition(SqlServerCondition.IsNotAzureSql)]
public void Ignore_columnstore_index()
=> Test(
@"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.SqlAzure;

#nullable disable

[SqlServerCondition(SqlServerCondition.IsSqlAzure)]
[SqlServerCondition(SqlServerCondition.IsAzureSql)]
public class SqlAzureBatchingTest(BatchingSqlAzureFixture fixture) : IClassFixture<BatchingSqlAzureFixture>
{
public BatchingSqlAzureFixture Fixture { get; } = fixture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.EntityFrameworkCore.SqlAzure;

#nullable disable

[SqlServerCondition(SqlServerCondition.IsSqlAzure)]
[SqlServerCondition(SqlServerCondition.IsAzureSql)]
#pragma warning disable CS9113 // Parameter is unread.
public class SqlAzureConnectionTest(SqlAzureFixture fixture) : IClassFixture<SqlAzureFixture>
#pragma warning restore CS9113 // Parameter is unread.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.EntityFrameworkCore.SqlAzure;

#nullable disable

[SqlServerCondition(SqlServerCondition.IsSqlAzure)]
[SqlServerCondition(SqlServerCondition.IsAzureSql)]
public class SqlAzureDatabaseCreationTest
{
protected string StoreName { get; } = "SqlAzureDatabaseCreationTest";
Expand All @@ -21,7 +21,7 @@ public async Task Creates_database_in_elastic_pool()
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();

await AssertOptionsAsync(context.Database.GetDbConnection(), 1000 * (1L << 28), "Standard", "ElasticPool");
await AssertOptionsAsync(context.Database.GetDbConnection(), 1L << 35, "GeneralPurpose", "ElasticPool");
}

private class ElasticPoolContext(SqlServerTestStore testStore) : DbContext
Expand All @@ -46,7 +46,7 @@ public async Task Creates_basic_database()
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();

await AssertOptionsAsync(context.Database.GetDbConnection(), 1L << 30, "Basic", "Basic");
await AssertOptionsAsync(context.Database.GetDbConnection(), 1L << 35, "GeneralPurpose", "GP_Gen5_2");
}

private class BasicContext(SqlServerTestStore testStore) : DbContext
Expand All @@ -61,8 +61,9 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasDatabaseMaxSize("1 GB");
modelBuilder.HasServiceTier("'basic'");
modelBuilder.HasDatabaseMaxSize("32 GB");
modelBuilder.HasServiceTier("'GeneralPurpose'");
modelBuilder.HasPerformanceLevel("GP_Gen5_2");
}
}

Expand All @@ -74,7 +75,7 @@ public async Task Creates_business_critical_database()
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();

await AssertOptionsAsync(context.Database.GetDbConnection(), 1L << 31, "BusinessCritical", "BC_Gen4_1");
await AssertOptionsAsync(context.Database.GetDbConnection(), 1L << 33, "BusinessCritical", "BC_Gen5_2");
}

private class BusinessCriticalContext(SqlServerTestStore testStore) : DbContext
Expand All @@ -89,9 +90,9 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasDatabaseMaxSize("2 GB");
modelBuilder.HasDatabaseMaxSize("8 GB");
modelBuilder.HasServiceTier("BusinessCritical");
modelBuilder.HasPerformanceLevel("BC_Gen4_1");
modelBuilder.HasPerformanceLevel("BC_Gen5_2");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.EntityFrameworkCore.SqlAzure;

#nullable disable

[SqlServerCondition(SqlServerCondition.IsSqlAzure)]
[SqlServerCondition(SqlServerCondition.IsAzureSql)]
public class SqlAzureFundamentalsTest(SqlAzureFixture fixture) : IClassFixture<SqlAzureFixture>
{
public SqlAzureFixture Fixture { get; } = fixture;
Expand Down
Binary file modified test/EFCore.SqlServer.FunctionalTests/SqlAzure/adventureworks.sql
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ private static async Task Noop_when_database_does_not_exist_test(bool async, boo
public class SqlServerDatabaseCreatorEnsureCreatedTest : SqlServerDatabaseCreatorTestBase
{
[ConditionalTheory]
[SqlServerCondition(SqlServerCondition.IsNotAzureSql)]
[InlineData(true, true)]
[InlineData(false, false)]
public Task Creates_schema_in_existing_database(bool async, bool ambientTransaction)
Expand All @@ -226,7 +227,7 @@ private static Task Creates_schema_in_existing_database_test(bool async, bool am
[ConditionalTheory]
[InlineData(true, false)]
[InlineData(false, true)]
[SqlServerCondition(SqlServerCondition.IsNotSqlAzure)]
[SqlServerCondition(SqlServerCondition.IsNotAzureSql)]
public Task Creates_physical_database_and_schema(bool async, bool ambientTransaction)
=> Creates_new_physical_database_and_schema_test(async, ambientTransaction, file: false);

Expand Down Expand Up @@ -686,7 +687,7 @@ public async Task Throws_if_database_already_exists(bool async)
}

#pragma warning disable RCS1102 // Make class static.
[SqlServerCondition(SqlServerCondition.IsNotSqlAzure | SqlServerCondition.IsNotCI)]
[SqlServerCondition(SqlServerCondition.IsNotAzureSql | SqlServerCondition.IsNotCI)]
public abstract class SqlServerDatabaseCreatorTestBase
{
protected static IDisposable CreateTransactionScope(bool useTransaction)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
}

[ConditionalFact]
[SqlServerCondition(SqlServerCondition.IsNotSqlAzure)]
[SqlServerCondition(SqlServerCondition.IsNotAzureSql)]
public async Task Insert_with_ValueGeneratedOnAdd_GUID_nonkey_property_throws()
{
await using var testStore = await SqlServerTestStore.CreateInitializedAsync(DatabaseName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities;
[Flags]
public enum SqlServerCondition
{
IsSqlAzure = 1 << 0,
IsNotSqlAzure = 1 << 1,
IsAzureSql = 1 << 0,
IsNotAzureSql = 1 << 1,
SupportsMemoryOptimized = 1 << 2,
SupportsAttach = 1 << 3,
SupportsHiddenColumns = 1 << 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public ValueTask<bool> IsMetAsync()
isMet &= TestEnvironment.IsMemoryOptimizedTablesSupported;
}

if (Conditions.HasFlag(SqlServerCondition.IsSqlAzure))
if (Conditions.HasFlag(SqlServerCondition.IsAzureSql))
{
isMet &= TestEnvironment.IsSqlAzure;
}

if (Conditions.HasFlag(SqlServerCondition.IsNotSqlAzure))
if (Conditions.HasFlag(SqlServerCondition.IsNotAzureSql))
{
isMet &= !TestEnvironment.IsSqlAzure;
}
Expand Down