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 @@ -2,6 +2,7 @@
{
using System;
using System.ComponentModel;
using System.Linq;
using NUnit.Framework;
using ServiceControlInstaller.Engine.Configuration.ServiceControl;
using UI.InstanceAdd;
Expand Down Expand Up @@ -277,5 +278,86 @@ public void Full_text_search_on_bodies_is_enabled()
Assert.That(viewModel.AuditEnableFullTextSearchOnBodies.Value, Is.EqualTo(true));
}
}

[Test]
public void Instance_sections_are_expanded_by_default()
{
var viewModel = new ServiceControlAddViewModel();

using (Assert.EnterMultipleScope())
{
Assert.That(viewModel.IsServiceControlExpanded, Is.True);
Assert.That(viewModel.IsServiceControlAuditExpanded, Is.True);
}
}

[Test]
public void Integrated_ServicePulse_is_enabled_by_default()
{
var viewModel = new ServiceControlAddViewModel();

using (Assert.EnterMultipleScope())
{
Assert.That(viewModel.ErrorEnableIntegratedServicePulseOptions, Is.Not.Empty);
Assert.That(viewModel.ErrorEnableIntegratedServicePulse.Value, Is.True);
}
}

[Test]
public void Integrated_ServicePulse_can_be_disabled()
{
var viewModel = new ServiceControlAddViewModel();

var offOption = viewModel.ErrorEnableIntegratedServicePulseOptions.First(o => !o.Value);
viewModel.ServiceControl.EnableIntegratedServicePulse = offOption;

Assert.That(viewModel.ErrorEnableIntegratedServicePulse.Value, Is.False);
}

[Test]
public void Audit_only_configuration_has_no_validation_errors_for_error_fields()
{
var viewModel = new ServiceControlAddViewModel(() => [])
{
InstallErrorInstance = false,
InstallAuditInstance = true,
SubmitAttempted = true
};

var notifyErrorInfo = (INotifyDataErrorInfo)viewModel;

using (Assert.EnterMultipleScope())
{
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.ErrorInstanceName)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.ErrorHostName)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.ErrorPortNumber)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.ErrorDestinationPath)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.ErrorLogPath)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.ErrorDatabasePath)), Is.Empty);
}
}

