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

Akka.Persistence.SqlServer plugin #842

Merged
merged 1 commit into from
Apr 24, 2015
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ UpgradeLog*.htm
*.mdf
*.ldf

# make exception for Akka.Persistence.SqlServer database file
!AkkaPersistenceSqlServerSpecDb.mdf
!AkkaPersistenceSqlServerSpecDb_log.ldf

# Business Intelligence projects
*.rdl.data
*.bim.layout
Expand Down
12 changes: 10 additions & 2 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ Target "RunTests" <| fun _ ->
let nunitTestAssemblies = !! "src/**/bin/Release/Akka.TestKit.NUnit.Tests.dll"
let xunitTestAssemblies = !! "src/**/bin/Release/*.Tests.dll" --
"src/**/bin/Release/Akka.TestKit.VsTest.Tests.dll" --
"src/**/bin/Release/Akka.TestKit.NUnit.Tests.dll"
"src/**/bin/Release/Akka.TestKit.NUnit.Tests.dll" --
"src/**/bin/Release/Akka.Persistence.SqlServer.Tests.dll"

mkdir testOutput

Expand Down Expand Up @@ -248,6 +248,14 @@ Target "MultiNodeTests" <| fun _ ->
info.Arguments <- args) (System.TimeSpan.FromMinutes 60.0) (* This is a VERY long running task. *)
if result <> 0 then failwithf "MultiNodeTestRunner failed. %s %s" multiNodeTestPath args

Target "RunSqlServerTests" <| fun _ ->
let sqlServerTests = !! "src/**/bin/Release/Akka.Persistence.SqlServer.Tests.dll"
let xunitToolPath = findToolInSubPath "xunit.console.clr4.exe" "src/packages/xunit.runners*"
printfn "Using XUnit runner: %s" xunitToolPath
xUnit
(fun p -> { p with OutputDir = testOutput; ToolPath = xunitToolPath })
sqlServerTests

