Skip to content

Commit

Permalink
test: reduce supported-os smoke test resource usage (#13283)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kruskall authored Jun 3, 2024
1 parent 1a59e59 commit c67adb9
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }"
Original file line number Diff line number Diff line change
Expand Up @@ -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 }"
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 }"
99 changes: 68 additions & 31 deletions testing/infra/terraform/modules/standalone_apm_server/main.tf
Original file line number Diff line number Diff line change
@@ -1,43 +1,72 @@
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"
"RHEL-9" = "ec2-user"
}
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" {
Expand All @@ -50,7 +79,7 @@ data "aws_ami" "os" {

filter {
name = "architecture"
values = ["x86_64"]
values = [local.instance_arch[var.aws_os]]
}

filter {
Expand Down Expand Up @@ -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 {
Expand All @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions testing/smoke/managed/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions testing/smoke/os_matrix.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 3 additions & 3 deletions testing/smoke/supported-os/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c67adb9

Please sign in to comment.