From 15db322476caf5f470d8b0aae16f120ab44b7104 Mon Sep 17 00:00:00 2001 From: RLRabinowitz <30493345+RLRabinowitz@users.noreply.github.com> Date: Wed, 6 Apr 2022 12:38:17 +0300 Subject: [PATCH] Fix: Remove flaky template tests (#322) * Remove flaky datas from template tests, and validation on other existing datas * Fix test's new github data output * Fix tested1 - tested2 confusion * Meaningful names to resources in template test --- .../004_template/expected_outputs.json | 13 ++-- tests/integration/004_template/main.tf | 68 ++++++------------- 2 files changed, 29 insertions(+), 52 deletions(-) diff --git a/tests/integration/004_template/expected_outputs.json b/tests/integration/004_template/expected_outputs.json index 0477a1e0..a5335180 100644 --- a/tests/integration/004_template/expected_outputs.json +++ b/tests/integration/004_template/expected_outputs.json @@ -1,8 +1,9 @@ { - "tested2_template_type": "terraform", - "tested2_template_name": "tested1-", - "tested2_template_repository": "https://github.com/env0/templates", - "tested1_template_repository": "https://gitlab.com/env0/gitlab-vcs-integration-tests.git", - "tested2_template_path": "second", - "tg_tg_version" : "0.35.0" + "github_template_type": "terraform", + "github_template_name": "Github Test-", + "github_template_repository": "https://github.com/env0/templates", + "gitlab_template_repository": "https://gitlab.com/env0/gitlab-vcs-integration-tests.git", + "github_template_path": "second", + "tg_tg_version" : "0.35.0", + "data_github_template_type": "terraform" } diff --git a/tests/integration/004_template/main.tf b/tests/integration/004_template/main.tf index 36ae3dc0..bc7c93f1 100644 --- a/tests/integration/004_template/main.tf +++ b/tests/integration/004_template/main.tf @@ -18,9 +18,9 @@ data "env0_template" "gitlab_template" { name = "Gitlab Integrated Template" } -resource "env0_template" "tested1" { - name = "tested1-${random_string.random.result}" - description = "Tested 1 description" +resource "env0_template" "github_template" { + name = "Github Test-${random_string.random.result}" + description = "Template description - GitHub" type = "terraform" repository = data.env0_template.github_template.repository github_installation_id = data.env0_template.github_template.github_installation_id @@ -31,9 +31,9 @@ resource "env0_template" "tested1" { terraform_version = "0.15.1" } -resource "env0_template" "tested2" { +resource "env0_template" "gitlab_template" { name = "GitLab Test-${random_string.random.result}" - description = "Tested 2 description - Gitlab" + description = "Template description - Gitlab" type = "terraform" repository = data.env0_template.gitlab_template.repository token_id = data.env0_template.gitlab_template.token_id @@ -57,62 +57,38 @@ resource "env0_template" "template_tg" { resource "env0_configuration_variable" "in_a_template" { name = "fake_key" value = "fake value" - template_id = env0_template.tested1.id + template_id = env0_template.github_template.id } resource "env0_configuration_variable" "in_a_template2" { name = "fake_key_2" value = "fake value 2" - template_id = env0_template.tested1.id + template_id = env0_template.github_template.id type = "terraform" } -# Temporary - Sleep to avoid eventual consistency issues with the data sources -resource "time_sleep" "wait_for_all_templates" { - depends_on = [env0_template.tested1, env0_template.tested2, env0_template.template_tg] - triggers = { - # Only using depends_on doesn't work on re-apply. This makes sure the sleep happens on re-apply - second_run = var.second_run - } - create_duration = "5s" +output "github_template_id" { + value = env0_template.github_template.id } - -data "env0_template" "tested2" { - depends_on = [time_sleep.wait_for_all_templates] - name = "tested1-${random_string.random.result}" -} -data "env0_template" "tested1" { - depends_on = [time_sleep.wait_for_all_templates] - name = "GitLab Test-${random_string.random.result}" +output "github_template_type" { + value = env0_template.github_template.type } -data "env0_template" "template_tg" { - depends_on = [time_sleep.wait_for_all_templates] - name = "Template for environment resource - tg-${random_string.random.result}" -} - -output "tested2_template_id" { - value = data.env0_template.tested2.id +output "github_template_name" { + value = replace(env0_template.github_template.name, random_string.random.result, "") } -output "tested2_template_type" { - value = data.env0_template.tested2.type +output "github_template_repository" { + value = env0_template.github_template.repository } -output "tested2_template_name" { - value = replace(data.env0_template.tested2.name, random_string.random.result, "") +output "gitlab_template_repository" { + value = env0_template.gitlab_template.repository } -output "tested2_template_repository" { - value = data.env0_template.tested2.repository -} -output "tested1_template_repository" { - value = data.env0_template.tested1.repository -} -output "tested2_template_path" { - value = data.env0_template.tested2.path +output "github_template_path" { + value = env0_template.github_template.path } output "tg_tg_version" { - value = data.env0_template.template_tg.terragrunt_version + value = env0_template.template_tg.terragrunt_version } -data "env0_template" "tested3" { - id = env0_template.tested1.id +output "data_github_template_type" { + value = data.env0_template.github_template.type } -