我正在使用terratest来测试terraform,我想确保terraform创建资源组、容器注册表和AKS,当我进行测试时-v-Timeout 60M所有资源都被创建和销毁,但最后我不知道它为什么抛出
TestTerraformAzureResources 2024-02-09T18:45:51+05:00 logger.go:66:
Destroy complete! Resources: 4 destroyed.
TestTerraformAzureResources 2024-02-09T18:45:51+05:00 logger.go:66:
--- FAIL: TestTerraformAzureResources (691.95s)
FAIL
exit status 1
FAIL my-terratest-project 691.996s
以下是我的terraform_test.go代码
package test
import (
"testing"
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/assert"
)
func TestTerraformAzureResources(t *testing.T) {
terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{
TerraformDir: "../terraform scripts",
})
defer terraform.Destroy(t, terraformOptions)
terraform.InitAndApply(t, terraformOptions)
// Retrieve the outputs of the Terraform configuration
resourceGroupName := terraform.Output(t, terraformOptions, "resource_group_name")
acrName := terraform.Output(t, terraformOptions, "acr_name")
aksName := terraform.Output(t, terraformOptions, "aks_name")
// Define the expected values
expectedResourceGroupName := "microservice-deployment-demo-tf-
scripttest"
expectedACRName := "microserviceimagestfscripttest"
expectedAKSName := "example-aks1-tf-scripttest"
// Compare the outputs with the expected values
assert.Equal(t, expectedResourceGroupName, resourceGroupName, "Resource
group name does not match")
assert.Equal(t, expectedACRName, acrName, "Azure Container Registry name
does not match")
assert.Equal(t, expectedAKSName, aksName, "Azure Kubernetes Cluster name
does not match")
}