Skip to content

Commit

Permalink
Merge pull request #737 from OctopusDeploy/sast/FixingShouldLogStartu…
Browse files Browse the repository at this point in the history
…pDiagnosticsToInstanceLogFileOnly

Fix flakey tentacle command line tests
  • Loading branch information
sburmanoctopus authored Dec 14, 2023
2 parents 70c2052 + b25550c commit cd04022
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public PollingTentacleBuilder(int pollingPort, string serverThumbprint)

ServerThumbprint = serverThumbprint;
}

internal async Task<RunningTentacle> Build(ILogger log, CancellationToken cancellationToken)
{
var instanceName = InstanceNameGenerator();
Expand All @@ -46,7 +46,7 @@ internal async Task<RunningTentacle> Build(ILogger log, CancellationToken cancel
cancellationToken);
}

private void ConfigureTentacleToPollOctopusServer(string configFilePath, Uri subscriptionId, string applicationDirectory)
void ConfigureTentacleToPollOctopusServer(string configFilePath, Uri subscriptionId, string applicationDirectory)
{
WithWritableTentacleConfiguration(configFilePath, writableTentacleConfiguration =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ public async Task InvalidInstance(TentacleConfigurationTestCase tc)
public async Task ShowThumbprintCommandText(TentacleConfigurationTestCase tc)
{
await using var clientAndTentacle = await tc.CreateBuilder().Build(CancellationToken);
await clientAndTentacle.RunningTentacle.Stop(CancellationToken);
var (exitCode, stdout, stderr) = await RunCommandAndAssertExitsWithSuccessExitCode(
tc,
clientAndTentacle.RunningTentacle.RunTentacleEnvironmentVariables,
Expand All @@ -367,6 +368,7 @@ public async Task ShowThumbprintCommandText(TentacleConfigurationTestCase tc)
public async Task ShowThumbprintCommandJson(TentacleConfigurationTestCase tc)
{
await using var clientAndTentacle = await tc.CreateBuilder().Build(CancellationToken);
await clientAndTentacle.RunningTentacle.Stop(CancellationToken);
var (exitCode, stdout, stderr) = await RunCommandAndAssertExitsWithSuccessExitCode(
tc,
clientAndTentacle.RunningTentacle.RunTentacleEnvironmentVariables,
Expand All @@ -384,6 +386,7 @@ public async Task ShowThumbprintCommandJson(TentacleConfigurationTestCase tc)
public async Task ListInstancesCommandText(TentacleConfigurationTestCase tc)
{
await using var clientAndTentacle = await tc.CreateBuilder().Build(CancellationToken);
await clientAndTentacle.RunningTentacle.Stop(CancellationToken);
var (exitCode, stdout, stderr) = await RunCommandAndAssertExitsWithSuccessExitCode(
tc,
clientAndTentacle.RunningTentacle.RunTentacleEnvironmentVariables,
Expand All @@ -402,6 +405,7 @@ public async Task ListInstancesCommandText(TentacleConfigurationTestCase tc)
public async Task ListInstancesCommandJson(TentacleConfigurationTestCase tc)
{
await using var clientAndTentacle = await tc.CreateBuilder().Build(CancellationToken);
await clientAndTentacle.RunningTentacle.Stop(CancellationToken);
var (_, stdout, stderr) = await RunCommandAndAssertExitsWithSuccessExitCode(
tc,
clientAndTentacle.RunningTentacle.RunTentacleEnvironmentVariables,
Expand All @@ -421,6 +425,8 @@ public async Task ListInstancesCommandJson(TentacleConfigurationTestCase tc)
public async Task ShouldLogStartupDiagnosticsToInstanceLogFileOnly(TentacleConfigurationTestCase tc)
{
await using var clientAndTentacle = await tc.CreateBuilder().Build(CancellationToken);
await clientAndTentacle.RunningTentacle.Stop(CancellationToken);

var startingLogText = clientAndTentacle.RunningTentacle.ReadAllLogFileText();

var (exitCode, stdout, stderr) = await RunCommandAndAssertExitsWithSuccessExitCode(
Expand All @@ -445,7 +451,6 @@ public async Task ShouldLogStartupDiagnosticsToInstanceLogFileOnly(TentacleConfi
{
throw new NotLoggedYetException();
}

return newLog;
});

Expand Down Expand Up @@ -514,6 +519,7 @@ to text.
public async Task ShowConfigurationCommand(TentacleConfigurationTestCase tc)
{
await using var clientAndTentacle = await tc.CreateBuilder().Build(CancellationToken);
await clientAndTentacle.RunningTentacle.Stop(CancellationToken);
var (_, stdout, stderr) = await RunCommandAndAssertExitsWithSuccessExitCode(
tc,
clientAndTentacle.RunningTentacle.RunTentacleEnvironmentVariables,
Expand Down Expand Up @@ -564,6 +570,7 @@ await RunCommandAndAssertExitsWithSuccessExitCode(
public async Task ShowConfigurationCommandLooksSensibleToHumans(TentacleConfigurationTestCase tc)
{
await using var clientAndTentacle = await tc.CreateBuilder().Build(CancellationToken);
await clientAndTentacle.RunningTentacle.Stop(CancellationToken);
var (_, stdout, stderr) = await RunCommandAndAssertExitsWithSuccessExitCode(
tc,
clientAndTentacle.RunningTentacle.RunTentacleEnvironmentVariables,
Expand Down Expand Up @@ -661,6 +668,7 @@ public async Task ShowConfigurationCommandLooksSensibleToHumans(TentacleConfigur
public async Task WatchdogCreateAndDeleteCommand(TentacleConfigurationTestCase tc)
{
await using var clientAndTentacle = await tc.CreateBuilder().Build(CancellationToken);
await clientAndTentacle.RunningTentacle.Stop(CancellationToken);
var create = await RunCommandAndAssertExitsWithSuccessExitCode(
tc,
clientAndTentacle.RunningTentacle.RunTentacleEnvironmentVariables,
Expand Down

0 comments on commit cd04022

Please sign in to comment.