Skip to content
Open
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 bitwarden-server.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<Project Path="test/Infrastructure.EFIntegration.Test/Infrastructure.EFIntegration.Test.csproj" />
<Project Path="test/Infrastructure.IntegrationTest/Infrastructure.IntegrationTest.csproj" />
<Project Path="test/IntegrationTestCommon/IntegrationTestCommon.csproj" />
<Project Path="test/Migrator.Test/Migrator.Test.csproj" />
<Project Path="test/Notifications.Test/Notifications.Test.csproj" />
<Project Path="test/SeederApi.IntegrationTest/SeederApi.IntegrationTest.csproj" />
<Project Path="test/Server.IntegrationTest/Server.IntegrationTest.csproj" />
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Settings/GlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ public class SqlSettings
public bool SkipDatabasePreparation { get; set; }
public bool DisableDatabaseMaintenanceJobs { get; set; }

public int? MigrationExecutionTimeoutSeconds { get; set; }

public string ConnectionString
{
get => _connectionString;
Expand Down
36 changes: 36 additions & 0 deletions test/Migrator.Test/DbMigratorTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
ο»Ώusing Bit.Migrator;

namespace Migrator.Test;

public class DbMigratorTests
{
private const int DefaultMinutes = 5;

[Theory]
[InlineData(null)]
[InlineData(-1)]
public void ResolveExecutionTimeout_WithoutUsableOverride_UsesDefault(int? executionTimeoutSeconds)
{
var timeout = DbMigrator.ResolveExecutionTimeout(executionTimeoutSeconds, DefaultMinutes);

Assert.Equal(TimeSpan.FromMinutes(DefaultMinutes), timeout);
}

[Fact]
public void ResolveExecutionTimeout_ZeroOverride_MapsToNoLimit()
{
var timeout = DbMigrator.ResolveExecutionTimeout(0, DefaultMinutes);

Assert.Equal(TimeSpan.Zero, timeout);
}

[Theory]
[InlineData(1)]
[InlineData(3600)]
public void ResolveExecutionTimeout_WithOverride_UsesOverrideInSeconds(int executionTimeoutSeconds)
{
var timeout = DbMigrator.ResolveExecutionTimeout(executionTimeoutSeconds, DefaultMinutes);

Assert.Equal(TimeSpan.FromSeconds(executionTimeoutSeconds), timeout);
}
}
28 changes: 28 additions & 0 deletions test/Migrator.Test/Migrator.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
<RootNamespace>Migrator.Test</RootNamespace>
</PropertyGroup>

<ItemGroup>
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="[18.7.0]" />
<PackageReference Include="xunit.v3" Version="[3.2.1]" />
<PackageReference Include="xunit.runner.visualstudio" Version="[3.1.5]" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\util\Migrator\Migrator.csproj" />
</ItemGroup>

</Project>
Loading
Loading