1

使用Terraform 的 Runscope 提供程序创建 Runscope 测试时,每个测试都创建为引用测试资源的单独资源。

resource "runscope_test" "api" {
  name         = "api-test"
  description  = "checks the api is up and running"
  bucket_id    = "${runscope_bucket.main}"
}

resource "runscope_step" "step_1" {
  bucket_id      = "${runscope_bucket.bucket.id}"
  test_id        = "${runscope_test.test.id}"
  step_type      = "request"

  ...

}

resource "runscope_step" "step_2" {
  bucket_id      = "${runscope_bucket.bucket.id}"
  test_id        = "${runscope_test.test.id}"
  step_type      = "request"

  ...

}

根据 Terraform,声明资源的顺序没有任何区别。

Terraform 的 Runscope 提供程序如何确定测试的步骤顺序?


更新

在 Terraform 文档中查看资源之间的隐式依赖关系,我发现我可以简单地参考上一步。

Terraform 能够推断出依赖关系,并且知道它必须首先创建实例。

在这种情况下,我使用note第二步的属性来引用第一步:

resource "runscope_step" "step_2" {
  bucket_id      = "${runscope_bucket.bucket.id}"
  test_id        = "${runscope_test.test.id}"
  step_type      = "request"
  note           = "Follows step: ${runscope_step.step_1.id}"

  ...
}
4

1 回答 1

0

我认为您可以在这样的步骤之间使用隐式依赖关系:

resource "runscope_step" "step_1" {
  bucket_id      = "${runscope_bucket.bucket.id}"
  test_id        = "${runscope_test.test.id}"
  step_type      = "request"

  ...

}

resource "runscope_step" "step_2" {
  bucket_id      = "${runscope_step.step_1.bucket_id}"
  test_id        = "${runscope_test.test.id}"
  step_type      = "request"

  ...

}

resource "runscope_step" "step_3" {
  bucket_id      = "${runscope_step.step_2.bucket_id}"
  test_id        = "${runscope_test.test.id}"
  step_type      = "request"

  ...

}

and you can check dependencies via [terraform graph][1] command


  [1]: https://www.terraform.io/docs/commands/graph.html
于 2019-08-09T19:29:53.477 回答