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
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,30 @@ async Task Add()

viewModel.InProgress = true;

var serviceControlNewInstance = viewModel.InstallErrorInstance ? new ServiceControlNewInstance
var serviceControlNewInstance = viewModel.InstallErrorInstance ? ServiceControlNewInstance.CreateWithDefaultPersistence() : null;

if (viewModel.InstallAuditInstance)
{
DisplayName = viewModel.ServiceControl.InstanceName,
Name = viewModel.ServiceControl.InstanceName.Replace(' ', '.'),
ServiceDescription = viewModel.ServiceControl.Description,
DBPath = viewModel.ServiceControl.DatabasePath,
LogPath = viewModel.ServiceControl.LogPath,
InstallPath = viewModel.ServiceControl.DestinationPath,
HostName = viewModel.ServiceControl.HostName,
Port = Convert.ToInt32(viewModel.ServiceControl.PortNumber),
DatabaseMaintenancePort = Convert.ToInt32(viewModel.ServiceControl.DatabaseMaintenancePortNumber),
VirtualDirectory = null,
ErrorQueue = viewModel.ServiceControl.ErrorQueueName,
ErrorLogQueue = viewModel.ServiceControl.ErrorForwarding.Value ? viewModel.ServiceControl.ErrorForwardingQueueName : null,
ForwardErrorMessages = viewModel.ServiceControl.ErrorForwarding.Value,
TransportPackage = viewModel.SelectedTransport,
ConnectionString = viewModel.ConnectionString,
ErrorRetentionPeriod = viewModel.ServiceControl.ErrorRetentionPeriod,
ServiceAccount = viewModel.ServiceControl.ServiceAccount,
ServiceAccountPwd = viewModel.ServiceControl.Password,
EnableFullTextSearchOnBodies = viewModel.ServiceControl.EnableFullTextSearchOnBodies.Value
} : null;
serviceControlNewInstance.DisplayName = viewModel.ServiceControl.InstanceName;
serviceControlNewInstance.Name = viewModel.ServiceControl.InstanceName.Replace(' ', '.');
serviceControlNewInstance.ServiceDescription = viewModel.ServiceControl.Description;
serviceControlNewInstance.DBPath = viewModel.ServiceControl.DatabasePath;
serviceControlNewInstance.LogPath = viewModel.ServiceControl.LogPath;
serviceControlNewInstance.InstallPath = viewModel.ServiceControl.DestinationPath;
serviceControlNewInstance.HostName = viewModel.ServiceControl.HostName;
serviceControlNewInstance.Port = Convert.ToInt32(viewModel.ServiceControl.PortNumber);
serviceControlNewInstance.DatabaseMaintenancePort = Convert.ToInt32(viewModel.ServiceControl.DatabaseMaintenancePortNumber);
serviceControlNewInstance.VirtualDirectory = null;
serviceControlNewInstance.ErrorQueue = viewModel.ServiceControl.ErrorQueueName;
serviceControlNewInstance.ErrorLogQueue = viewModel.ServiceControl.ErrorForwarding.Value ? viewModel.ServiceControl.ErrorForwardingQueueName : null;
serviceControlNewInstance.ForwardErrorMessages = viewModel.ServiceControl.ErrorForwarding.Value;
serviceControlNewInstance.TransportPackage = viewModel.SelectedTransport;
serviceControlNewInstance.ConnectionString = viewModel.ConnectionString;
serviceControlNewInstance.ErrorRetentionPeriod = viewModel.ServiceControl.ErrorRetentionPeriod;
serviceControlNewInstance.ServiceAccount = viewModel.ServiceControl.ServiceAccount;
serviceControlNewInstance.ServiceAccountPwd = viewModel.ServiceControl.Password;
serviceControlNewInstance.EnableFullTextSearchOnBodies = viewModel.ServiceControl.EnableFullTextSearchOnBodies.Value;
}

