tgc-fix-integration-tests-skill
When you need to fix integration tests for TGC, use this skill.
When to Use This Skill
- Use this when fixing integration tests for TGC.
- This is helpful when you need to address build and testing failures for any Terraform Google Conversion (TGC) resource.
How to Use It
To fix integration tests, follow the guidelines and playbook below:
1. General Rules for Fixing Tests
When troubleshooting and resolving test failures, adhere to these constraints:
- DON'T modify the templates in
mmv1/templates/terraformor shared helper files/templates inmmv1/third_party/terraform. It is only allowed to modify the templates inmmv1/templates/tgc_nextor TGC Next custom files undermmv1/third_party/tgc_next/. - DON'T modify legacy TGC code in
mmv1/third_party/cai2hclormmv1/third_party/tgc. All changes must be made to TGC Next code inmmv1/third_party/tgc_next/. - DON'T add
ignore_read_extrato the example inResource.yaml. - DON'T add new fields to
mmv1/api/resource/custom_code.gounless explicitly guided by the user. - DON'T remove any existing
custom_code, including any constants. - DO add a comment for each fix in the YAML file or other files to explain the root cause and the solution.
- DON'T use
d.Setin custom decoders forcai2hcl. Conversion incai2hclis a direct mapping from CAI asset data maps to HCL maps without involving Terraform state. Mutate the data map directly. - DON'T use
is_missing_in_cai: trueif the missing fields are present in other raw JSON files of other tests. - DON'T modify
mmv1/api/resource.goto hardcode or manually append ignored fields for tests. If there is a field path mapping mismatch (e.g., due to singular/plural name differences), rename the property name in the resource YAML configuration (e.g.,Instance.yaml) and useapi_nameto map it to the API field name. - DO trace the value of a failing field through
Test_export.tf,Test_roundtrip.json, andTest_roundtrip.tfto identify the exact stage where data is lost or mutated, rather than guessing based on the final error message.
2. Test Discovery and Naming Conventions
When tests are not being generated or run for a resource, ensure that the handwritten test files in mmv1/third_party/terraform/services/<product>/ follow the expected naming convention: resource_<product>_<resource_name>_test.go.
If the file name does not match, the generator function addTestsFromHandwrittenTests will fail to find it and will log a message like no handwritten test file found for <resource>. Renaming the file to match the expected convention allows the generator to discover it.
3. Troubleshooting Playbook
The detailed troubleshooting playbook has been moved to a separate file to keep this skill description concise.
Please refer to Troubleshooting Playbook for solutions to common test failures.