0

我在运行 Terraform 测试时收到以下错误消息:

│ Error: Failed to clean up after tests
│
│ Due to errors during destroy, test suite "defaults" has left behind an object for module.ns_checks.module.namespaces.aws_iam_role.ns_editor["pm"], with the following identity:
│     name = "editor-ns"
│
│ You will need to delete this object manually in the remote system, or else it may have an ongoing cost.
╵
╷
│ Error: Failed to clean up after tests
│
│ Due to errors during destroy, test suite "defaults" has left behind an object for module.ns_checks.module.namespaces.aws_iam_role.ns_editor["cs"], with the following identity:
│     name = "s-editor"
│
│ You will need to delete this object manually in the remote system, or else it may have an ongoing cost.
╵
╷
│ Error: Failed to clean up after tests
│
│ Due to errors during destroy, test suite "defaults" has left behind an object for module.ns_checks.module.namespaces.aws_iam_role.ns_editor["as"], with the following identity:
│     name = "editor"
│
│ You will need to delete this object manually in the remote system, or else it may have an ongoing cost.
╵
Success! All of the test assertions passed.

但是,测试运行成功,资源也被删除...

但不知道如何摆脱这个错误。

我还手动尝试在测试目录中执行 init/plan 和 apply/destroy 并且它是成功的,但是当我运行 terraform 测试时它会抛出这些错误。

我也尝试了不正确的输出,但它按预期失败。只是想摆脱这些错误。

 Error: Failed to clean up after tests
│
│ Due to errors during destroy, test suite "defaults" has left behind an object for module.ns_checks.module.namespaces.null_resource.ns_admin["cs"]. You will need to delete this object manually in the remote system, or else it may
│ have an ongoing cost.
╵
╷
│ Error: Failed to clean up after tests
│
│ Due to errors during destroy, test suite "defaults" has left behind an object for module.ns_checks.module.namespaces.null_resource.ns_admin["as"]. You will need to delete this object manually in the remote system, or else it may
│ have an ongoing cost.
╵
╷
│ Error: Failed to clean up after tests
│
│ Due to errors during destroy, test suite "defaults" has left behind an object for module.ns_checks.module.namespaces.null_resource.ns_admin["pm"]. You will need to delete this object manually in the remote system, or else it may
│ have an ongoing cost.
╵
─── Failed: defaults.ns_name1.name (Check the ns) 
wrong value
    got:  "pm"
    want: "as"

─── Failed: defaults.ns_name2.name (Check the ns) 
wrong value
    got:  "as"
    want: "cs"

─── Failed: defaults.ns_name3.name (Check the ns) 
wrong value
    got:  "cs"
    want: "pm"
    enter code here

按照这个建议尝试:https ://discuss.hashicorp.com/t/better-terraform-testing-logging-and-error-messages/27055

请建议如何摆脱这些错误

参考:https ://www.scalefactory.com/blog/2021/03/30/integration-testing-with-terraform-0.15/

4

0 回答 0