Skip to content
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 src/LegacyArtifacts/LegacyArtifacts.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
-->
<Artifact Include="**\*.manifest" DestinationFolder="$(ArtifactsPath)%(RecursiveDir)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
</PropertyGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)\..\platform\servicecontrol\servicecontrol-instance\**\*" CopyToOutputDirectory="PreserveNewest" Link="platform\servicecontrol\servicecontrol-instance\%(RecursiveDir)%(Filename)%(Extension)" />
<None Include="$(MSBuildThisFileDirectory)\..\platform\servicecontrol\servicecontrol-instance\**\*" CopyToOutputDirectory="PreserveNewest" LinkBase="platform\servicecontrol\servicecontrol-instance" />
</ItemGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)\..\platform\servicecontrol\servicecontrol-audit-instance\**\*" CopyToOutputDirectory="PreserveNewest" Link="platform\servicecontrol\servicecontrol-audit-instance\%(RecursiveDir)%(Filename)%(Extension)" />
<None Include="$(MSBuildThisFileDirectory)\..\platform\servicecontrol\servicecontrol-audit-instance\**\*" CopyToOutputDirectory="PreserveNewest" LinkBase="platform\servicecontrol\servicecontrol-audit-instance" />
</ItemGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)\..\platform\servicecontrol\monitoring-instance\**\*" CopyToOutputDirectory="PreserveNewest" Link="platform\servicecontrol\monitoring-instance\%(RecursiveDir)%(Filename)%(Extension)" />
<None Include="$(MSBuildThisFileDirectory)\..\platform\servicecontrol\monitoring-instance\**\*" CopyToOutputDirectory="PreserveNewest" LinkBase="platform\servicecontrol\monitoring-instance" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Project>

<ItemGroup Label="Persisters">
<ProjectReference Include="..\ServiceControl.Audit.Persistence.InMemory\ServiceControl.Audit.Persistence.InMemory.csproj" ReferenceOutputAssembly="false" Private="false" />
<ProjectReference Include="..\ServiceControl.Audit.Persistence.RavenDb5\ServiceControl.Audit.Persistence.RavenDb5.csproj" ReferenceOutputAssembly="false" Private="false" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<Project>

<ItemGroup Label="Persisters">
<ProjectReference Include="..\ServiceControl.Persistence.RavenDb5\ServiceControl.Persistence.RavenDb5.csproj" ReferenceOutputAssembly="false" Private="false" />
</ItemGroup>

</Project>
14 changes: 14 additions & 0 deletions src/ProjectReferences.Transports.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project>

<ItemGroup Label="Transports">
<ProjectReference Include="..\ServiceControl.Transports.ASB\ServiceControl.Transports.ASB.csproj" ReferenceOutputAssembly="false" Private="false" />
<ProjectReference Include="..\ServiceControl.Transports.ASBS\ServiceControl.Transports.ASBS.csproj" ReferenceOutputAssembly="false" Private="false" />
<ProjectReference Include="..\ServiceControl.Transports.ASQ\ServiceControl.Transports.ASQ.csproj" ReferenceOutputAssembly="false" Private="false" />
<ProjectReference Include="..\ServiceControl.Transports.Learning\ServiceControl.Transports.Learning.csproj" ReferenceOutputAssembly="false" Private="false" />
<ProjectReference Include="..\ServiceControl.Transports.Msmq\ServiceControl.Transports.Msmq.csproj" ReferenceOutputAssembly="false" Private="false" />
<ProjectReference Include="..\ServiceControl.Transports.RabbitMQ\ServiceControl.Transports.RabbitMQ.csproj" ReferenceOutputAssembly="false" Private="false" />
<ProjectReference Include="..\ServiceControl.Transports.SqlServer\ServiceControl.Transports.SqlServer.csproj" ReferenceOutputAssembly="false" Private="false" />
<ProjectReference Include="..\ServiceControl.Transports.SQS\ServiceControl.Transports.SQS.csproj" ReferenceOutputAssembly="false" Private="false" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<RunSettingsFilePath>ServiceControl.runsettings</RunSettingsFilePath>
<LangVersion>8</LangVersion>
<LangVersion>8.0</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -25,7 +25,7 @@
</ItemGroup>

