Skip to content

Commit

Permalink
#61 : streams reset during EnsureDeleted, added some tests (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
masesdevelopers authored Sep 27, 2023
1 parent 7645ae3 commit 36bc8a4
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/net/KEFCore/Storage/Internal/KafkaCluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,17 @@ public virtual bool EnsureDeleted(
foreach (var entityType in designModel.GetEntityTypes())
{
var topic = entityType.TopicName(Options);

if (!Options.UseCompactedReplicator)
{
try
{
StreamsResetter.ResetApplicationForced(Options.BootstrapServers, entityType.ApplicationIdForTable(Options), topic);
}
catch (ExecutionException ex)
{
throw ex.InnerException;
}
}
coll.Add(topic);
}

Expand Down
20 changes: 20 additions & 0 deletions test/KEFCore.Test.InMemory/KEFCore.Test.InMemory.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\Common\Common.props" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<AssemblyName>MASES.EntityFrameworkCore.KNet.Test.InMemory</AssemblyName>
<RootNamespace>MASES.EntityFrameworkCore.KNet.Test.InMemory</RootNamespace>
<Title>EntityFrameworkCore InMemory Test</Title>
<Description>EntityFrameworkCore InMemory Test</Description>
<Product>MASES.EntityFrameworkCore.KNet.Test.InMemory</Product>
<OutputPath>..\..\bin\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\KEFCore.Test\Program.cs" Link="Program.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.11" />
</ItemGroup>
</Project>
35 changes: 35 additions & 0 deletions test/KEFCore.Test.InMemory/ProgramConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* MIT License
*
* Copyright (c) 2022 MASES s.r.l.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

namespace MASES.EntityFrameworkCore.KNet.Test
{
partial class Program
{
public static bool UseInMemoryProvider = true;
public static bool UseModelBuilder = false;
public static bool UseCompactedReplicator = false;
public static string DatabaseName = null;
static bool deleteApplication = false;
}
}
20 changes: 20 additions & 0 deletions test/KEFCore.Test.Replicator/KEFCore.Test.Replicator.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\Common\Common.props" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<AssemblyName>MASES.EntityFrameworkCore.KNet.Test.Replicator</AssemblyName>
<RootNamespace>MASES.EntityFrameworkCore.KNet.Test.Replicator</RootNamespace>
<Title>EntityFrameworkCore Replicator Test</Title>
<Description>EntityFrameworkCore Replicator Test</Description>
<Product>MASES.EntityFrameworkCore.KNet.Test.Replicator</Product>
<OutputPath>..\..\bin\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\KEFCore.Test\Program.cs" Link="Program.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.11" />
</ItemGroup>
</Project>
35 changes: 35 additions & 0 deletions test/KEFCore.Test.Replicator/ProgramConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* MIT License
*
* Copyright (c) 2022 MASES s.r.l.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

namespace MASES.EntityFrameworkCore.KNet.Test
{
partial class Program
{
public static bool UseInMemoryProvider = false;
public static bool UseModelBuilder = false;
public static bool UseCompactedReplicator = true;
public static string DatabaseName = null;
static bool deleteApplication = false;
}
}
22 changes: 22 additions & 0 deletions test/KEFCore.Test.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KEFCore.Test", "KEFCore.Tes
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KEFCore", "..\src\net\KEFCore\KEFCore.csproj", "{BB85D638-A032-41F5-9118-3264F6F6D14C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KEFCore.Test.InMemory", "KEFCore.Test.InMemory\KEFCore.Test.InMemory.csproj", "{B32C7AB4-6B7D-4CDF-B18E-467B9757D231}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{B35B16BB-890F-4385-AB20-7AA4DD6E9C01}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{4A0AD520-9BC4-4F92-893B-6F92BBC35BFA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KEFCore.Test.Replicator", "KEFCore.Test.Replicator\KEFCore.Test.Replicator.csproj", "{6FE8F586-4EA6-496E-AC8D-53F5C25E5388}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,10 +29,24 @@ Global
{BB85D638-A032-41F5-9118-3264F6F6D14C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BB85D638-A032-41F5-9118-3264F6F6D14C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BB85D638-A032-41F5-9118-3264F6F6D14C}.Release|Any CPU.Build.0 = Release|Any CPU
{B32C7AB4-6B7D-4CDF-B18E-467B9757D231}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B32C7AB4-6B7D-4CDF-B18E-467B9757D231}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B32C7AB4-6B7D-4CDF-B18E-467B9757D231}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B32C7AB4-6B7D-4CDF-B18E-467B9757D231}.Release|Any CPU.Build.0 = Release|Any CPU
{6FE8F586-4EA6-496E-AC8D-53F5C25E5388}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6FE8F586-4EA6-496E-AC8D-53F5C25E5388}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6FE8F586-4EA6-496E-AC8D-53F5C25E5388}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6FE8F586-4EA6-496E-AC8D-53F5C25E5388}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6999B7F3-6887-41CE-B1E9-2CE6BB881FDA} = {4A0AD520-9BC4-4F92-893B-6F92BBC35BFA}
{BB85D638-A032-41F5-9118-3264F6F6D14C} = {B35B16BB-890F-4385-AB20-7AA4DD6E9C01}
{B32C7AB4-6B7D-4CDF-B18E-467B9757D231} = {4A0AD520-9BC4-4F92-893B-6F92BBC35BFA}
{6FE8F586-4EA6-496E-AC8D-53F5C25E5388} = {4A0AD520-9BC4-4F92-893B-6F92BBC35BFA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {36C294ED-9ECE-42AA-8273-31E008749AF3}
EndGlobalSection
Expand Down

0 comments on commit 36bc8a4

Please sign in to comment.