From c1fc6eca949b48cda01803123c9f1df0ca42c98d Mon Sep 17 00:00:00 2001 From: SanabriaRusso Date: Tue, 23 Jul 2024 17:46:03 +0200 Subject: [PATCH 1/2] Fix Terraform tests by synthetically creating required seed peerid files --- .../terraform/modules/o1-testnet/files.tf | 19 ++++++++++++++++--- .../terraform/modules/o1-testnet/inputs.tf | 7 +++++++ automation/terraform/testnets/ci-net/main.tf | 8 ++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/automation/terraform/modules/o1-testnet/files.tf b/automation/terraform/modules/o1-testnet/files.tf index 7eb37815c96..8f39b9982e3 100644 --- a/automation/terraform/modules/o1-testnet/files.tf +++ b/automation/terraform/modules/o1-testnet/files.tf @@ -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 + ] } diff --git a/automation/terraform/modules/o1-testnet/inputs.tf b/automation/terraform/modules/o1-testnet/inputs.tf index 809040cd6d2..e250639d4a4 100644 --- a/automation/terraform/modules/o1-testnet/inputs.tf +++ b/automation/terraform/modules/o1-testnet/inputs.tf @@ -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" diff --git a/automation/terraform/testnets/ci-net/main.tf b/automation/terraform/testnets/ci-net/main.tf index 84bb70c2eb7..d6ba50d1b61 100644 --- a/automation/terraform/testnets/ci-net/main.tf +++ b/automation/terraform/testnets/ci-net/main.tf @@ -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 = true +} + locals { seed_region = "us-west1" seed_zone = "us-west1-b" @@ -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 From 7413f66f32ec0ff6a9534d45e2f1056d300ebddd Mon Sep 17 00:00:00 2001 From: SanabriaRusso Date: Tue, 23 Jul 2024 18:01:50 +0200 Subject: [PATCH 2/2] Assigned value for CI at execution time instead of embedding it --- automation/terraform/testnets/ci-net/main.tf | 2 +- buildkite/scripts/terraform-test.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/automation/terraform/testnets/ci-net/main.tf b/automation/terraform/testnets/ci-net/main.tf index d6ba50d1b61..f9a41019e43 100644 --- a/automation/terraform/testnets/ci-net/main.tf +++ b/automation/terraform/testnets/ci-net/main.tf @@ -65,7 +65,7 @@ variable "ci_artifact_path" { variable "create_libp2p_files" { type = bool description = "Whether to create LibP2P peer ID files" - default = true + default = false } locals { diff --git a/buildkite/scripts/terraform-test.sh b/buildkite/scripts/terraform-test.sh index c117898cfa0..d5da2567f7e 100755 --- a/buildkite/scripts/terraform-test.sh +++ b/buildkite/scripts/terraform-test.sh @@ -5,7 +5,7 @@ function test_single_terraform_config { cd $1 terraform init - terraform plan + terraform plan -var="create_libp2p_files=true" RET=$?