Skip to content

Commit

Permalink
Merge pull request #15858 from MinaProtocol/terraform-tests
Browse files Browse the repository at this point in the history
Fix Terraform tests by synthetically creating required seed peerid files
  • Loading branch information
dkijania authored Jul 23, 2024
2 parents 3ba6743 + 7413f66 commit 5291f42
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
19 changes: 16 additions & 3 deletions automation/terraform/modules/o1-testnet/files.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,23 @@
# ]
# }

# Generate random strings for peer IDs
resource "random_id" "peer_id" {
for_each = var.create_libp2p_files ? toset(local.seed_names) : []
byte_length = 32
}

# Create the files with the generated peer IDs
resource "local_file" "libp2p_seed_peers" {
for_each = var.create_libp2p_files ? toset(local.seed_names) : []
filename = "${var.artifact_path}/keys/libp2p-keys/${each.key}.peerid"
content = random_id.peer_id[each.key].hex
}

data "local_file" "libp2p_seed_peers" {
for_each = toset(local.seed_names)
filename = "${var.artifact_path}/keys/libp2p-keys/${each.key}.peerid"
# depends_on = [
# null_resource.block_producer_key_generation
# ]
depends_on = [
local_file.libp2p_seed_peers
]
}
7 changes: 7 additions & 0 deletions automation/terraform/modules/o1-testnet/inputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ variable "artifact_path" {
default = "/tmp"
}

# Variable to control file creation
variable "create_libp2p_files" {
description = "Whether to create LibP2P peer ID files"
type = bool
default = false
}

variable "mina_image" {
type = string
default = "gcr.io/o1labs-192920/mina-daemon:1.2.0beta8-5b35b27-devnet"
Expand Down
8 changes: 8 additions & 0 deletions automation/terraform/testnets/ci-net/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ variable "ci_artifact_path" {
default = "/tmp"
}

variable "create_libp2p_files" {
type = bool
description = "Whether to create LibP2P peer ID files"
default = false
}

locals {
seed_region = "us-west1"
seed_zone = "us-west1-b"
Expand All @@ -73,6 +79,8 @@ module "ci_testnet" {

artifact_path = var.ci_artifact_path

create_libp2p_files = var.create_libp2p_files

# TODO: remove obsolete cluster_name var + cluster region
cluster_name = "mina-integration-west1"
cluster_region = var.ci_cluster_region
Expand Down
2 changes: 1 addition & 1 deletion buildkite/scripts/terraform-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function test_single_terraform_config {
cd $1

terraform init
terraform plan
terraform plan -var="create_libp2p_files=true"

RET=$?

Expand Down

0 comments on commit 5291f42

Please sign in to comment.