From ffe6d8620dc866675152b38aac66ab9052308dd1 Mon Sep 17 00:00:00 2001 From: jordanbreen28 Date: Thu, 9 Nov 2023 09:10:34 +0000 Subject: [PATCH] (CAT-1545) - Add machine type to matrix This commit adds a machine_type field to each object in the matrix platforms. This means that for arm-based architectures, we can return the t2a-standard-2 machine which supports arm. If not arm based, then resort back to default. --- README.md | 2 +- exe/matrix_from_metadata_v2 | 4 +++- spec/exe/matrix_from_metadata_v2_spec.rb | 10 +++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index bd6d9f68..135e768b 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ In order to use this new functionality, run: `$: bundle exec matrix_from_metadata_v2 --custom-matrix matrix.json` -> Note: The file should contain a valid Array of JSON Objects (i.e. `[{"label":"AlmaLinux-8","provider":"provision_service","image":"almalinux-cloud/almalinux-8"}, {..}]`), otherwise it will throw an error. +> Note: The file should contain a valid Array of JSON Objects (i.e. `[{"label":"AlmaLinux-8","provider":"provision_service","image":"almalinux-cloud/almalinux-8", "machine_type":"n1-standard-2"}, {..}]`), otherwise it will throw an error. ## Documentation diff --git a/exe/matrix_from_metadata_v2 b/exe/matrix_from_metadata_v2 index 44d8b552..a4bb1a90 100755 --- a/exe/matrix_from_metadata_v2 +++ b/exe/matrix_from_metadata_v2 @@ -157,7 +157,9 @@ else matrix[:platforms] << { label: image_key, provider: 'provision_service', - image: IMAGE_TABLE[image_key] + image: IMAGE_TABLE[image_key], + # if the image is to be an ARM based instance, use t2a-standard-2 machine type + machine_type: image_key.include?('arm') ? 't2a-standard-2' : 'n1-standard-2' } elsif DOCKER_PLATFORMS.key?(image_key) && !exclude_list.include?(image_key.downcase) matrix[:platforms] << { diff --git a/spec/exe/matrix_from_metadata_v2_spec.rb b/spec/exe/matrix_from_metadata_v2_spec.rb index 849355d5..0c24956f 100644 --- a/spec/exe/matrix_from_metadata_v2_spec.rb +++ b/spec/exe/matrix_from_metadata_v2_spec.rb @@ -23,8 +23,8 @@ 'matrix={', '"platforms":[', '{"label":"CentOS-6","provider":"docker","image":"litmusimage/centos:6"},', - '{"label":"RedHat-8","provider":"provision_service","image":"rhel-8"},', - '{"label":"RedHat-9-arm","provider":"provision_service","image":"rhel-9-arm64"},', + '{"label":"RedHat-8","provider":"provision_service","image":"rhel-8","machine_type":"n1-standard-2"},', + '{"label":"RedHat-9-arm","provider":"provision_service","image":"rhel-9-arm64","machine_type":"t2a-standard-2"},', '{"label":"Ubuntu-18.04","provider":"docker","image":"litmusimage/ubuntu:18.04"}', '],', '"collection":[', @@ -61,8 +61,8 @@ 'matrix={', '"platforms":[', '{"label":"CentOS-6","provider":"docker","image":"litmusimage/centos:6"},', - '{"label":"RedHat-8","provider":"provision_service","image":"rhel-8"},', - '{"label":"RedHat-9-arm","provider":"provision_service","image":"rhel-9-arm64"}', + '{"label":"RedHat-8","provider":"provision_service","image":"rhel-8","machine_type":"n1-standard-2"},', + '{"label":"RedHat-9-arm","provider":"provision_service","image":"rhel-9-arm64","machine_type":"t2a-standard-2"}', '],', '"collection":[', '"puppet7-nightly","puppet8-nightly"', @@ -99,7 +99,7 @@ 'matrix={', '"platforms":[', '{"label":"CentOS-6","provider":"docker","image":"litmusimage/centos:6"},', - '{"label":"RedHat-9-arm","provider":"provision_service","image":"rhel-9-arm64"}', + '{"label":"RedHat-9-arm","provider":"provision_service","image":"rhel-9-arm64","machine_type":"t2a-standard-2"}', '],', '"collection":[', '"puppet7-nightly","puppet8-nightly"',