From f40933f1ea26039c46fd7a94a5f0561cb5cd2db9 Mon Sep 17 00:00:00 2001 From: Malhar Khimsaria Date: Thu, 24 Feb 2022 16:32:08 -0500 Subject: [PATCH] fix: Fix redeployment failure while using ConsoleAppEcsFargateService recipe --- .../Configurations/AutoScalingConfiguration.cs | 18 ++++++++++-------- .../ConsoleAppTests.cs | 9 +++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/AWS.Deploy.Recipes/CdkTemplates/ConsoleAppECSFargateService/Generated/Configurations/AutoScalingConfiguration.cs b/src/AWS.Deploy.Recipes/CdkTemplates/ConsoleAppECSFargateService/Generated/Configurations/AutoScalingConfiguration.cs index aaa6ab9eb..9979cfd14 100644 --- a/src/AWS.Deploy.Recipes/CdkTemplates/ConsoleAppECSFargateService/Generated/Configurations/AutoScalingConfiguration.cs +++ b/src/AWS.Deploy.Recipes/CdkTemplates/ConsoleAppECSFargateService/Generated/Configurations/AutoScalingConfiguration.cs @@ -15,11 +15,13 @@ namespace ConsoleAppEcsFargateService.Configurations { public partial class AutoScalingConfiguration { + const int defaultCooldown = 300; + public bool Enabled { get; set; } - public int MinCapacity { get; set; } + public int MinCapacity { get; set; } = 1; - public int MaxCapacity { get; set; } + public int MaxCapacity { get; set; } = 3; public enum ScalingTypeEnum { Cpu, Memory } @@ -27,19 +29,19 @@ public enum ScalingTypeEnum { Cpu, Memory } - public double CpuTypeTargetUtilizationPercent { get; set; } + public double CpuTypeTargetUtilizationPercent { get; set; } = 70; - public int CpuTypeScaleInCooldownSeconds { get; set; } + public int CpuTypeScaleInCooldownSeconds { get; set; } = defaultCooldown; - public int CpuTypeScaleOutCooldownSeconds { get; set; } + public int CpuTypeScaleOutCooldownSeconds { get; set; } = defaultCooldown; - public int MemoryTypeTargetUtilizationPercent { get; set; } + public int MemoryTypeTargetUtilizationPercent { get; set; } = 70; - public int MemoryTypeScaleInCooldownSeconds { get; set; } + public int MemoryTypeScaleInCooldownSeconds { get; set; } = defaultCooldown; - public int MemoryTypeScaleOutCooldownSeconds { get; set; } + public int MemoryTypeScaleOutCooldownSeconds { get; set; } = defaultCooldown; /// A parameterless constructor is needed for /// or the classes will fail to initialize. diff --git a/test/AWS.Deploy.CLI.IntegrationTests/ConsoleAppTests.cs b/test/AWS.Deploy.CLI.IntegrationTests/ConsoleAppTests.cs index a7c8192dd..890860915 100644 --- a/test/AWS.Deploy.CLI.IntegrationTests/ConsoleAppTests.cs +++ b/test/AWS.Deploy.CLI.IntegrationTests/ConsoleAppTests.cs @@ -97,6 +97,15 @@ public async Task DefaultConfigurations(params string[] components) var listStdOut = _interactiveService.StdOutReader.ReadAllLines().Select(x => x.Split()[0]).ToList(); Assert.Contains(listStdOut, (deployment) => _stackName.Equals(deployment)); + // Arrange input for re-deployment + await _interactiveService.StdInWriter.WriteAsync(Environment.NewLine); // Select default option settings + await _interactiveService.StdInWriter.FlushAsync(); + + // Perform re-deployment + deployArgs = new[] { "deploy", "--project-path", _testAppManager.GetProjectPath(Path.Combine(components)), "--application-name", _stackName, "--diagnostics" }; + Assert.Equal(CommandReturnCodes.SUCCESS, await _app.Run(deployArgs)); + Assert.Equal(StackStatus.UPDATE_COMPLETE, await _cloudFormationHelper.GetStackStatus(_stackName)); + // Arrange input for delete await _interactiveService.StdInWriter.WriteAsync("y"); // Confirm delete await _interactiveService.StdInWriter.FlushAsync();