test-terraform-fields

Validates Config Connector resource fields by recording golden HTTP logs against real GCP and MockGCP.

1.1k|377|Updated Apr 8, 2019
One-click install
npx skills add https://github.com/GoogleCloudPlatform/k8s-config-connector --skill test-terraform-fields
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-terraform-fields
Source: https://github.com/GoogleCloudPlatform/k8s-config-connector/tree/main/.gemini/skills/test-terraform-fields
Command: npx skills add https://github.com/GoogleCloudPlatform/k8s-config-connector --skill test-terraform-fields

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Adding or modifying fields on Config Connector resources requires end-to-end validation against both real GCP and the MockGCP control plane, and manually coordinating golden file generation, baseline commits, and mock alignment is error-prone and easy to get wrong.

Core Features & Use Cases

  • Golden File Test Workflow: Guides creation of fixture directories with create.yaml, update.yaml, dependencies.yaml, and golden HTTP logs under pkg/test/resourcefixture/testdata.
  • Real GCP Recording: Enforces recording authentic _http.log baselines via hack/record-gcp with proper ADC authentication, project configuration, and mandatory baseline commits.
  • MockGCP Alignment: Provides troubleshooting strategies for enum mismatches, server-generated fields, volatile value normalization, and duplicate normalizer conflicts.
  • Use Case: When adding a new mutable field to a DNSRecordSet resource, use this Skill to set up the fixture, record live GCP traffic, compare against MockGCP, fix mock discrepancies, and run all CI presubmit checks before submitting the PR.

Quick Start

Ask the agent to set up and record a golden E2E test fixture for a specific Config Connector resource field using hack/record-gcp and then align MockGCP behavior.

Frequently Asked Questions about test-terraform-fields

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test new fields on Config Connector resources?

Create a fixture directory under pkg/test/resourcefixture/testdata/basic with create.yaml and update.yaml, remove the resource from the ratcheting exclusion list, then record golden logs against real GCP using hack/record-gcp before comparing with MockGCP.

How do I record golden HTTP logs for KCC E2E tests?

Run hack/record-gcp with the test name or package path after authenticating with gcloud application-default login and setting GCP_PROJECT_ID. The script executes tests with E2E_GCP_TARGET=real and WRITE_GOLDEN_OUTPUT=1 to capture the _http.log baseline.

Why does MockGCP output differ from real GCP golden logs?

Differences come from enum naming mismatches, server-generated fields, or volatile values like timestamps and UUIDs. Fix these by intercepting request bodies in the mock service, implementing default value generation, or adding scoped normalization rules in normalize.go.

Can I run go test directly for KCC E2E fixture tests?

No, running go test directly bypasses KUBEBUILDER_ASSETS configuration and may use an outdated kube-apiserver, producing incorrect fields like metadata.selfLink in golden files. Always use hack/record-gcp, hack/compare-mock, or dev/tasks/run-e2e instead.

What presubmit checks are required before submitting a KCC PR?

Run make ready-pr, make resource-docs, dev/ci/presubmits/validate-generated-files, scripts/validate-prereqs.sh, go vet, and the relevant tests-e2e-fixtures group script. Also verify CRD field coverage and acronym casing tests, then commit all regenerated golden files.