test/image: use t4g.micro instance type for aarch64

The instance type is arch-dependant, therefore it's needed to pick the right
one for a given arch.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2020-11-30 11:25:22 +01:00 committed by msehnout
parent 67d6b58e24
commit 7256a92d15
2 changed files with 14 additions and 3 deletions

View file

@ -271,9 +271,20 @@ func testBootUsingAWS(t *testing.T, imagePath string) {
securityGroupName, err := GenerateCIArtifactName("osbuild-image-tests-security-group-")
require.NoError(t, err)
instanceTypeForArch := map[string]string{
"x86_64": "t3.micro",
"aarch64": "t4g.micro",
}
instanceType, exists := instanceTypeForArch[common.CurrentArch()]
if !exists {
panic("unsupported AWS arch")
}
// boot the uploaded image and try to connect to it
err = boot.WithSSHKeyPair(func(privateKey, publicKey string) error {
return boot.WithBootedImageInEC2(e, securityGroupName, imageDesc, publicKey, func(address string) error {
return boot.WithBootedImageInEC2(e, securityGroupName, imageDesc, publicKey, instanceType, func(address string) error {
testSSH(t, address, privateKey, nil)
return nil
})

View file

@ -179,7 +179,7 @@ func DeleteEC2Image(e *ec2.EC2, imageDesc *imageDescription) error {
// WithBootedImageInEC2 runs the function f in the context of booted
// image in AWS EC2
func WithBootedImageInEC2(e *ec2.EC2, securityGroupName string, imageDesc *imageDescription, publicKey string, f func(address string) error) (retErr error) {
func WithBootedImageInEC2(e *ec2.EC2, securityGroupName string, imageDesc *imageDescription, publicKey string, instanceType string, f func(address string) error) (retErr error) {
// generate user data with given public key
userData, err := CreateUserData(publicKey)
if err != nil {
@ -224,7 +224,7 @@ func WithBootedImageInEC2(e *ec2.EC2, securityGroupName string, imageDesc *image
MaxCount: aws.Int64(1),
MinCount: aws.Int64(1),
ImageId: imageDesc.Id,
InstanceType: aws.String("t3.micro"),
InstanceType: aws.String(instanceType),
SecurityGroupIds: []*string{securityGroup.GroupId},
UserData: aws.String(encodeBase64(userData)),
})