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

Timeout option #330

Merged
merged 2 commits into from
Oct 31, 2024
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
@@ -0,0 +1,49 @@
using System.Threading;
using Clio.Command;
using FluentAssertions;
using NUnit.Framework;

namespace Clio.Tests.Command.ApplicationCommand;

[TestFixture]
public class CompileConfigurationOptionsTestFixture {

[Test]
public void CanSetTimeout(){
//Arrange
RemoteCommandOptions options = new() {
TimeOut = 50
};

//Assert
options.TimeOut.Should().Be(50);
}

[Test]
public void DefaultTimeout_ShouldBe_Infinite(){
//Arrange
CompileConfigurationOptions options = new();

//Assert
options.TimeOut.Should().Be(Timeout.Infinite);
}

[Test]
public void DefaultTimeoutInReomoe_ShouldBe_100K(){
//Arrange
RemoteCommandOptions options = new();

//Assert
options.TimeOut.Should().Be(100_000);
}


[Test]
public void RestartOPtions(){
//Arrange
RestartOptions options = new();

//Assert
options.TimeOut.Should().Be(100_000);
}
}
4 changes: 2 additions & 2 deletions clio.tests/Command/RedisCommand.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void ClearRedisDb_FormsCorrectApplicationRequest_WhenApplicationRunsUnder
IsNetCore = false
};
RedisCommand redisCommand = new RedisCommand(applicationClient, settings);
var clearRedisOptions = Substitute.For<ClearRedisOptions>();
ClearRedisOptions clearRedisOptions = new();

//Act
redisCommand.Execute(clearRedisOptions);
Expand All @@ -39,7 +39,7 @@ public void ClearRedisDb_FormsCorrectApplicationRequest_WhenApplicationRunsUnder
IsNetCore = true
};
RedisCommand redisCommand = new RedisCommand(applicationClient, settings);
var clearRedisOptions = Substitute.For<ClearRedisOptions>();
ClearRedisOptions clearRedisOptions = new();

//Act
redisCommand.Execute(clearRedisOptions);
Expand Down
4 changes: 2 additions & 2 deletions clio.tests/Command/RestartCommand.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void RestartCommand_FormsCorrectApplicationRequest_WhenApplicationRunsUnd
Uri = "http://test.domain.com"
};
RestartCommand restartCommand = new RestartCommand(applicationClient, environmentSettings);
var options = Substitute.For<RestartOptions>();
RestartOptions options = new();

//Act
restartCommand.Execute(options);
Expand All @@ -44,7 +44,7 @@ public void RestartCommand_FormsCorrectApplicationRequest_WhenApplicationRunsUnd
Uri = "http://test.domain.com"
};
RestartCommand restartCommand = new RestartCommand(applicationClient, environmentSettings);
var options = Substitute.For<RestartOptions>();
RestartOptions options = new();

//Act
restartCommand.Execute(options);
Expand Down
4 changes: 3 additions & 1 deletion clio/Command/CompileConfigurationCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Threading;
using Clio.Common;
using CommandLine;

Expand All @@ -15,7 +16,8 @@ public class CompileConfigurationOptions : RemoteCommandOptions
public bool All {
get; set;
}

protected override int DefaultTimeout => Timeout.Infinite;

}

#endregion
Expand Down
13 changes: 12 additions & 1 deletion clio/Command/RemoteCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@
using System.Reflection;
using Clio.Common;
using CommandLine;
using DocumentFormat.OpenXml.Spreadsheet;

namespace Clio.Command;

public class RemoteCommandOptions : EnvironmentOptions
{
public int TimeOut { get; internal set; } = 100_000;

private int? _timeOut;
protected virtual int DefaultTimeout { get; set; } = 100_000;


[Option("timeout", Required = false, HelpText = "Request timeout in milliseconds", Default = 100_000)]
public int TimeOut {
get => _timeOut ?? DefaultTimeout;
internal set => _timeOut = value;
}

public int RetryCount { get; internal set; } = 3;
public int RetryDelay { get; internal set; } = 1;

Expand Down