Skip to content

Commit

Permalink
Merge pull request #632 from Sitecore/feature/613-Make_the_Success_me…
Browse files Browse the repository at this point in the history
…ssages_more_informative

Feature/613 make the success messages more informative
  • Loading branch information
AndreyFilchenkov authored Nov 8, 2021
2 parents efeadd2 + 88157d8 commit 8ec9e8b
Show file tree
Hide file tree
Showing 17 changed files with 43 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
using NSubstitute;
using SIM.Sitecore9Installer.Validation;
using SIM.Sitecore9Installer.Validation.Validators;
Expand All @@ -17,7 +12,7 @@ public class DiskSpaceValidatorTests
[Theory]
[InlineData(@"C:\inetpub\wwwroot", 7368709120, ValidatorState.Success, "Hard disk has enough free space to continue the installation.")]
[InlineData(@"C:\inetpub\wwwroot\", 5368709119, ValidatorState.Warning, @"Hard disk 'C:\' has a little free space.")]
[InlineData(@"D:\inetpub\", 3221225470, ValidatorState.Error, @"Hard disk 'D:\' does not have enough free space to continue installation.")]
[InlineData(@"D:\inetpub\", 3221225470, ValidatorState.Error, @"Hard disk 'D:\' does not have enough free space to continue the installation.")]
[InlineData(@"D:\inetpub\wwwroot", -1, ValidatorState.Error, @"Hard disk 'D:\' has not been found.")]

public void ReturnsValidValidationResults(string deployRoot, long freeSpace, ValidatorState expectedResult, string resultMessage)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using NSubstitute;
using SIM.Sitecore9Installer.Validation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SIM.Sitecore9Installer.Tasks;
using SIM.Sitecore9Installer.Validation.Validators;
using Xunit;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using NSubstitute;
using SIM.Sitecore9Installer.Tasks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
using SIM.Sitecore9Installer.Tasks;
using SIM.Sitecore9Installer.Validation;
using SIM.Sitecore9Installer.Validation.Validators;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;

namespace SIM.Sitecore9Installer.Tests.Validation.Validators
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace SIM.Sitecore9Installer.Validation.Validators
{
public class CertificateValidator : BaseValidator
{
public override string SuccessMessage => $"Invalid certificates have not been found in {this.Data["StoreName"]}.";
public override string SuccessMessage => $"Invalid certificates have not been found in the '{this.Data["StoreName"]}' store.";

protected override IEnumerable<ValidationResult> GetErrorsForTask(Task task, IEnumerable<InstallParam> paramsToValidate)
{
Expand All @@ -26,7 +26,7 @@ protected override IEnumerable<ValidationResult> GetErrorsForTask(Task task, IEn
bool isValid = this.ValidateCertificate(x509);
if (!isValid)
{
yield return new ValidationResult(ValidatorState.Error, string.Format("Certificate {0} - {1} is not valid", x509.SubjectName.Name, x509.Thumbprint), null);
yield return new ValidationResult(ValidatorState.Error, string.Format("Certificate '{0} - {1}' is not valid.", x509.SubjectName.Name, x509.Thumbprint), null);
}
x509.Reset();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class CmDdsPatchSiteNameValidator : IValidator

public Dictionary<string, string> Data { get; set; }

public virtual string SuccessMessage => "'SiteName' value was set properly for 'sitecore-xp1-cm' and 'sitecore-XP1-cm-dds-patch' installation tasks.";
public virtual string SuccessMessage => "The 'SiteName' parameter's value was set properly for the 'sitecore-xp1-cm' and 'sitecore-XP1-cm-dds-patch' installation tasks.";

public CmDdsPatchSiteNameValidator()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class CmIdentityServerSiteNameValidator : IValidator

public Dictionary<string, string> Data { get; set; }

public virtual string SuccessMessage => "'AllowedCorsOrigins' and 'PasswordRecoveryUrl' were set properly for 'IdentityServer' installation task.";
public virtual string SuccessMessage => "The 'AllowedCorsOrigins' and 'PasswordRecoveryUrl' parameters were set properly for the 'IdentityServer' installation task.";

public CmIdentityServerSiteNameValidator()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ public IEnumerable<ValidationResult> Evaluate(IEnumerable<Tasks.Task> tasks)

if (errorGetcores != null)
{
yield return new ValidationResult(ValidatorState.Error, $"Unable to get cores from solr {item.Item1}", errorGetcores);
yield return new ValidationResult(ValidatorState.Error, $"Unable to get cores from Solr '{item.Item1}'.", errorGetcores);
continue;
}

if (coreNames.Any(cn => cn.StartsWith(item.Item2, StringComparison.InvariantCultureIgnoreCase)))
{
errors = true;
yield return new ValidationResult(ValidatorState.Error, $"Core with prefix {item.Item2} already exists in solr {item.Item1}",null);
yield return new ValidationResult(ValidatorState.Error, $"Core with the '{item.Item2}' prefix already exists in Solr '{item.Item1}'.", null);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SIM.Sitecore9Installer.Tasks;
using Task = SIM.Sitecore9Installer.Tasks.Task;

namespace SIM.Sitecore9Installer.Validation.Validators
Expand Down Expand Up @@ -42,7 +38,7 @@ public IEnumerable<ValidationResult> Evaluate(IEnumerable<Task> tasks)
if (freeSpace < hardDriveErrorLimit)
{
errors = true;
yield return new ValidationResult(ValidatorState.Error, $"Hard disk '{drive}' does not have enough free space to continue installation.", null);
yield return new ValidationResult(ValidatorState.Error, $"Hard disk '{drive}' does not have enough free space to continue the installation.", null);
}
else
if (freeSpace < hardDriveWarningLimit)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections.Generic;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using SIM.Sitecore9Installer.Tasks;

namespace SIM.Sitecore9Installer.Validation.Validators
{
public class HostAvaiableValidator : BaseValidator
{
public override string SuccessMessage => "Host response is 200";
public override string SuccessMessage => null;

protected override IEnumerable<ValidationResult> GetErrorsForTask(Tasks.Task task, IEnumerable<InstallParam> paramsToValidate)
{
Expand All @@ -29,13 +24,17 @@ protected override IEnumerable<ValidationResult> GetErrorsForTask(Tasks.Task tas

if (error != null)
{
yield return new ValidationResult(ValidatorState.Error, $"Unable to connect to host {p.Value}", error);
yield return new ValidationResult(ValidatorState.Error, $"Unable to connect to the '{p.Value}' host defined in the '{p.Name}' parameter of the '{task.Name}' installation task.", error);
yield break;
}

if (resp.StatusCode != HttpStatusCode.OK)
{
yield return new ValidationResult(ValidatorState.Error, $"Host {p.Value} did not return 200.",null);
yield return new ValidationResult(ValidatorState.Error, $"The '{p.Value}' host defined in the '{p.Name}' parameter of the '{task.Name}' installation task did not return status code 200.", null);
}
else
{
yield return new ValidationResult(ValidatorState.Success, $"The '{p.Value}' host defined in the '{p.Name}' parameter of the '{task.Name}' installation task returned status code 200.", null);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ namespace SIM.Sitecore9Installer.Validation.Validators
{
public class HostNameValidator : BaseValidator
{
public override string SuccessMessage => "'Uri.CheckHostName()' validation has been finished successfully.";
public override string SuccessMessage => "Hosts defined in parameters of installations tasks are valid DNS names.";

protected override IEnumerable<ValidationResult> GetErrorsForTask(Task task, IEnumerable<InstallParam> paramsToValidate)
{
foreach (InstallParam param in paramsToValidate)
{
if (Uri.CheckHostName(param.Value) != UriHostNameType.Dns)
{
ValidationResult r = new ValidationResult(ValidatorState.Error,
string.Format("Invalid host in '{0}' of '{1}'", param.Name, task.Name), null);
string.Format("Invalid host is defined in the '{0}' parameter of the '{1}' installation task.", param.Name, task.Name), null);
yield return r;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using SIM.Sitecore9Installer.Tasks;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;

Expand All @@ -26,7 +25,7 @@ public IEnumerable<ValidationResult> Evaluate(IEnumerable<Tasks.Task> tasks)
{
if (!FileExists(path))
{
yield return new ValidationResult(ValidatorState.Error, $"Unable to locate {path} license file.", null);
yield return new ValidationResult(ValidatorState.Error, $"Unable to locate the '{path}' license file.", null);
hasErrors = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private IEnumerable<ValidationResult> GetValidationResults()
{
ValidationResult result = new ValidationResult(
state: ValidatorState.Error,
message: $"{TaskName}: nuget.exe is not a recognized as an internal or external command. To fix: download the NuGet.exe from https://www.nuget.org/downloads and set the local path of NuGet.exe into your path environment variable.",
message: $"{TaskName}: nuget.exe is not a recognized as an internal or external command. To fix: download 'nuget.exe' from https://www.nuget.org/downloads and set the local path of 'nuget.exe' into your path environment variable.",
error: null);

yield return result;
Expand All @@ -41,7 +41,7 @@ private IEnumerable<ValidationResult> GetValidationResults()
{
ValidationResult result = new ValidationResult(
state: ValidatorState.Error,
message: $"{TaskName}: The '{psError}' error occurred when 'nuget.exe' was invoked from PowerShell.",
message: $"{TaskName}: the '{psError}' error occurred when 'nuget.exe' was invoked from PowerShell.",
error: null);

yield return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ namespace SIM.Sitecore9Installer.Validation.Validators
{
public class PathExistsValidator : BaseValidator
{
public override string SuccessMessage => "Path exists on file system.";
public override string SuccessMessage => null;

protected override IEnumerable<ValidationResult> GetErrorsForTask(Tasks.Task task, IEnumerable<InstallParam> paramsToValidate)
{
foreach(InstallParam p in paramsToValidate)
{
if (!this.PathExists(p.Value))
{
yield return new ValidationResult(ValidatorState.Error, $"Path {p.Value} does not exist.", null);
yield return new ValidationResult(ValidatorState.Error, $"The '{p.Value}' path defined in the '{p.Name}' parameter of the '{task.Name}' installation task does not exist.", null);
}
else
{
yield return new ValidationResult(ValidatorState.Success, $"The '{p.Value}' path defined in the '{p.Name}' parameter of the '{task.Name}' installation task exists.", null);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected override IEnumerable<ValidationResult> GetErrorsForTask(Task task,
if (SolrStateResolver.GetServiceState(param.Value) == SolrState.CurrentState.Stopped)
{
yield return new ValidationResult(ValidatorState.Error,
$"Service '{param.Value}' required for '{task.Name}' is not running", null);
$"The '{param.Value}' service required for the '{task.Name}' installation task is not running.", null);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ namespace SIM.Sitecore9Installer.Validation.Validators
{
public class SolrVersionValidator : IValidator
{
public virtual string SuccessMessage => "Sitecore XP and 'Solr' versions are compatible.";
public virtual string SuccessMessage => "Sitecore and Solr versions are compatible.";

public string SolrUrl { get => this.Data["Solr"]; }

public Dictionary<string, string> Data { get; set; }
Expand Down Expand Up @@ -47,27 +48,27 @@ public IEnumerable<ValidationResult> Evaluate(IEnumerable<Tasks.Task> tasks)
if (errors.oldSolrTaskNames.Any())
{
yield return new ValidationResult(ValidatorState.Error,
$"'Solr' version is older than expected. Please consider a newer version. " +
$"Recommended 'Solr' versions: {Data["Versions"]}. " +
$"Solr version is older than expected. Please consider a newer version. " +
$"Recommended Solr versions: {Data["Versions"]}. " +
$"Installation tasks related to the problematic Solr versions: {string.Join(", ", errors.oldSolrTaskNames)}",
null);
}

if (errors.unresolvedSolrTaskNames.Any())
{
yield return new ValidationResult(ValidatorState.Error,
$"Unable to resolve 'Solr' versions for the following tasks: {string.Join(", ", errors.unresolvedSolrTaskNames)}",
$"Unable to resolve Solr versions for the following tasks: {string.Join(", ", errors.unresolvedSolrTaskNames)}",
null);
}

if (errors.untestedSolrTaskNames.Any())
{
yield return new ValidationResult(ValidatorState.Warning,
$"Sitecore XP and 'Solr' versions have not been tested together. They might be incompatible. " +
$"Recommended 'Solr' versions: {Data["Versions"]}. " +
$"Installation tasks related to the problematic Solr versions: {string.Join(", ", errors.untestedSolrTaskNames)}",
$"Sitecore and Solr versions have not been tested together. They might be incompatible. " +
$"Recommended Solr versions: {Data["Versions"]}. " +
$"Installation tasks related to the problematic Solr versions: {string.Join(", ", errors.untestedSolrTaskNames)}",
null);
}
}
}

private SolrVersionValidatorErrors GetErrors(IEnumerable<Tasks.Task> tasks, string[] compatibleVersions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

using SIM.Sitecore9Installer.Tasks;

namespace SIM.Sitecore9Installer.Validation.Validators
Expand Down Expand Up @@ -41,7 +39,7 @@ public IEnumerable<ValidationResult> Evaluate(IEnumerable<Tasks.Task> tasks)
{
if (this.GetDbList(set.Item1, set.Item2, set.Item3, set.Item4).Any())
{
yield return new ValidationResult(ValidatorState.Error, $"Database with prefix {set.Item4} already exists on server {set.Item1}",null);
yield return new ValidationResult(ValidatorState.Error, $"Database with the '{set.Item4}' prefix already exists on the '{set.Item1}' server.", null);
}
}

Expand Down

0 comments on commit 8ec9e8b

Please sign in to comment.