[Test]
public void Error_only_configuration_has_no_validation_errors_for_audit_fields()
{
var viewModel = new ServiceControlAddViewModel(() => [])
{
InstallErrorInstance = true,
InstallAuditInstance = false,
SubmitAttempted = true
};

var notifyErrorInfo = (INotifyDataErrorInfo)viewModel;

using (Assert.EnterMultipleScope())
{
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.AuditInstanceName)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.AuditHostName)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.AuditPortNumber)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.AuditDestinationPath)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.AuditLogPath)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.AuditDatabasePath)), Is.Empty);
}
}
}
}
51 changes: 51 additions & 0 deletions src/ServiceControl.Config.Tests/SetupModeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
namespace ServiceControl.Config.Tests
{
using NUnit.Framework;
using UI.Shell;

[TestFixture]
class SetupModeTests
{
[TestCase(SetupMode.ErrorHandling, true, false, false)]
[TestCase(SetupMode.ErrorAndAudit, true, true, false)]
[TestCase(SetupMode.AuditOnly, false, true, false)]
[TestCase(SetupMode.MonitoringOnly, false, false, true)]
public void Scenario_selects_the_instances_to_install(SetupMode mode, bool serviceControl, bool audit, bool monitoring)
{
using (Assert.EnterMultipleScope())
{
Assert.That(mode.InstallsServiceControl(), Is.EqualTo(serviceControl));
Assert.That(mode.InstallsAudit(), Is.EqualTo(audit));
Assert.That(mode.InstallsMonitoring(), Is.EqualTo(monitoring));
}
}

[TestCase(SetupMode.ErrorHandling)]
[TestCase(SetupMode.ErrorAndAudit)]
[TestCase(SetupMode.AuditOnly)]
[TestCase(SetupMode.MonitoringOnly)]
public void Every_scenario_installs_at_least_one_instance(SetupMode mode)
{
// The Next button is always enabled, so no scenario may resolve to nothing.
Assert.That(mode.InstallsServiceControl() || mode.InstallsAudit() || mode.InstallsMonitoring(), Is.True);
}

[TestCase(SetupMode.ErrorHandling)]
[TestCase(SetupMode.ErrorAndAudit)]
public void Integrated_ServicePulse_follows_the_choice_when_an_error_instance_is_installed(SetupMode mode)
{
using (Assert.EnterMultipleScope())
{
Assert.That(mode.InstallsServicePulse(wanted: true), Is.True);
Assert.That(mode.InstallsServicePulse(wanted: false), Is.False);
}
}

[TestCase(SetupMode.AuditOnly)]
[TestCase(SetupMode.MonitoringOnly)]
public void Integrated_ServicePulse_is_never_installed_without_an_error_instance(SetupMode mode)
{
Assert.That(mode.InstallsServicePulse(wanted: true), Is.False);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
namespace ServiceControl.Config.Commands
namespace ServiceControl.Config.Commands
{
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Framework;
using Framework.Commands;
Expand All @@ -18,17 +20,32 @@ public AddServiceControlInstanceCommand(IServiceControlWindowManager windowManag

public override async Task ExecuteAsync(object obj)
{
if (!await commandChecks.CanAddInstance(true))
await ExecuteWithOptions(installError: true, installAudit: true, installServicePulse: true);
}

public async Task ExecuteWithOptions(bool installError, bool installAudit, bool installServicePulse, CancellationToken cancellationToken = default)
{
if (!await commandChecks.CanAddInstance(true, cancellationToken))
{
return;
}

var instanceViewModel = addInstance();
await windowManager.ShowInnerDialog(instanceViewModel);
instanceViewModel.InstallErrorInstance = installError;
instanceViewModel.InstallAuditInstance = installAudit;

if (installError)
{
// The options list always carries both an On and an Off entry.
instanceViewModel.ServiceControl.EnableIntegratedServicePulse = instanceViewModel.ServiceControl
.EnableIntegratedServicePulseOptions.First(o => o.Value == installServicePulse);
}

await windowManager.ShowInnerDialog(instanceViewModel, cancellationToken: cancellationToken);
}

readonly Func<ServiceControlAddViewModel> addInstance;
readonly IServiceControlWindowManager windowManager;
readonly ScmuCommandChecks commandChecks;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@
Visibility="{Binding InMaintenanceMode, Converter={StaticResource boolToVisInverted}}"
Margin="0,0,0,20"
>
Enter database maintenance mode to access to RavenDB Management Studio. While in this mode all message processing is disabled and the REST API is unavailable. This will prevent ServicePulse and ServiceInsight connecting to this instance.
Enter database maintenance mode to access to RavenDB Management Studio. While in this mode all message processing is disabled and the REST API is unavailable. This will prevent ServicePulse connecting to this instance.
</TextBlock>

<TextBlock FontSize="12px"
TextWrapping="Wrap"
Visibility="{Binding InMaintenanceMode, Converter={StaticResource boolToVis}}"
Margin="0,0,0,20"
>
This instance is in database maintenance mode. All message processing is disabled and the REST API is unavailable.<LineBreak />ServicePulse and ServiceInsight cannot connect to this instance while it is in maintenance mode.<LineBreak />Launch <Hyperlink Command="{Binding OpenUrl}" CommandParameter="{Binding RavenDbStudioUrl}">
This instance is in database maintenance mode. All message processing is disabled and the REST API is unavailable.<LineBreak />ServicePulse cannot connect to this instance while it is in maintenance mode.<LineBreak />Launch <Hyperlink Command="{Binding OpenUrl}" CommandParameter="{Binding RavenDbStudioUrl}">
RavenDB Management Studio
<Hyperlink.ContextMenu>
<ContextMenu>
Expand Down
74 changes: 18 additions & 56 deletions src/ServiceControl.Config/UI/InstanceAdd/ServiceControlAddView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,34 +73,14 @@
Converter={StaticResource boolToVis}}" />
</StackPanel>

<TextBlock Padding="0, 0, 0, 10" Visibility="{Binding OneInstanceTypeSelected, Converter={StaticResource boolToVisInverted}}"
FontSize="13px"
Foreground="{StaticResource ErrorBrush}"
Text="Must select either an audit or an error instance." />

<StackPanel>
<!-- Horizontal layout: CheckBox + Expander side by side -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<CheckBox Grid.Column="0"
Padding="0, 0, 0, 0"
IsChecked="{Binding InstallErrorInstance}"
VerticalAlignment="Top"
Margin="0,8,8,5"/>

<Expander Grid.Column="1"
Header="ServiceControl"
IsExpanded="{Binding IsServiceControlExpanded}"
IsEnabled="{Binding InstallErrorInstance}"
Margin="0,5,0,5"
MouseDown="Button_MouseDown"
PreviewMouseDown="Button_MouseDown"
PreviewMouseLeftButtonDown="Button_MouseDown">
<StackPanel Margin="60,0,60,0" Visibility="{Binding InstallErrorInstance, Converter={StaticResource boolToVis}}">
<StackPanel Visibility="{Binding InstallErrorInstance, Converter={StaticResource boolToVis}}">
<Expander Header="ServiceControl"
IsExpanded="{Binding IsServiceControlExpanded}"
Margin="0,5,0,5"
MouseDown="Button_MouseDown"
PreviewMouseDown="Button_MouseDown"
PreviewMouseLeftButtonDown="Button_MouseDown">
<StackPanel Margin="60,0,60,0">
<Border Margin="0,40,0,20"
BorderBrush="{StaticResource Gray70Brush}"
BorderThickness="0,0,0,1">
Expand Down Expand Up @@ -261,34 +241,17 @@
ItemsSource="{Binding ErrorEnableIntegratedServicePulseOptions}"
SelectedValue="{Binding ErrorEnableIntegratedServicePulse}" />
</StackPanel>
</Expander>
</Grid>
</Expander>
</StackPanel>

<StackPanel>
<!-- Horizontal layout: CheckBox + Expander side by side -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<CheckBox Grid.Column="0"
Padding="0, 0, 0, 0"
IsChecked="{Binding InstallAuditInstance}"
IsThreeState="False"
VerticalAlignment="Top"
Margin="0,8,8,5"/>

<Expander Grid.Column="1"
Header="ServiceControl Audit"
IsExpanded="{Binding IsServiceControlAuditExpanded}"
IsEnabled="{Binding InstallAuditInstance}"
Margin="0,5,0,5"
MouseDown="Button_MouseDown"
PreviewMouseDown="Button_MouseDown"
PreviewMouseLeftButtonDown="Button_MouseDown">
<StackPanel Margin="60,0,60,0" Visibility="{Binding InstallAuditInstance, Converter={StaticResource boolToVis}}">
<StackPanel Visibility="{Binding InstallAuditInstance, Converter={StaticResource boolToVis}}">
<Expander Header="ServiceControl Audit"
IsExpanded="{Binding IsServiceControlAuditExpanded}"
Margin="0,5,0,5"
MouseDown="Button_MouseDown"
PreviewMouseDown="Button_MouseDown"
PreviewMouseLeftButtonDown="Button_MouseDown">
<StackPanel Margin="60,0,60,0">
<Border Margin="0,40,0,20"
BorderBrush="{StaticResource Gray70Brush}"
BorderThickness="0,0,0,1">
Expand Down Expand Up @@ -458,8 +421,7 @@
ItemsSource="{Binding AuditEnableFullTextSearchOnBodiesOptions}"
SelectedValue="{Binding AuditEnableFullTextSearchOnBodies}" />
</StackPanel>
</Expander>
</Grid>
</Expander>
</StackPanel>
</StackPanel>
</sie:SharedServiceControlEditorView.SharedContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,9 @@ public string AuditDatabasePath

public TimeSpanUnits AuditRetentionUnits => ServiceControlAudit.AuditRetentionUnits;

public bool IsServiceControlExpanded { get; set; }
public bool IsServiceControlExpanded { get; set; } = true;

public bool IsServiceControlAuditExpanded { get; set; }
public bool IsServiceControlAuditExpanded { get; set; } = true;

public double AuditRetention
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ public virtual void OnSelectedTransportChanged()
// Needs to exist in base class for Fody to call it so it can be executed in superclass
}

public bool OneInstanceTypeSelected => InstallErrorInstance || InstallAuditInstance;

public string TransportWarning => SelectedTransport?.Help;

public string ConnectionString { get; set; }
Expand Down
21 changes: 3 additions & 18 deletions src/ServiceControl.Config/UI/NoInstances/NoInstancesView.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<UserControl x:Class="ServiceControl.Config.UI.NoInstances.NoInstancesView"
<UserControl x:Class="ServiceControl.Config.UI.NoInstances.NoInstancesView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Expand All @@ -7,26 +7,11 @@
d:DesignWidth="600"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<TextBlock Margin="10"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
VerticalAlignment="Center"
FontSize="20"
Foreground="{StaticResource Gray60Brush}"
Text="No service instances installed" />

<Button Grid.Row="1"
Margin="10"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Command="{Binding AddInstance}"
Content="Add new instance"
Style="{StaticResource HiliteButton}"
Visibility="{Binding ShowMonitoringInstances,
Converter={StaticResource boolToVisInverted}}" />
</Grid>
</UserControl>
</UserControl>
15 changes: 3 additions & 12 deletions src/ServiceControl.Config/UI/NoInstances/NoInstancesViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
namespace ServiceControl.Config.UI.NoInstances
namespace ServiceControl.Config.UI.NoInstances
{
using System.Windows.Input;
using Commands;
using Framework.Rx;

class NoInstancesViewModel : RxScreen
{
public NoInstancesViewModel(AddServiceControlInstanceCommand addInstance)
public NoInstancesViewModel()
{
DisplayName = "DEPLOYED INSTANCES";

AddInstance = addInstance;
}

public ICommand AddInstance { get; }

[FeatureToggle(Feature.MonitoringInstances)]
public bool ShowMonitoringInstances { get; set; }
}
}
}
Loading