var auditNewInstance = viewModel.InstallAuditInstance ? ServiceControlAuditNewInstance.CreateWithDefaultPersistence() : null;
if (viewModel.InstallAuditInstance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,29 +147,28 @@ protected override void BeginProcessing()

protected override void ProcessRecord()
{
var details = new ServiceControlNewInstance
{
InstallPath = InstallPath,
LogPath = LogPath,
DBPath = DBPath,
Name = Name,
DisplayName = string.IsNullOrWhiteSpace(DisplayName) ? Name : DisplayName,
ServiceDescription = Description,
ServiceAccount = ServiceAccount,
ServiceAccountPwd = ServiceAccountPassword,
HostName = HostName,
Port = Port,
DatabaseMaintenancePort = DatabaseMaintenancePort,
VirtualDirectory = VirtualDirectory,
ErrorQueue = ErrorQueue,
ErrorLogQueue = string.IsNullOrWhiteSpace(ErrorLogQueue) ? null : ErrorLogQueue,
ForwardErrorMessages = ForwardErrorMessages.ToBool(),
ErrorRetentionPeriod = ErrorRetentionPeriod,
ConnectionString = ConnectionString,
TransportPackage = ServiceControlCoreTransports.All.First(t => t.Matches(Transport)),
SkipQueueCreation = SkipQueueCreation,
EnableFullTextSearchOnBodies = EnableFullTextSearchOnBodies,
};
var details = ServiceControlNewInstance.CreateWithDefaultPersistence();

details.InstallPath = InstallPath;
details.LogPath = LogPath;
details.DBPath = DBPath;
details.Name = Name;
details.DisplayName = string.IsNullOrWhiteSpace(DisplayName) ? Name : DisplayName;
details.ServiceDescription = Description;
details.ServiceAccount = ServiceAccount;
details.ServiceAccountPwd = ServiceAccountPassword;
details.HostName = HostName;
details.Port = Port;
details.DatabaseMaintenancePort = DatabaseMaintenancePort;
details.VirtualDirectory = VirtualDirectory;
details.ErrorQueue = ErrorQueue;
details.ErrorLogQueue = string.IsNullOrWhiteSpace(ErrorLogQueue) ? null : ErrorLogQueue;
details.ForwardErrorMessages = ForwardErrorMessages.ToBool();
details.ErrorRetentionPeriod = ErrorRetentionPeriod;
details.ConnectionString = ConnectionString;
details.TransportPackage = ServiceControlCoreTransports.All.First(t => t.Matches(Transport));
details.SkipQueueCreation = SkipQueueCreation;
details.EnableFullTextSearchOnBodies = EnableFullTextSearchOnBodies;

var modulePath = Path.GetDirectoryName(MyInvocation.MyCommand.Module.Path);
var zipfolder = ZipPath.Get(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Xml;
using NUnit.Framework;
using ServiceControlInstaller.Engine.Configuration.ServiceControl;
using ServiceControlInstaller.Engine.FileSystem;
using ServiceControlInstaller.Engine.Instances;
using ServiceControlInstaller.Engine.Services;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void Should_parse_all_persister_manifests()

var zipFile = zipFiles.Single(f => f.Name.StartsWith("Particular.ServiceControl.Audit"));

var allManifests = ServiceControlAuditPersisters.LoadAllManifests(zipFile.FullName);
var allManifests = ServiceControlPersisters.LoadAllManifests(zipFile.FullName);

CollectionAssert.IsNotEmpty(allManifests);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,29 @@ public async Task CreateInstanceMSMQ()
var installer = new UnattendServiceControlInstaller(new TestLogger(), DeploymentCache);
var instanceName = "Test.ServiceControl.Msmq";
var root = Path.Combine(@"c:\Test", instanceName);
var details = new ServiceControlNewInstance
{
DisplayName = instanceName.Replace(".", " "),
Name = instanceName,
ServiceDescription = "Test SC Instance",
DBPath = Path.Combine(root, "Database"),
LogPath = Path.Combine(root, "Logs"),
InstallPath = Path.Combine(root, "Binaries"),
HostName = "localhost",
Port = 33335,
DatabaseMaintenancePort = 33336,
VirtualDirectory = null,
AuditQueue = "audittest",
ForwardAuditMessages = false,
ForwardErrorMessages = false,
AuditRetentionPeriod = TimeSpan.FromDays(SettingConstants.AuditRetentionPeriodDefaultInDaysForUI),
ErrorRetentionPeriod = TimeSpan.FromDays(SettingConstants.ErrorRetentionPeriodDefaultInDaysForUI),
ErrorQueue = "testerror",
TransportPackage = ServiceControlCoreTransports.All.First(t => t.Name == TransportNames.MSMQ),
ReportCard = new ReportCard(),
// but this fails for unit tests as the deploymentCache path is not used
// constructer of ServiceControlInstanceMetadata extracts version from zip
Version = installer.ZipInfo.Version
};
var details = ServiceControlNewInstance.CreateWithDefaultPersistence(DeploymentCache);

details.DisplayName = instanceName.Replace(".", " ");
details.Name = instanceName;
details.ServiceDescription = "Test SC Instance";
details.DBPath = Path.Combine(root, "Database");
details.LogPath = Path.Combine(root, "Logs");
details.InstallPath = Path.Combine(root, "Binaries");
details.HostName = "localhost";
details.Port = 33335;
details.DatabaseMaintenancePort = 33336;
details.VirtualDirectory = null;
details.AuditQueue = "audittest";
details.ForwardAuditMessages = false;
details.ForwardErrorMessages = false;
details.AuditRetentionPeriod = TimeSpan.FromDays(SettingConstants.AuditRetentionPeriodDefaultInDaysForUI);
details.ErrorRetentionPeriod = TimeSpan.FromDays(SettingConstants.ErrorRetentionPeriodDefaultInDaysForUI);
details.ErrorQueue = "testerror";
details.TransportPackage = ServiceControlCoreTransports.All.First(t => t.Name == TransportNames.MSMQ);
details.ReportCard = new ReportCard();
// but this fails for unit tests as the deploymentCache path is not used
// constructer of ServiceControlInstanceMetadata extracts version from zip
details.Version = installer.ZipInfo.Version;

await details.Validate(s => Task.FromResult(false)).ConfigureAwait(false);
if (details.ReportCard.HasErrors)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ public class PathsValidationTests
[Test]
public void CheckPathsAreUnique_ShouldThrow()
{
var newInstance = new ServiceControlNewInstance
{
InstallPath = @"c:\test\1\bin",
LogPath = @"c:\test\1\bin",
DBPath = @"c:\test\1\bin"
};
var newInstance = ServiceControlNewInstance.CreateWithDefaultPersistence();

newInstance.InstallPath = @"c:\test\1\bin";
newInstance.LogPath = @"c:\test\1\bin";
newInstance.DBPath = @"c:\test\1\bin";

var p = new PathsValidator(newInstance);

Expand All @@ -28,12 +27,11 @@ public void CheckPathsAreUnique_ShouldThrow()
[Test]
public void CheckPathsAreUnique_ShouldSucceed()
{
var newInstance = new ServiceControlNewInstance
{
InstallPath = @"c:\test\1\bin",
LogPath = @"c:\test\1\log",
DBPath = @"c:\test\1\db"
};
var newInstance = ServiceControlNewInstance.CreateWithDefaultPersistence();

newInstance.InstallPath = @"c:\test\1\bin";
newInstance.LogPath = @"c:\test\1\log";
newInstance.DBPath = @"c:\test\1\db";

var p = new PathsValidator(newInstance);
Assert.DoesNotThrow(() => p.CheckPathsAreUnique());
Expand All @@ -43,12 +41,11 @@ public void CheckPathsAreUnique_ShouldSucceed()
[Test]
public void CheckPathsAreValid_ShouldSucceed()
{
var newInstance = new ServiceControlNewInstance
{
InstallPath = @"c:\test\1\bin",
LogPath = @"c:\test\1\bin",
DBPath = @"c:\test\1\bin"
};
var newInstance = ServiceControlNewInstance.CreateWithDefaultPersistence();

newInstance.InstallPath = @"c:\test\1\bin";
newInstance.LogPath = @"c:\test\1\bin";
newInstance.DBPath = @"c:\test\1\bin";

var p = new PathsValidator(newInstance);
Assert.DoesNotThrow(() => p.CheckPathsAreValid());
Expand All @@ -58,35 +55,36 @@ public void CheckPathsAreValid_ShouldSucceed()
public void CheckPathsAreValid_ShouldThrow()
{
//Invalid path
var p = new PathsValidator(new ServiceControlNewInstance { InstallPath = @"?>c:\test\1\bin" });
var instance = ServiceControlNewInstance.CreateWithDefaultPersistence();
instance.InstallPath = @"?>c:\test\1\bin";
var p = new PathsValidator(instance);

var ex = Assert.Throws<EngineValidationException>(() => p.CheckPathsAreValid());
Assert.That(ex.Message, Is.EqualTo("The install path is set to an invalid path"));

instance.InstallPath = @"\test\1\bin";

//Partial path
p = new PathsValidator(new ServiceControlNewInstance
{
InstallPath = @"\test\1\bin"
});
p = new PathsValidator(instance);

ex = Assert.Throws<EngineValidationException>(() => p.CheckPathsAreValid());
Assert.That(ex.Message, Is.EqualTo("The install path is set to an invalid path"));

//No Drive
p = new PathsValidator(new ServiceControlNewInstance { InstallPath = $@"{GetAnUnsedDriveLetter()}:\test\1\bin" });
instance.InstallPath = $@"{GetAnUnsedDriveLetter()}:\test\1\bin";
p = new PathsValidator(instance);
ex = Assert.Throws<EngineValidationException>(() => p.CheckPathsAreValid());
Assert.That(ex.Message, Is.EqualTo("The install path does not go to a supported drive"));
}

[Test]
public void CheckNoNestedPaths_ShouldThrow()
{
var newInstance = new ServiceControlNewInstance
{
InstallPath = @"c:\test\1",
LogPath = @"c:\test\1\log",
DBPath = @"c:\test\1\db"
};
var newInstance = ServiceControlNewInstance.CreateWithDefaultPersistence();

newInstance.InstallPath = @"c:\test\1";
newInstance.LogPath = @"c:\test\1\log";
newInstance.DBPath = @"c:\test\1\db";

var p = new PathsValidator(newInstance);
var ex = Assert.Throws<EngineValidationException>(() => p.CheckNoNestedPaths());
Expand All @@ -96,12 +94,11 @@ public void CheckNoNestedPaths_ShouldThrow()
[Test]
public void CheckNoNestedSiblingPaths_ShouldSucceed()
{
var newInstance = new ServiceControlNewInstance
{
InstallPath = @"c:\test\1\servicecontrol",
LogPath = @"c:\test\1\servicecontrollog",
DBPath = @"c:\test\1\servicecontroldb"
};
var newInstance = ServiceControlNewInstance.CreateWithDefaultPersistence();

newInstance.InstallPath = @"c:\test\1\servicecontrol";
newInstance.LogPath = @"c:\test\1\servicecontrollog";
newInstance.DBPath = @"c:\test\1\servicecontroldb";

var p = new PathsValidator(newInstance);
Assert.DoesNotThrow(() => p.CheckNoNestedPaths());
Expand All @@ -110,12 +107,11 @@ public void CheckNoNestedSiblingPaths_ShouldSucceed()
[Test]
public void CheckNoNestedPaths_ShouldSucceed()
{
var newInstance = new ServiceControlNewInstance
{
InstallPath = @"c:\test\1\bin",
LogPath = @"c:\test\1\log",
DBPath = @"c:\test\1\db"
};
var newInstance = ServiceControlNewInstance.CreateWithDefaultPersistence();

newInstance.InstallPath = @"c:\test\1\bin";
newInstance.LogPath = @"c:\test\1\log";
newInstance.DBPath = @"c:\test\1\db";

var p = new PathsValidator(newInstance);

Expand Down
Loading