Skip to content

Commit cbcab4f

Browse files
committed
Update test prefix in tests
1 parent c0c9c03 commit cbcab4f

File tree

8 files changed

+18
-24
lines changed

8 files changed

+18
-24
lines changed

.gitlab-ci.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
image: registry.ddbuild.io/images/mirror/golang:1.23.4
2-
31
stages:
42
- test
53

@@ -12,13 +10,6 @@ tests:
1210
- mkdir -p ~/.aws
1311
- apt-get update && apt-get install -y unzip curl jq
1412

15-
# Setup opentofu (open source Terraform)
16-
# - curl -L https://github.com/opentofu/opentofu/releases/download/v1.9.1/tofu_1.9.1_linux_amd64.tar.gz -o tofu.tar.gz
17-
# - tar -xzf tofu.tar.gz
18-
# - mv tofu /usr/local/bin/tofu
19-
# - chmod +x /usr/local/bin/tofu
20-
# - tofu version
21-
2213
# Setup Terraform
2314
- curl -fsSL https://releases.hashicorp.com/terraform/1.6.6/terraform_1.6.6_linux_amd64.zip -o terraform.zip
2415
- unzip terraform.zip

tests/all_dd_disabled_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (s *ECSFargateSuite) TestAllDDDisabled() {
2020
// Retrieve the task output for the "all-dd-disabled" module
2121
var containers []types.ContainerDefinition
2222
task := terraform.OutputMap(s.T(), s.terraformOptions, "all-dd-disabled")
23-
s.Equal("terraform-test-all-dd-disabled", task["family"], "Unexpected task family name")
23+
s.Equal(s.testPrefix+"-all-dd-disabled", task["family"], "Unexpected task family name")
2424
s.Equal(string(types.NetworkModeAwsvpc), task["network_mode"], "Unexpected network mode")
2525
s.Equal(string(types.PidModeTask), task["pid_mode"], "Unexpected PID mode")
2626

tests/all_dd_inputs_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ func (s *ECSFargateSuite) TestAllDDInputs() {
2121
var containers []types.ContainerDefinition
2222
task := terraform.OutputMap(s.T(), s.terraformOptions, "all-dd-inputs")
2323

24+
s.Equal(s.testPrefix+"-all-dd-inputs", task["family"], "Unexpected task family name")
25+
2426
err := json.Unmarshal([]byte(task["container_definitions"]), &containers)
2527
s.NoError(err, "Failed to parse container definitions")
2628
s.Equal(6, len(containers), "Expected 6 containers in the task definition")

tests/all_ecs_inputs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func (s *ECSFargateSuite) TestAllECSInputs() {
1818
// Retrieve the task output for the "all-ecs-inputs" module
1919
task := terraform.OutputMap(s.T(), s.terraformOptions, "all-ecs-inputs")
2020

21-
s.Equal("terraform-test-all-ecs-inputs", task["family"], "Unexpected task family name")
21+
s.Equal(s.testPrefix+"-all-ecs-inputs", task["family"], "Unexpected task family name")
2222
s.Equal("256", task["cpu"], "Unexpected CPU value")
2323
s.Equal("512", task["memory"], "Unexpected memory value")
2424
s.Equal("awsvpc", task["network_mode"], "Unexpected network mode")

tests/all_windows_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (s *ECSFargateSuite) TestAllWindows() {
2020
// Retrieve the task output for the "all-windows" module
2121
var containers []types.ContainerDefinition
2222
task := terraform.OutputMap(s.T(), s.terraformOptions, "all-windows")
23-
s.Equal("terraform-test-all-windows", task["family"], "Unexpected task family name")
23+
s.Equal(s.testPrefix+"-all-windows", task["family"], "Unexpected task family name")
2424
s.Equal(string(types.NetworkModeAwsvpc), task["network_mode"], "Unexpected network mode")
2525
s.Equal(string(types.PidModeTask), task["pid_mode"], "Unexpected PID mode")
2626

tests/apm_dsd_tcp_udp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (s *ECSFargateSuite) TestApmDsdTcpUdp() {
2020
// Retrieve the task output for the "apm-dsd-tcp-udp" module
2121
var containers []types.ContainerDefinition
2222
task := terraform.OutputMap(s.T(), s.terraformOptions, "apm-dsd-tcp-udp")
23-
s.Equal("terraform-test-apm-dsd-tcp-udp", task["family"], "Unexpected task family name")
23+
s.Equal(s.testPrefix+"-apm-dsd-tcp-udp", task["family"], "Unexpected task family name")
2424
s.Equal(string(types.NetworkModeAwsvpc), task["network_mode"], "Unexpected network mode")
2525
s.Equal(string(types.PidModeTask), task["pid_mode"], "Unexpected PID mode")
2626

tests/logging_only_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (s *ECSFargateSuite) TestLoggingOnly() {
2020
// Retrieve the task output for the "logging-only" module
2121
var containers []types.ContainerDefinition
2222
task := terraform.OutputMap(s.T(), s.terraformOptions, "logging-only")
23-
s.Equal("terraform-test-logging-only", task["family"], "Unexpected task family name")
23+
s.Equal(s.testPrefix+"-logging-only", task["family"], "Unexpected task family name")
2424
s.Equal(string(types.NetworkModeAwsvpc), task["network_mode"], "Unexpected network mode")
2525
s.Equal(string(types.PidModeTask), task["pid_mode"], "Unexpected PID mode")
2626

tests/main_test.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"log"
1010
"os"
1111
"testing"
12-
"time"
1312

1413
"github.com/gruntwork-io/terratest/modules/terraform"
1514
"github.com/stretchr/testify/suite"
@@ -19,6 +18,7 @@ import (
1918
type ECSFargateSuite struct {
2019
suite.Suite
2120
terraformOptions *terraform.Options
21+
testPrefix string
2222
}
2323

2424
// TestECSFargateSuite is the entry point for the test suite
@@ -31,10 +31,10 @@ func (s *ECSFargateSuite) SetupSuite() {
3131
log.Println("Setting up test suite resources...")
3232

3333
// All resources must be prefixed with terraform-test
34-
testPrefix := "terraform-test"
34+
s.testPrefix = "terraform-test"
3535
ciJobID := os.Getenv("CI_JOB_ID")
3636
if ciJobID != "" {
37-
testPrefix = testPrefix + "-" + ciJobID
37+
s.testPrefix = s.testPrefix + "-" + ciJobID
3838
}
3939

4040
// Define the Terraform options for the suite
@@ -46,19 +46,20 @@ func (s *ECSFargateSuite) SetupSuite() {
4646
"dd_api_key": "test-api-key",
4747
"dd_service": "test-service",
4848
"dd_site": "datadoghq.com",
49-
"test_prefix": testPrefix,
49+
"test_prefix": s.testPrefix,
5050
},
5151
RetryableTerraformErrors: map[string]string{
52-
"couldn't find resource": "ECS eventually consistent or task definition not yet propagated",
52+
"couldn't find resource": "terratest could not find the resource",
5353
},
54-
NoColor: true,
55-
MaxRetries: 2,
56-
TimeBetweenRetries: 10 * time.Second,
57-
Lock: true,
54+
// NoColor: true,
55+
// MaxRetries: 0,
56+
// TimeBetweenRetries: 10 * time.Second,
57+
// Lock: true,
5858
}
5959

6060
// Run terraform init and apply
61-
terraform.InitAndApply(s.T(), s.terraformOptions)
61+
terraform.Init(s.T(), s.terraformOptions)
62+
terraform.Apply(s.T(), s.terraformOptions)
6263
}
6364

6465
// TearDownSuite is run once at the end of the test suite

0 commit comments

Comments
 (0)