<ItemGroup>
<Compile Include="..\ServiceControl.AcceptanceTests\**\*.cs" Link="Shared\%(RecursiveDir)\%(Filename).%(Extension)" />
<Compile Include="..\ServiceControl.AcceptanceTests\**\*.cs" LinkBase="Shared" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<!-- The tests need to be run in x64 otherwise an exception about RavenDB (Voron) not being supported in 32bit mode will be thrown. -->
<TargetPlatform>x64</TargetPlatform>
</RunConfiguration>
<RunConfiguration>
<!-- The tests need to be run in x64 otherwise an exception about RavenDB (Voron) not being supported in 32bit mode will be thrown. -->
<TargetPlatform>x64</TargetPlatform>
</RunConfiguration>
</RunSettings>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<RunSettingsFilePath>ServiceControl.runsettings</RunSettingsFilePath>
<LangVersion>8</LangVersion>
<LangVersion>8.0</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<!-- The tests need to be run in x64 otherwise an exception about RavenDB (Voron) not being supported in 32bit mode will be thrown. -->
<TargetPlatform>x64</TargetPlatform>
</RunConfiguration>
<RunConfiguration>
<!-- The tests need to be run in x64 otherwise an exception about RavenDB (Voron) not being supported in 32bit mode will be thrown. -->
<TargetPlatform>x64</TargetPlatform>
</RunConfiguration>
</RunSettings>
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<RunSettingsFilePath>ServiceControl.runsettings</RunSettingsFilePath>
<LangVersion>8</LangVersion>
<LangVersion>8.0</LangVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\ServiceControl.AcceptanceTesting\ServiceControl.AcceptanceTesting.csproj" />
<ProjectReference Include="..\ServiceControl.Audit.Persistence.InMemory\ServiceControl.Audit.Persistence.InMemory.csproj" />
<ProjectReference Include="..\ServiceControl.Audit\ServiceControl.Audit.csproj" />
<ProjectReference Include="..\ServiceControl.Audit.Persistence.InMemory\ServiceControl.Audit.Persistence.InMemory.csproj" />
<ProjectReference Include="..\ServiceControl.Transports.Learning\ServiceControl.Transports.Learning.csproj" />
<ProjectReference Include="..\ServiceControlInstaller.Engine\ServiceControlInstaller.Engine.csproj" />
<ProjectReference Include="..\TestHelper\TestHelper.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<!-- The tests need to be run in x64 otherwise an exception about RavenDB (Voron) not being supported in 32bit mode will be thrown. -->
<TargetPlatform>x64</TargetPlatform>
</RunConfiguration>
<RunConfiguration>
<!-- The tests need to be run in x64 otherwise an exception about RavenDB (Voron) not being supported in 32bit mode will be thrown. -->
<TargetPlatform>x64</TargetPlatform>
</RunConfiguration>
</RunSettings>
31 changes: 12 additions & 19 deletions src/ServiceControl.Audit.Persistence.RavenDb5/EmbeddedDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using ByteSizeLib;
Expand All @@ -25,30 +26,22 @@ public EmbeddedDatabase(DatabaseConfiguration configuration)

static (string LicenseFileName, string ServerDirectory) GetRavenLicenseFileNameAndServerDirectory()
{
var assembly = Assembly.GetExecutingAssembly();
var assemblyDirectory = Path.GetDirectoryName(assembly.Location);

var licenseFileName = "RavenLicense.json";
var localRavenLicense = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, licenseFileName);
if (File.Exists(localRavenLicense))
var ravenLicense = Path.Combine(assemblyDirectory, licenseFileName);
var serverDirectory = Path.Combine(assemblyDirectory, "RavenDBServer");

if (File.Exists(ravenLicense))
{
return (localRavenLicense, null);
return (ravenLicense, serverDirectory);
}

const string Persisters = "Persisters";
const string RavenDB5 = "RavenDB5";

var persisterDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Persisters, RavenDB5);

