Skip to content

Commit

Permalink
fix: Correctly validate platform architecture for Windows instance types
Browse files Browse the repository at this point in the history
  • Loading branch information
normj committed Jun 29, 2022
1 parent da564a0 commit 463e09d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ public async Task<ValidationResult> Validate(object input, Recommendation recomm
return ValidationResult.Failed($"The specified instance type {rawInstanceType} does not exist in the deployment region.");
}

if (string.Equals(_platform, EC2.FILTER_PLATFORM_WINDOWS) && !instanceTypeInfo.ProcessorInfo.SupportedArchitectures.Contains("x64_86"))
if (string.Equals(_platform, EC2.FILTER_PLATFORM_WINDOWS) && !instanceTypeInfo.ProcessorInfo.SupportedArchitectures.Contains(EC2.FILTER_ARCHITECTURE_X86_64))
{
return ValidationResult.Failed($"The specified instance type {rawInstanceType} does not support x86_64.");
return ValidationResult.Failed($"The specified instance type {rawInstanceType} does not support {EC2.FILTER_ARCHITECTURE_X86_64}.");
}

return ValidationResult.Valid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public async Task LinuxExecute()
var interactiveServices = new TestToolInteractiveServiceImpl(new List<string>
{
"y", // Free tier
"1", // Architecture x64_86
"1", // Architecture x86_64
"1", // CPU
"1", // Memory
"1" // Instance type
Expand Down Expand Up @@ -438,13 +438,13 @@ public async Task WindowsValidate()
.Setup(x => x.DescribeInstanceType(It.IsAny<string>()))
.ReturnsAsync((string type) =>
{
if (type == "t1.x64_86")
if (type == "t1.x86_64")
{
return new InstanceTypeInfo
{
ProcessorInfo = new ProcessorInfo
{
SupportedArchitectures = new List<string> { "x64_86" }
SupportedArchitectures = new List<string> { "x86_64" }
}
};
}
Expand All @@ -464,7 +464,7 @@ public async Task WindowsValidate()
{
ProcessorInfo = new ProcessorInfo
{
SupportedArchitectures = new List<string> { "x64_86", EC2.FILTER_ARCHITECTURE_ARM64 }
SupportedArchitectures = new List<string> { "x86_64", EC2.FILTER_ARCHITECTURE_ARM64 }
}
};
}
Expand All @@ -474,7 +474,7 @@ public async Task WindowsValidate()

var validator = new WindowsInstanceTypeValidator(_mockAWSResourceQueryer.Object);

Assert.True(validator.Validate("t1.x64_86", beanstalkRecommendation, instanceTypeSetting).Result.IsValid);
Assert.True(validator.Validate("t1.x86_64", beanstalkRecommendation, instanceTypeSetting).Result.IsValid);
Assert.False(validator.Validate("t1.arm64", beanstalkRecommendation, instanceTypeSetting).Result.IsValid);
Assert.True(validator.Validate("t1.both", beanstalkRecommendation, instanceTypeSetting).Result.IsValid);
Assert.False(validator.Validate("t1.fake", beanstalkRecommendation, instanceTypeSetting).Result.IsValid);
Expand Down Expand Up @@ -502,13 +502,13 @@ public async Task LinuxValidate()
.Setup(x => x.DescribeInstanceType(It.IsAny<string>()))
.ReturnsAsync((string type) =>
{
if (type == "t1.x64_86")
if (type == "t1.x86_64")
{
return new InstanceTypeInfo
{
ProcessorInfo = new ProcessorInfo
{
SupportedArchitectures = new List<string> { "x64_86" }
SupportedArchitectures = new List<string> { "x86_64" }
}
};
}
Expand All @@ -528,7 +528,7 @@ public async Task LinuxValidate()
{
ProcessorInfo = new ProcessorInfo
{
SupportedArchitectures = new List<string> { "x64_86", EC2.FILTER_ARCHITECTURE_ARM64 }
SupportedArchitectures = new List<string> { "x86_64", EC2.FILTER_ARCHITECTURE_ARM64 }
}
};
}
Expand All @@ -538,7 +538,7 @@ public async Task LinuxValidate()

var validator = new LinuxInstanceTypeValidator(_mockAWSResourceQueryer.Object);

Assert.True(validator.Validate("t1.x64_86", beanstalkRecommendation, instanceTypeSetting).Result.IsValid);
Assert.True(validator.Validate("t1.x86_64", beanstalkRecommendation, instanceTypeSetting).Result.IsValid);
Assert.True(validator.Validate("t1.arm64", beanstalkRecommendation, instanceTypeSetting).Result.IsValid);
Assert.True(validator.Validate("t1.both", beanstalkRecommendation, instanceTypeSetting).Result.IsValid);
Assert.False(validator.Validate("t1.fake", beanstalkRecommendation, instanceTypeSetting).Result.IsValid);
Expand Down

0 comments on commit 463e09d

Please sign in to comment.