Skip to content

Commit

Permalink
Fix: fix 029_provider flaky test by adding sleep (#884)
Browse files Browse the repository at this point in the history
* Fix: fix 029_provider flaky test by adding sleep

* fix another flaky test

* fix another flaky test
  • Loading branch information
TomerHeber authored Jun 25, 2024
1 parent b11c7f8 commit ae427a6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 26 deletions.
59 changes: 37 additions & 22 deletions tests/integration/003_configuration_variable/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,34 @@ resource "env0_configuration_variable" "region_in_project_resource" {
value = "il-tnuvot-1"
}

resource "env0_configuration_variable" "tested1" {
name = "tested1-${random_string.random.result}"
value = "fake value 1 ${var.second_run ? "after update" : ""}"
}

resource "env0_configuration_variable" "tested3" {
name = "tested3-${random_string.random.result}"
value = "First"
enum = ["First", "Second"]
}

resource "env0_configuration_variable" "regex_var" {
project_id = env0_project.test_project.id
name = "regex_var"
regex = "^test-\\d+$"
}

resource "time_sleep" "wait_5_seconds" {
create_duration = "5s"

depends_on = [env0_configuration_variable.region_in_project_resource, env0_configuration_variable.tested1, env0_configuration_variable.tested3, env0_configuration_variable.regex_var]
}

data "env0_configuration_variable" "region_in_project" {
name = "AWS_DEFAULT_REGION"
project_id = env0_project.test_project.id
depends_on = [env0_configuration_variable.region_in_project_resource]

depends_on = [time_sleep.wait_5_seconds]
}
output "region_in_project_value" {
value = data.env0_configuration_variable.region_in_project.value
Expand All @@ -27,13 +51,11 @@ output "region_in_project_id" {
value = data.env0_configuration_variable.region_in_project.id
}

resource "env0_configuration_variable" "tested1" {
name = "tested1-${random_string.random.result}"
value = "fake value 1 ${var.second_run ? "after update" : ""}"
}

data "env0_configuration_variable" "tested1" {
name = "tested1-${random_string.random.result}"
depends_on = [env0_configuration_variable.tested1]
name = "tested1-${random_string.random.result}"

depends_on = [time_sleep.wait_5_seconds, env0_configuration_variable.tested1]
}

output "tested1_value" {
Expand All @@ -43,18 +65,16 @@ output "tested1_value" {

data "env0_configuration_variable" "tested2" {
id = env0_configuration_variable.tested1.id
}

resource "env0_configuration_variable" "tested3" {
name = "tested3-${random_string.random.result}"
value = "First"
enum = ["First", "Second"]
depends_on = [time_sleep.wait_5_seconds]
}


data "env0_configuration_variable" "tested3" {
name = "tested3-${random_string.random.result}"
depends_on = [env0_configuration_variable.tested3]
}
name = "tested3-${random_string.random.result}"

depends_on = [time_sleep.wait_5_seconds]
}

output "tested3_enum_1" {
value = data.env0_configuration_variable.tested3.enum[0]
Expand All @@ -65,16 +85,11 @@ output "tested3_enum_2" {
sensitive = true
}

resource "env0_configuration_variable" "regex_var" {
project_id = env0_project.test_project.id
name = "regex_var"
regex = "^test-\\d+$"
}

data "env0_configuration_variable" "regex_var" {
project_id = env0_project.test_project.id
name = "regex_var"
depends_on = [env0_configuration_variable.regex_var]

depends_on = [time_sleep.wait_5_seconds]
}

output "regex" {
Expand Down
15 changes: 11 additions & 4 deletions tests/integration/029_provider/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ resource "env0_provider" "test_provider" {
description = var.second_run ? "des1" : "des2"
}

# TODO: uncomment when we fix 404 retry logic
# data "env0_provider" "test_provider_data" {
# type = env0_provider.test_provider.type
# }
resource "time_sleep" "wait_5_seconds" {
create_duration = "5s"

depends_on = [env0_provider.test_provider]
}

data "env0_provider" "test_provider_data" {
type = env0_provider.test_provider.type

depends_on = [time_sleep.wait_5_seconds]
}

resource "env0_provider" "test_provider-type-change" {
type = var.second_run ? "aws2-${random_string.random.result}" : "aws1-${random_string.random.result}"
Expand Down

0 comments on commit ae427a6

Please sign in to comment.