localRavenLicense = Path.Combine(persisterDirectory, licenseFileName);
if (!File.Exists(localRavenLicense))
else
{
throw new Exception($"RavenDB license not found. Make sure the RavenDB license file, '{licenseFileName}', " +
$"is stored in the '{AppDomain.CurrentDomain.BaseDirectory}' folder or in the '{Persisters}/{RavenDB5}' subfolder.");
var assemblyName = Path.GetFileName(assembly.Location);
throw new Exception($"RavenDB license not found. Make sure the RavenDB license file '{licenseFileName}' is stored in the same directory as {assemblyName}.");
}

// By default RavenDB 5 searches its binaries in the RavenDBServer right below the BaseDirectory.
// If we're loading from Persisters/RavenDB5 we also have to signal RavenDB where are binaries
var serverDirectory = Path.Combine(persisterDirectory, "RavenDBServer");

return (localRavenLicense, serverDirectory);
}

public static EmbeddedDatabase Start(DatabaseConfiguration databaseConfiguration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ItemGroup>

<ItemGroup>
<Compile Include="..\ServiceControl.Audit.Persistence.Tests\*.cs" Link="Shared\%(RecursiveDir)%(FileName)%(Extension)" />
<Compile Include="..\ServiceControl.Audit.Persistence.Tests\*.cs" LinkBase="Shared" />
<Compile Remove="..\ServiceControl.Audit.Persistence.Tests\PersistenceManifestLibraryTests.cs" />
<Compile Remove="..\ServiceControl.Audit.Persistence.Tests\TestsFilter.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class PersistenceManifestLibraryTests
{
const string persistenceName = "RavenDB5";
const string persistenceType = "ServiceControl.Audit.Persistence.RavenDb.RavenDbPersistenceConfiguration, ServiceControl.Audit.Persistence.RavenDb5";
const string persistenceFolder = "RavenDB5";

[Test]
public void Should_find_persistence_type_by_name()
Expand All @@ -22,7 +21,7 @@ public void Should_find_persistence_type_by_name()
}

[Test]
public void Should_find_tpersistence_type_by_type()
public void Should_find_persistence_type_by_type()
{
var _persistenceType = PersistenceManifestLibrary.Find(persistenceType);

Expand All @@ -43,15 +42,15 @@ public void Should_find_persistence_type_folder_by_name()
{
var _persistenceTypeFolder = PersistenceManifestLibrary.GetPersistenceFolder(persistenceName);

Assert.AreEqual(persistenceFolder, _persistenceTypeFolder);
Assert.IsNotNull(_persistenceTypeFolder);
}

[Test]
public void Should_find_tpersistence_type_folder_by_type()
public void Should_find_persistence_type_folder_by_type()
{
var _persistenceTypeFolder = PersistenceManifestLibrary.GetPersistenceFolder(persistenceType);

Assert.AreEqual(persistenceFolder, _persistenceTypeFolder);
Assert.IsNotNull(_persistenceTypeFolder);
}

[Test]
Expand All @@ -66,38 +65,24 @@ public void Should_return_null_for_not_found_persistence_type()
[Test]
public void All_types_defined_in_manifest_files_exist_in_specified_assembly()
{
var assemblyLocation = Assembly.GetExecutingAssembly().Location;
var appDirectory = Path.GetDirectoryName(assemblyLocation);
PersistenceManifestLibrary.GetPersistenceFolder("dummy"); //to initialise the collection
var count = 0;

var supportedManifests = PersistenceManifestLibrary.PersistenceManifests.Where(p => p.IsSupported).ToList();
Assert.True(supportedManifests.Count >= 1);

supportedManifests.ForEach(p =>
foreach (var definition in PersistenceManifestLibrary.PersistenceManifests)
{
var persistenceFolder = PersistenceManifestLibrary.GetPersistenceFolder(p.Name);
var subFolderPath = Path.Combine(appDirectory, "Persisters", persistenceFolder);
var assemblyName = p.TypeName.Split(',')[1].Trim();
var assembly = TryLoadTypeFromSubdirectory(subFolderPath, assemblyName);
count++;
var persistenceFolder = PersistenceManifestLibrary.GetPersistenceFolder(definition.Name);
var assemblyName = definition.TypeName.Split(',')[1].Trim();
var assemblyFile = Path.Combine(persistenceFolder, assemblyName + ".dll");
var assembly = Assembly.LoadFrom(assemblyFile);

Assert.IsNotNull(assembly, $"Could not load assembly {assemblyName}");

//NOTE not checking namespace here as it doesn't match for RavenDb5
//Assert.IsTrue(assembly.GetTypes().Any(a => a.FullName == p.TypeName.Split(',').FirstOrDefault() && a.Namespace == assemblyName), $"Persistence type {p.TypeName} not found in assembly {assemblyName}");
Assert.IsTrue(assembly.GetTypes().Any(a => a.FullName == p.TypeName.Split(',').FirstOrDefault()), $"Persistence type {p.TypeName} not found in assembly {assemblyName}");
});
}

Assembly TryLoadTypeFromSubdirectory(string subFolderPath, string requestingName)
{
//look into any subdirectory
var file = Directory.EnumerateFiles(subFolderPath, requestingName + ".dll", SearchOption.AllDirectories).SingleOrDefault();
if (file != null)
{
return Assembly.LoadFrom(file);
//Assert.IsTrue(assembly.GetTypes().Any(a => a.FullName == definition.TypeName.Split(',').FirstOrDefault() && a.Namespace == assemblyName), $"Persistence type {definition.TypeName} not found in assembly {assemblyName}");
Assert.IsTrue(assembly.GetTypes().Any(a => a.FullName == definition.TypeName.Split(',').FirstOrDefault()), $"Persistence type {definition.TypeName} not found in assembly {assemblyName}");
}

return null;
Assert.NotZero(count, "No persistence manifests found.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,9 @@
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>

<Import Project="..\Persisters.Audit.Includes.props" />

<ItemGroup Label="Persisters">
<!--NOTE: We need a direct reference to InMemory for test configuration -->
<ProjectReference Include="..\ServiceControl.Audit.Persistence.InMemory\ServiceControl.Audit.Persistence.InMemory.csproj" ReferenceOutputAssembly="true" Private="true" />
</ItemGroup>

<!-- NOTE: Not using Persisters.Audit.Artifacts.Includes.props to avoid race conditions-->
<ItemGroup>
<Artifact Include="$(ArtifactsPath)Particular.ServiceControl.Audit\Persisters" DestinationFolder="$(OutputPath)\Persisters\%(RecursiveDir)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ServiceControl.Audit.Persistence\ServiceControl.Audit.Persistence.csproj" />
<ProjectReference Include="..\ServiceControl.Audit.Persistence.InMemory\ServiceControl.Audit.Persistence.InMemory.csproj" />
<ProjectReference Include="..\ServiceControlInstaller.Engine\ServiceControlInstaller.Engine.csproj" />
<ProjectReference Include="..\TestHelper\TestHelper.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace ServiceControl.Persistence
{
using System.Collections.Generic;
using System.IO;

static class DevelopmentPersistenceLocations
{
public static List<string> ManifestFiles { get; } = new List<string>();

static DevelopmentPersistenceLocations()
{
var assembly = typeof(DevelopmentPersistenceLocations).Assembly.Location;
var assemblyDirectory = Path.GetDirectoryName(assembly);

// Becomes null if it navigates past the root of a drive
var srcFolder = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(assemblyDirectory))));

if (!string.IsNullOrWhiteSpace(srcFolder) && srcFolder.EndsWith("src"))
{
ManifestFiles.Add(BuildManifestPath(srcFolder, "ServiceControl.Audit.Persistence.InMemory"));
ManifestFiles.Add(BuildManifestPath(srcFolder, "ServiceControl.Audit.Persistence.RavenDb5"));
}
}

static string BuildManifestPath(string srcFolder, string projectName) => Path.Combine(srcFolder, projectName, "bin", configuration, framework, "persistence.manifest");

#if DEBUG
const string configuration = "Debug";
#else
const string configuration = "Release";
#endif

#if NET472
const string framework = "net472";
#endif
}
}
Loading