问题描述
我想使用 go test
和 terratest
库对具有约 10 个不同组件(pod、服务、负载平衡器、组件之间的链接等)的集群进行集成测试。用于构建基础架构的工具是 terraform
、kubernetes
和 helm
。构建基础设施大约需要。 10分钟,这样我就不想每次测试都单独做。我的解决方案建议使用在 TestMain(*testing.M)
中设置测试基础设施的模式,并在 TestAuth(*testing.T)
、TestMonitoring(*testing.T)
等测试套件中对测试进行分组。现在,我需要调用 {{1 }} 测试套件之外的 terratest
组件——显然对我来说——是不可能的。
我尝试了以下方法:
terraform.InitAndApply(*testing.T,terraformOptions)
由于这是设置综合测试基础设施的自然方式,我错过了什么?
我看到所有 func TestMain(m *testing.M) {
setupInfrastructure()
rc = m.Run()
teadDownInfrastructure()
os.Exit(rc)
}
func setupInfrastructure() {
terraformOptions := &terraform.Options{
terraformDir: testFolder,EnvVars: map[string]string{
"TF_VAR_cluster_size": 3,},}
terraform.InitAndApply(t,terraformOptions) // <-- this is the problem
}
样本 (https://github.com/gruntwork-io/terratest/tree/master/test) 都使用一个测试套件、阶段和子测试,我不想这样做,因为它放弃了 {{1 }}。这真的是完成这项工作的唯一方法吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)