From c67adb9fb708d94687aa4e04eefa9ea8995f57d9 Mon Sep 17 00:00:00 2001 From: kruskall <99559985+kruskall@users.noreply.github.com> Date: Mon, 3 Jun 2024 09:36:24 +0200 Subject: [PATCH] test: reduce supported-os smoke test resource usage (#13283) Update elasticsearch size 4g -> 1g Update deployment template gcp-compute-optimized-v3 -> gcp-vector-search-optimized. Use arm instances everywhere Avoid always downloading apm-server and elastic-agent, only download the necessary binary to reduce setup time. Update instance type t3.micro -> t4g.nano where possible and use t4g.micro for RHEL systems. --- .../latest_apm_server.sh | 2 +- .../latest_elastic_agent.sh | 2 +- .../modules/standalone_apm_server/main.tf | 99 +++++++++++++------ testing/smoke/managed/main.tf | 6 +- testing/smoke/os_matrix.sh | 10 +- testing/smoke/supported-os/main.tf | 6 +- 6 files changed, 81 insertions(+), 44 deletions(-) diff --git a/testing/infra/terraform/modules/standalone_apm_server/latest_apm_server.sh b/testing/infra/terraform/modules/standalone_apm_server/latest_apm_server.sh index 1b9a03a7977..3946546080e 100755 --- a/testing/infra/terraform/modules/standalone_apm_server/latest_apm_server.sh +++ b/testing/infra/terraform/modules/standalone_apm_server/latest_apm_server.sh @@ -8,4 +8,4 @@ if [[ -z ${VERSION} ]] || [[ "${VERSION}" == "latest" ]]; then fi LATEST_BUILD=$(curl -s "https://artifacts-api.elastic.co/v1/versions/${VERSION}/builds/" | jq -r '.builds[0]') -curl -s "https://artifacts-api.elastic.co/v1/versions/${VERSION}/builds/${LATEST_BUILD}/projects/apm-server" | jq -r ".project.packages | {deb: .\"apm-server-${VERSION}-amd64.deb\".url, rpm: .\"apm-server-${VERSION}-x86_64.rpm\".url }" +curl -s "https://artifacts-api.elastic.co/v1/versions/${VERSION}/builds/${LATEST_BUILD}/projects/apm-server" | jq -r ".project.packages | {deb_amd: .\"apm-server-${VERSION}-amd64.deb\".url, deb_arm: .\"apm-server-${VERSION}-arm64.deb\".url, rpm_amd: .\"apm-server-${VERSION}-x86_64.rpm\".url, rpm_arm: .\"apm-server-${VERSION}-aarch64.rpm\".url }" diff --git a/testing/infra/terraform/modules/standalone_apm_server/latest_elastic_agent.sh b/testing/infra/terraform/modules/standalone_apm_server/latest_elastic_agent.sh index db11de133cd..02df3188d5a 100755 --- a/testing/infra/terraform/modules/standalone_apm_server/latest_elastic_agent.sh +++ b/testing/infra/terraform/modules/standalone_apm_server/latest_elastic_agent.sh @@ -8,4 +8,4 @@ if [[ -z ${VERSION} ]] || [[ "${VERSION}" == "latest" ]]; then fi LATEST_BUILD=$(curl -s "https://artifacts-api.elastic.co/v1/versions/${VERSION}/builds/" | jq -r '.builds[0]') -curl -s "https://artifacts-api.elastic.co/v1/versions/${VERSION}/builds/${LATEST_BUILD}/projects/elastic-agent-package" | jq -r ".project.packages | {deb: .\"elastic-agent-${VERSION}-amd64.deb\".url, rpm: .\"elastic-agent-${VERSION}-x86_64.rpm\".url }" \ No newline at end of file +curl -s "https://artifacts-api.elastic.co/v1/versions/${VERSION}/builds/${LATEST_BUILD}/projects/elastic-agent-package" | jq -r ".project.packages | {deb_amd: .\"elastic-agent-${VERSION}-amd64.deb\".url, deb_arm: .\"elastic-agent-${VERSION}-arm64.deb\".url, rpm_amd: .\"elastic-agent-${VERSION}-x86_64.rpm\".url, rpm_arm: .\"elastic-agent-${VERSION}-aarch64.rpm\".url }" diff --git a/testing/infra/terraform/modules/standalone_apm_server/main.tf b/testing/infra/terraform/modules/standalone_apm_server/main.tf index 194c6ea5071..ae57972fb9f 100644 --- a/testing/infra/terraform/modules/standalone_apm_server/main.tf +++ b/testing/infra/terraform/modules/standalone_apm_server/main.tf @@ -1,21 +1,65 @@ locals { image_owners = { - "ubuntu-bionic-18.04-amd64-server" = "099720109477" # canonical - "ubuntu-focal-20.04-amd64-server" = "099720109477" # canonical - "ubuntu-jammy-22.04-amd64-server" = "099720109477" # canonical - "debian-10-amd64" = "136693071363" # debian - "debian-11-amd64" = "136693071363" # debian + "ubuntu-bionic-18.04-arm64-server" = "099720109477" # canonical + "ubuntu-focal-20.04-arm64-server" = "099720109477" # canonical + "ubuntu-jammy-22.04-arm64-server" = "099720109477" # canonical + "debian-10-arm64" = "136693071363" # debian + "debian-11-arm64" = "136693071363" # debian "amzn2-ami-kernel-5.10" = "137112412989" # amazon "RHEL-7" = "309956199498" # Red Hat "RHEL-8" = "309956199498" # Red Hat "RHEL-9" = "309956199498" # Red Hat } + instance_types = { + "ubuntu-bionic-18.04-arm64-server" = "t4g.nano" + "ubuntu-focal-20.04-arm64-server" = "t4g.nano" + "ubuntu-jammy-22.04-arm64-server" = "t4g.nano" + "debian-10-arm64" = "t4g.nano" + "debian-11-arm64" = "t4g.nano" + "amzn2-ami-kernel-5.10" = "t4g.nano" + "RHEL-7" = "t3a.micro" # RHEL-7 doesn't support arm + "RHEL-8" = "t4g.micro" # RHEL doesn't support nano instances + "RHEL-9" = "t4g.micro" # RHEL doesn't support nano instances + } + instance_arch = { + "ubuntu-bionic-18.04-arm64-server" = "arm64" + "ubuntu-focal-20.04-arm64-server" = "arm64" + "ubuntu-jammy-22.04-arm64-server" = "arm64" + "debian-10-arm64" = "arm64" + "debian-11-arm64" = "arm64" + "amzn2-ami-kernel-5.10" = "arm64" + "RHEL-7" = "x86_64" # RHEL-7 doesn't support arm + "RHEL-8" = "arm64" + "RHEL-9" = "arm64" + } + instance_ea_provision_cmd = { + "ubuntu-bionic-18.04-arm64-server" = "curl ${data.external.latest_elastic_agent.result.deb_arm} -o elastic-agent.deb && sudo dpkg -i elastic-agent.deb" + "ubuntu-focal-20.04-arm64-server" = "curl ${data.external.latest_elastic_agent.result.deb_arm} -o elastic-agent.deb && sudo dpkg -i elastic-agent.deb" + "ubuntu-jammy-22.04-arm64-server" = "curl ${data.external.latest_elastic_agent.result.deb_arm} -o elastic-agent.deb && sudo dpkg -i elastic-agent.deb" + "debian-10-arm64" = "curl ${data.external.latest_elastic_agent.result.deb_arm} -o elastic-agent.deb && sudo dpkg -i elastic-agent.deb" + "debian-11-arm64" = "curl ${data.external.latest_elastic_agent.result.deb_arm} -o elastic-agent.deb && sudo dpkg -i elastic-agent.deb" + "amzn2-ami-kernel-5.10" = "curl ${data.external.latest_elastic_agent.result.rpm_arm} -o elastic-agent.rpm && sudo yum -y install elastic-agent.rpm" + "RHEL-7" = "curl ${data.external.latest_elastic_agent.result.rpm_amd} -o elastic-agent.rpm && sudo yum -y install elastic-agent.rpm" + "RHEL-8" = "curl ${data.external.latest_elastic_agent.result.rpm_arm} -o elastic-agent.rpm && sudo yum -y install elastic-agent.rpm" + "RHEL-9" = "curl ${data.external.latest_elastic_agent.result.rpm_arm} -o elastic-agent.rpm && sudo yum -y install elastic-agent.rpm" + } + instance_standalone_provision_cmd = { + "ubuntu-bionic-18.04-arm64-server" = "curl ${data.external.latest_apm_server.result.deb_arm} -o apm-server.deb && sudo dpkg -i apm-server.deb" + "ubuntu-focal-20.04-arm64-server" = "curl ${data.external.latest_apm_server.result.deb_arm} -o apm-server.deb && sudo dpkg -i apm-server.deb" + "ubuntu-jammy-22.04-arm64-server" = "curl ${data.external.latest_apm_server.result.deb_arm} -o apm-server.deb && sudo dpkg -i apm-server.deb" + "debian-10-arm64" = "curl ${data.external.latest_apm_server.result.deb_arm} -o apm-server.deb && sudo dpkg -i apm-server.deb" + "debian-11-arm64" = "curl ${data.external.latest_apm_server.result.deb_arm} -o apm-server.deb && sudo dpkg -i apm-server.deb" + "amzn2-ami-kernel-5.10" = "curl ${data.external.latest_apm_server.result.rpm_arm} -o apm-server.rpm && sudo yum -y install apm-server.rpm" + "RHEL-7" = "curl ${data.external.latest_apm_server.result.rpm_amd} -o apm-server.rpm && sudo yum -y install apm-server.rpm" + "RHEL-8" = "curl ${data.external.latest_apm_server.result.rpm_arm} -o apm-server.rpm && sudo yum -y install apm-server.rpm" + "RHEL-9" = "curl ${data.external.latest_apm_server.result.rpm_arm} -o apm-server.rpm && sudo yum -y install apm-server.rpm" + } image_ssh_users = { - "ubuntu-bionic-18.04-amd64-server" = "ubuntu" - "ubuntu-focal-20.04-amd64-server" = "ubuntu" - "ubuntu-jammy-22.04-amd64-server" = "ubuntu" - "debian-10-amd64" = "admin" - "debian-11-amd64" = "admin" + "ubuntu-bionic-18.04-arm64-server" = "ubuntu" + "ubuntu-focal-20.04-arm64-server" = "ubuntu" + "ubuntu-jammy-22.04-arm64-server" = "ubuntu" + "debian-10-arm64" = "admin" + "debian-11-arm64" = "admin" "amzn2-ami-kernel-5.10" = "ec2-user" "RHEL-7" = "ec2-user" "RHEL-8" = "ec2-user" @@ -23,21 +67,6 @@ locals { } apm_port = "8200" conf_path = "/tmp/local-apm-config.yml" - ea_provision_commands = [ - "curl ${data.external.latest_elastic_agent.result.deb} -o elastic-agent.deb && curl ${data.external.latest_elastic_agent.result.rpm} -o elastic-agent.rpm", - "sudo dpkg -i elastic-agent.deb || sudo yum -y install elastic-agent.rpm", - "sudo elastic-agent install -n --unprivileged", - "sudo cp ${local.conf_path} /etc/elastic-agent/elastic-agent.yml", - "sudo systemctl start elastic-agent", - "sleep 1", - ] - standalone_provision_commands = [ - "curl ${data.external.latest_apm_server.result.deb} -o apm-server.deb && curl ${data.external.latest_apm_server.result.rpm} -o apm-server.rpm", - "sudo dpkg -i apm-server.deb || sudo yum -y install apm-server.rpm", - "sudo cp ${local.conf_path} /etc/apm-server/apm-server.yml", - "sudo systemctl start apm-server", - "sleep 1", - ] } data "aws_ami" "os" { @@ -50,7 +79,7 @@ data "aws_ami" "os" { filter { name = "architecture" - values = ["x86_64"] + values = [local.instance_arch[var.aws_os]] } filter { @@ -108,7 +137,7 @@ resource "aws_security_group" "main" { resource "aws_instance" "apm" { ami = data.aws_ami.os.id - instance_type = "t3.micro" + instance_type = local.instance_types[var.aws_os] key_name = aws_key_pair.provisioner_key.key_name connection { @@ -131,10 +160,18 @@ resource "aws_instance" "apm" { } provisioner "remote-exec" { - inline = concat( - [for command in local.ea_provision_commands : command if var.ea_managed], - [for command in local.standalone_provision_commands : command if !var.ea_managed], - ) + inline = var.ea_managed ? [ + local.instance_ea_provision_cmd[var.aws_os], + "sudo elastic-agent install -n --unprivileged", + "sudo cp ${local.conf_path} /etc/elastic-agent/elastic-agent.yml", + "sudo systemctl start elastic-agent", + "sleep 1", + ] : [ + local.instance_standalone_provision_cmd[var.aws_os], + "sudo cp ${local.conf_path} /etc/apm-server/apm-server.yml", + "sudo systemctl start apm-server", + "sleep 1", + ] } vpc_security_group_ids = [aws_security_group.main.id] diff --git a/testing/smoke/managed/main.tf b/testing/smoke/managed/main.tf index 4d79c93bc81..3fead67e50e 100644 --- a/testing/smoke/managed/main.tf +++ b/testing/smoke/managed/main.tf @@ -29,12 +29,12 @@ module "ec_deployment" { source = "../../infra/terraform/modules/ec_deployment" region = var.region - deployment_template = "gcp-compute-optimized-v3" - deployment_name_prefix = "smoke-upgrade" + deployment_template = "gcp-vector-search-optimized" + deployment_name_prefix = "supported-os-managed" apm_server_size = "1g" - elasticsearch_size = "4g" + elasticsearch_size = "1g" elasticsearch_zone_count = 1 stack_version = var.stack_version diff --git a/testing/smoke/os_matrix.sh b/testing/smoke/os_matrix.sh index 5ac6d624651..1ac49de3e85 100644 --- a/testing/smoke/os_matrix.sh +++ b/testing/smoke/os_matrix.sh @@ -1,11 +1,11 @@ #!/usr/bin/env bash os_names=( - "ubuntu-bionic-18.04-amd64-server" - "ubuntu-focal-20.04-amd64-server" - "ubuntu-jammy-22.04-amd64-server" - "debian-10-amd64" - "debian-11-amd64" + "ubuntu-bionic-18.04-arm64-server" + "ubuntu-focal-20.04-arm64-server" + "ubuntu-jammy-22.04-arm64-server" + "debian-10-arm64" + "debian-11-arm64" "amzn2-ami-kernel-5.10" "RHEL-7" "RHEL-8" diff --git a/testing/smoke/supported-os/main.tf b/testing/smoke/supported-os/main.tf index 2367b1d3c4e..9674b1829ba 100644 --- a/testing/smoke/supported-os/main.tf +++ b/testing/smoke/supported-os/main.tf @@ -29,12 +29,12 @@ module "ec_deployment" { source = "../../infra/terraform/modules/ec_deployment" region = var.region - deployment_template = "gcp-compute-optimized-v3" - deployment_name_prefix = "smoke-upgrade" + deployment_template = "gcp-vector-search-optimized" + deployment_name_prefix = "supported-os-standalone" apm_server_size = "1g" - elasticsearch_size = "4g" + elasticsearch_size = "1g" elasticsearch_zone_count = 1 stack_version = var.stack_version