How to run Gardener integration tests for shoot creation without production credentials?
0 reputation · 20 Sept 2021, 15:34 UTC
0 reputation · 20 Sept 2021, 15:34 UTC
The Gardener project provides an integration test script that runs Ginkgo tests against a local or CI environment, optionally generating JUnit reports. The script configures test flags, including a timeout when running in Prow, and invokes go test with GO111MODULE=on. However, exercising the shoot creation feature typically requires credentials for the target cloud provider, which poses a security risk when running tests outside production. The goal is to validate the shoot creation integration logic without exposing real credentials, perhaps by using a fake provider, envtest cluster, or mocking the cloud API. Constraints include keeping the test reproducible locally, avoiding external secrets, and still exercising the Gardener controller manager and API server. It is unclear which environment variables or test flags allow skipping credential‑dependent steps, or whether a dedicated test suite exists for the shoot creation feature that works with envtest.
Specific questions:
To exercise the shoot creation logic in Gardener’s integration test suite while avoiding real cloud credentials, run the tests against a local Kubernetes cluster (e.g., kind) and configure Gardener to use a fake or test cloud provider. This keeps the test reproducible locally and does not expose any production secrets.
envtest cluster):
# Install kind if needed
# go install sigs.k8s.io/kind@v0.22.0
kind create cluster --name gardener-test --wait 60s
export KUBECONFIG="$(kind get kubeconfig-path --name='gardener-test')"
GARDENER_TEST_PROVIDER (or GARDENER_CLOUD_PROVIDER for some providers) to switch to a mock implementation that does not call real APIs.
export GARDENER_TEST_PROVIDER=local # or "fake" depending on the provider code
# For AWS‑style tests you can also provide dummy keys that are ignored by the fake provider:
export AWS_ACCESS_KEY_ID=test
export AWS_SECRET_ACCESS_KEY=test
go test directly.
# Using make (adjust the focus label as needed)
make test-integration TEST_FOCUS=ShootCreation
# Or directly with go test
GO111MODULE=on go test ./test/integration/shoot -run TestShootCreation -v
# Example verification command after the test run
grep -E 'kind-control-plane|127\.0\.0\.1' test-output.log
# Ensure no lines contain real AWS, Azure or GCP endpoints
The Gardener integration test framework already contains a "local" or "fake" provider implementation that is exercised when GARDENER_TEST_PROVIDER is set. This provider creates shoot objects in the API server but does not attempt to provision real infrastructure; instead it patches the shoot status to simulate successful reconciliation. By pointing Gardener’s KUBECONFIG at a kind cluster, the API server and controller manager run locally, satisfying the requirement to exercise the controller logic without external credentials.
If the tests still fail because they expect provider‑specific configuration (e.g., region, zone), you can supply dummy values via the usual provider environment variables (AWS_REGION, AZURE_LOCATION, etc.). These values are ignored by the fake provider but satisfy any validation that expects them to be present.
If you observe that the test logs still contain calls to real cloud endpoints after setting the fake provider, please share the exact error message or the provider name you are targeting; that information would change the recommendation (e.g., a different fake‑provider flag may be required).
Use comments to ask for clarification. Post a solution as an answer.
26,525 reputation · 20 Sept 2021, 18:15 UTC
One clarification on the previous answer: I'm not aware of a GARDENER_TEST_PROVIDER environment variable in the gardener/gardener codebase, and I'd verify that before relying on it. The supported local path is different: Gardener ships provider-local, an actual extension that emulates infrastructure operations, so shoot creation runs against a kind cluster without any cloud credentials. The typical flow is make kind-up followed by make gardener-up, which deploys the control plane plus local DNS and registry into kind.
Two things worth knowing:
test/e2e/gardener use this local provider, so shoot reconciliation, hibernation, and deletion run with no real machines — node behavior is emulated, meaning you validate orchestration logic, not VM lifecycle.Caveats: make targets and directory layout shift between releases, so check docs/development for your checked-out version, and budget several GB of RAM for the kind setup. Also note local tests won't catch IAM, quota, or machine-image issues.