//--------------------------------------------------------------------------------
// Nuget targets
//--------------------------------------------------------------------------------
Expand Down
25 changes: 25 additions & 0 deletions src/Akka.sln
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.TestKit.NUnit", "contr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.TestKit.NUnit.Tests", "contrib\testkits\Akka.TestKit.NUnit.Tests\Akka.TestKit.NUnit.Tests.csproj", "{D63223FA-03F5-4B32-A6EC-668F718C0826}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Persistence", "Persistence", "{264C22A4-CAFC-41F6-B82C-4DDC5C196767}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.Persistence.SqlServer", "contrib\persistence\Akka.Persistence.SqlServer\Akka.Persistence.SqlServer.csproj", "{BAC85686-AFC4-413E-98DC-5ED8F468BC63}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.Persistence.SqlServer.Tests", "contrib\persistence\Akka.Persistence.SqlServer.Tests\Akka.Persistence.SqlServer.Tests.csproj", "{5A3C24D7-0D1C-4974-BBB4-22AC792666DE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug Mono|Any CPU = Debug Mono|Any CPU
Expand Down Expand Up @@ -681,6 +687,22 @@ Global
{D63223FA-03F5-4B32-A6EC-668F718C0826}.Release Mono|Any CPU.Build.0 = Release|Any CPU
{D63223FA-03F5-4B32-A6EC-668F718C0826}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D63223FA-03F5-4B32-A6EC-668F718C0826}.Release|Any CPU.Build.0 = Release|Any CPU
{BAC85686-AFC4-413E-98DC-5ED8F468BC63}.Debug Mono|Any CPU.ActiveCfg = Debug|Any CPU
{BAC85686-AFC4-413E-98DC-5ED8F468BC63}.Debug Mono|Any CPU.Build.0 = Debug|Any CPU
{BAC85686-AFC4-413E-98DC-5ED8F468BC63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BAC85686-AFC4-413E-98DC-5ED8F468BC63}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BAC85686-AFC4-413E-98DC-5ED8F468BC63}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
{BAC85686-AFC4-413E-98DC-5ED8F468BC63}.Release Mono|Any CPU.Build.0 = Release|Any CPU
{BAC85686-AFC4-413E-98DC-5ED8F468BC63}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BAC85686-AFC4-413E-98DC-5ED8F468BC63}.Release|Any CPU.Build.0 = Release|Any CPU
{5A3C24D7-0D1C-4974-BBB4-22AC792666DE}.Debug Mono|Any CPU.ActiveCfg = Debug|Any CPU
{5A3C24D7-0D1C-4974-BBB4-22AC792666DE}.Debug Mono|Any CPU.Build.0 = Debug|Any CPU
{5A3C24D7-0D1C-4974-BBB4-22AC792666DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A3C24D7-0D1C-4974-BBB4-22AC792666DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A3C24D7-0D1C-4974-BBB4-22AC792666DE}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
{5A3C24D7-0D1C-4974-BBB4-22AC792666DE}.Release Mono|Any CPU.Build.0 = Release|Any CPU
{5A3C24D7-0D1C-4974-BBB4-22AC792666DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A3C24D7-0D1C-4974-BBB4-22AC792666DE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -764,5 +786,8 @@ Global
{2065C3A2-8C15-4912-BCF5-AE89E3DDA079} = {B1D10183-8FAE-4506-B935-403FCED89BDB}
{BEF84A6F-32C4-4ACF-AFC3-7B5FCA6F209E} = {7625FD95-4B2C-4A5B-BDD5-94B1493FAC8E}
{D63223FA-03F5-4B32-A6EC-668F718C0826} = {7625FD95-4B2C-4A5B-BDD5-94B1493FAC8E}
{264C22A4-CAFC-41F6-B82C-4DDC5C196767} = {588C1513-FAB6-42C3-B6FC-3485F13620CF}
{BAC85686-AFC4-413E-98DC-5ED8F468BC63} = {264C22A4-CAFC-41F6-B82C-4DDC5C196767}
{5A3C24D7-0D1C-4974-BBB4-22AC792666DE} = {264C22A4-CAFC-41F6-B82C-4DDC5C196767}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5A3C24D7-0D1C-4974-BBB4-22AC792666DE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Akka.Persistence.SqlServer.Tests</RootNamespace>
<AssemblyName>Akka.Persistence.SqlServer.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DbCleanup.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="SqlServerJournalSpec.cs" />
<Compile Include="SqlServerSnapshotStoreSpec.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\core\Akka.Persistence.TestKit\Akka.Persistence.TestKit.csproj">
<Project>{ad9418b6-c452-4169-94fb-d43de0bfa966}</Project>
<Name>Akka.Persistence.TestKit</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\core\Akka.Persistence\Akka.Persistence.csproj">
<Project>{fca84dea-c118-424b-9eb8-34375dfef18a}</Project>
<Name>Akka.Persistence</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\core\Akka.TestKit\Akka.TestKit.csproj">
<Project>{0d3cbad0-bbdb-43e5-afc4-ed1d3ecdc224}</Project>
<Name>Akka.TestKit</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\core\Akka\Akka.csproj">
<Project>{5deddf90-37f0-48d3-a0b0-a5cbd8a7e377}</Project>
<Name>Akka</Name>
</ProjectReference>
<ProjectReference Include="..\..\testkits\Akka.TestKit.Xunit\Akka.TestKit.Xunit.csproj">
<Project>{11f4d4b8-7e07-4457-abf2-609b3e7b2649}</Project>
<Name>Akka.TestKit.Xunit</Name>
</ProjectReference>
<ProjectReference Include="..\Akka.Persistence.SqlServer\Akka.Persistence.SqlServer.csproj">
<Project>{bac85686-afc4-413e-98dc-5ed8f468bc63}</Project>
<Name>Akka.Persistence.SqlServer</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="Resources\AkkaPersistenceSqlServerSpecDb.mdf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\AkkaPersistenceSqlServerSpecDb_log.ldf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<DependentUpon>AkkaPersistenceSqlServerSpecDb.mdf</DependentUpon>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Data.SqlClient;

namespace Akka.Persistence.SqlServer.Tests
{
public static class DbCleanup
{
private static readonly string ConnectionString = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Resources\AkkaPersistenceSqlServerSpecDb.mdf;Integrated Security=True";

static DbCleanup()
{
AppDomain.CurrentDomain.SetData("DataDirectory", AppDomain.CurrentDomain.BaseDirectory);
}

public static void Clean()
{
using (var conn = new SqlConnection(ConnectionString))
using (var cmd = new SqlCommand())
{
conn.Open();
cmd.CommandText = @"
IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME = 'EventJournal') BEGIN DELETE FROM dbo.EventJournal END;
IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME = 'SnapshotStore') BEGIN DELETE FROM dbo.SnapshotStore END";
cmd.Connection = conn;
cmd.ExecuteNonQuery();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Akka.Persistence.SqlServer.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Akka.Persistence.SqlServer.Tests")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("343a20b5-0aa8-4c22-baea-de78162b1c94")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Akka.Persistence.SqlServer.Tests.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="SqlServerJournalSpecDbConnectionString" Type="(Connection string)" Scope="Application">
<DesignTimeValue Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
&lt;ConnectionString&gt;Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\SqlServerJournalSpecDb.mdf;Integrated Security=True;Connect Timeout=30&lt;/ConnectionString&gt;
&lt;ProviderName&gt;System.Data.SqlClient&lt;/ProviderName&gt;
&lt;/SerializableConnectionString&gt;</DesignTimeValue>
<Value Profile="(Default)">Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\SqlServerJournalSpecDb.mdf;Integrated Security=True;Connect Timeout=30</Value>
</Setting>
</Settings>
</SettingsFile>
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Akka.Configuration;
using Akka.Persistence.TestKit.Journal;

namespace Akka.Persistence.SqlServer.Tests
{
public class SqlServerJournalSpec : JournalSpec
{
private static readonly Config SpecConfig = ConfigurationFactory.ParseString(@"
akka.persistence {
publish-plugin-commands = on
journal {
plugin = ""akka.persistence.journal.sql-server""
sql-server {
class = ""Akka.Persistence.SqlServer.Journal.SqlServerJournal, Akka.Persistence.SqlServer""
plugin-dispatcher = ""akka.actor.default-dispatcher""
table-name = EventJournal
schema-name = dbo
auto-initialize = on
connection-string = ""Data Source=(LocalDB)\\v11.0;AttachDbFilename=|DataDirectory|\\Resources\\AkkaPersistenceSqlServerSpecDb.mdf;Integrated Security=True""
}
}
}");

public SqlServerJournalSpec()
: base(SpecConfig, "SqlServerJournalSpec")
{
DbCleanup.Clean();
Initialize();
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
DbCleanup.Clean();
}
}
}
Loading