Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F net 11478 testing #24597

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Thumbs.db
.idea
.fleet


# Folders
_obj
_test
Expand Down
177 changes: 0 additions & 177 deletions e2e/terraform/.terraform.lock.hcl

This file was deleted.

2 changes: 1 addition & 1 deletion e2e/terraform/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CONSUL_LICENSE_PATH ?=
custom.tfvars:
echo 'nomad_local_binary = "$(PKG_PATH)"' > custom.tfvars
echo 'volumes = false' >> custom.tfvars
echo 'client_count_ubuntu_jammy_amd64 = 3' >> custom.tfvars
echo 'client_count_linux = 3' >> custom.tfvars
echo 'client_count_windows_2016_amd64 = 0' >> custom.tfvars
echo 'consul_license = "$(shell cat $(CONSUL_LICENSE_PATH))"' >> custom.tfvars
echo 'nomad_license = "$(shell cat $(NOMAD_LICENSE_PATH))"' >> custom.tfvars
Expand Down
2 changes: 1 addition & 1 deletion e2e/terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Linux clients or Windows clients.
region = "us-east-1"
instance_type = "t2.medium"
server_count = "3"
client_count_ubuntu_jammy_amd64 = "4"
client_count_linux = "4"
client_count_windows_2016_amd64 = "1"
```

Expand Down
36 changes: 7 additions & 29 deletions e2e/terraform/main.tf
Original file line number Diff line number Diff line change
@@ -1,34 +1,12 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

provider "aws" {
region = var.region
}

data "aws_caller_identity" "current" {
}

resource "random_pet" "e2e" {
}

resource "random_password" "windows_admin_password" {
length = 20
special = true
override_special = "_%@"
}
module "provision-infra" {
source = "./provision-infra"

locals {
random_name = "${var.name}-${random_pet.e2e.id}"
}

# Generates keys to use for provisioning and access
module "keys" {
name = local.random_name
path = "${path.root}/keys"
source = "mitchellh/dynamic-keys/aws"
version = "v2.0.0"
}

data "aws_kms_alias" "e2e" {
name = "alias/${var.aws_kms_alias}"
}
server_count = var.client_count_linux
client_count_linux = var.client_count_linux
client_count_windows_2016_amd64 = var.client_count_windows_2016_amd64
nomad_local_binary = var.nomad_local_binary
}
44 changes: 5 additions & 39 deletions e2e/terraform/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,19 @@
# SPDX-License-Identifier: BUSL-1.1

output "servers" {
value = aws_instance.server.*.public_ip
value = module.provision-infra.servers
}

output "linux_clients" {
value = aws_instance.client_ubuntu_jammy_amd64.*.public_ip
value = module.provision-infra.linux_clients
}

output "windows_clients" {
value = aws_instance.client_windows_2016_amd64.*.public_ip
value = module.provision-infra.windows_clients
}

output "message" {
value = <<EOM
Your cluster has been provisioned! To prepare your environment, run:

$(terraform output --raw environment)

Then you can run tests from the e2e directory with:

go test -v .

ssh into servers with:

%{for ip in aws_instance.server.*.public_ip~}
ssh -i keys/${local.random_name}.pem ubuntu@${ip}
%{endfor~}

ssh into clients with:

%{for ip in aws_instance.client_ubuntu_jammy_amd64.*.public_ip~}
ssh -i keys/${local.random_name}.pem ubuntu@${ip}
%{endfor~}
%{for ip in aws_instance.client_windows_2016_amd64.*.public_ip~}
ssh -i keys/${local.random_name}.pem Administrator@${ip}
%{endfor~}

EOM
value = module.provision-infra.message
}

# Note: Consul and Vault environment needs to be set in test
Expand All @@ -47,15 +23,5 @@ EOM
output "environment" {
description = "get connection config by running: $(terraform output environment)"
sensitive = true
value = <<EOM
export NOMAD_ADDR=https://${aws_instance.server[0].public_ip}:4646
export NOMAD_CACERT=${abspath(path.module)}/keys/tls_ca.crt
export NOMAD_CLIENT_CERT=${abspath(path.module)}/keys/tls_api_client.crt
export NOMAD_CLIENT_KEY=${abspath(path.module)}/keys/tls_api_client.key
export NOMAD_TOKEN=${data.local_sensitive_file.nomad_token.content}
export NOMAD_E2E=1
export CONSUL_HTTP_ADDR=https://${aws_instance.consul_server.public_ip}:8501
export CONSUL_HTTP_TOKEN=${local_sensitive_file.consul_initial_management_token.content}
export CONSUL_CACERT=${abspath(path.module)}/keys/tls_ca.crt
EOM
value = module.provision-infra.environment
}
59 changes: 59 additions & 0 deletions e2e/terraform/packer/ubuntu-jammy-arm64.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

variable "build_sha" {
type = string
description = "the revision of the packer scripts building this image"
}

locals {
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
distro = "ubuntu-jammy-22.04-arm64-server-*"
version = "v3"
}

source "amazon-ebs" "latest_ubuntu_jammy" {
ami_name = "nomad-e2e-${local.version}-ubuntu-jammy-arm64-${local.timestamp}"
iam_instance_profile = "packer_build" // defined in nomad-e2e repo
instance_type = "m7a.large"
region = "us-east-1"
ssh_username = "ubuntu"
ssh_interface = "public_ip"

source_ami_filter {
filters = {
architecture = "arm64"
"block-device-mapping.volume-type" = "gp2"
name = "ubuntu/images/hvm-ssd/${local.distro}"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["099720109477"] // Canonical
}

tags = {
OS = "Ubuntu"
Version = "Jammy"
BuilderSha = var.build_sha
}
}

build {
sources = ["source.amazon-ebs.latest_ubuntu_jammy"]

provisioner "file" {
destination = "/tmp/linux"
source = "./ubuntu-jammy-arm64"
}

// cloud-init modifies the apt sources, so we need to wait
// before running our setup
provisioner "shell-local" {
inline = ["sleep 30"]
}

provisioner "shell" {
script = "./ubuntu-jammy-arm64/setup.sh"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"cniVersion": "1.0.0",
"name": "cni_args",
"plugins": [
{
"type": "cni_args.sh"
}
]
}
Loading
Loading