Skip to content

Commit

Permalink
fix: Add clean token to remove extra new line added in provision
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanadelacuesta committed Jan 17, 2025
1 parent 889703f commit d6760d4
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 100 deletions.
3 changes: 3 additions & 0 deletions enos/enos-providers.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "aws" "default" {
region = var.aws_region
}
2 changes: 2 additions & 0 deletions enos/modules/run_workloads/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Job specs rendered during the module execution
jobs/*.hcl
2 changes: 1 addition & 1 deletion enos/modules/run_workloads/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ terraform {
}

locals {
clean_token = trimspace(var.nomad_token) #Somewhere in the process, a newline is added to teh token.
clean_token = trimspace(var.nomad_token) #Somewhere in the process, a newline is added to the token.
}

resource "enos_local_exec" "wait_for_nomad_api" {
Expand Down
25 changes: 25 additions & 0 deletions enos/modules/run_workloads/scripts/wait_for_nomad_api.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

set -xeuo pipefail

TIMEOUT=20
INTERVAL=5

start_time=$(date +%s)

while ! nomad server members > /dev/null 2>&1; do
echo "Waiting for Nomad API..."

current_time=$(date +%s)
elapsed_time=$((current_time - start_time))
if [ "$elapsed_time" -ge "$TIMEOUT" ]; then
echo "Error: Nomad API did not become available within $TIMEOUT seconds."
exit 1
fi

sleep "$INTERVAL"
done

echo "Nomad API is available!"
24 changes: 0 additions & 24 deletions enos/modules/run_workloads/templates/docker-service.nomad.hcl

This file was deleted.

35 changes: 0 additions & 35 deletions enos/modules/run_workloads/templates/exec-system.nomad.hcl

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ job exec-system {
type = "system"
group "exec-system" {
count = 1
count = "${alloc_count}"
task "exec" {
template {
Expand All @@ -32,4 +32,4 @@ EOH
}
}
}
}
}
35 changes: 0 additions & 35 deletions enos/modules/run_workloads/templates/raw-exec-service.nomad.hcl

This file was deleted.

4 changes: 2 additions & 2 deletions enos/modules/run_workloads/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ variable "workloads" {
alloc_count = number
}))
default = {
service_raw_exec = { template = "templates/raw-exec-service.nomad.hcl", alloc_count = 3 }
service_docker = { template = "templates/docker-service.nomad.hcl", alloc_count = 3 }
service_raw_exec = { template = "templates/raw-exec-service.nomad.hcl.tpl", alloc_count = 3 }
service_docker = { template = "templates/docker-service.nomad.hcl.tpl", alloc_count = 3 }
}
}
2 changes: 1 addition & 1 deletion enos/modules/test_cluster_health/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ terraform {
}

locals {
clean_token = trimspace(var.nomad_token) #Somewhere in the process, a newline is added to teh token.
clean_token = trimspace(var.nomad_token) #Somewhere in the process, a newline is added to the token.
}

resource "enos_local_exec" "run_tests" {
Expand Down

0 comments on commit d6760d4

Please sign in to comment.