Skip to content

Conversation

@pkoutsovasilis
Copy link
Contributor

@pkoutsovasilis pkoutsovasilis commented Jun 17, 2025

What does this PR do?

This PR refactors the Kubernetes integration tests by pre-rendering the Kustomize manifest before test execution. The key changes include:

  • Moved Kustomize rendering to TestMain: This ensures Kustomize manifests are rendered once before all tests run, avoiding repeated work in every test case.
  • Introduced --integration.k8s.skip-kustomize-tests flag: Allows skipping Kustomize-based tests when necessary (e.g., local test runs or CI constraints).
  • Removed inline k8sRenderKustomize logic: This logic is now centralized and retried with backoff using cenkalti/backoff/v5.
  • Replaced deprecated skip logic: Now each test case uses a skip(t *testing.T) function to allow dynamic skipping logic.

Why is it important?

Reduces test flakiness: Previously, each test independently rendered the Kustomize YAML, which involved fetching resources such as kube-state-metrics manifests from GitHub. This led to transient test failures due to network instability or GitHub rate limiting. By rendering the manifest once during test setup with retry logic, we reduce (but do not eliminate) this source of flakiness.

Checklist

  • I have read and understood the pull request guidelines of this project.
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

Disruptive User Impact

None expected. This change only affects internal integration test infrastructure and does not impact users or production functionality.

How to test this PR locally

EXTERNAL=true SNAPSHOT=true PACKAGES=docker DOCKER_VARIANTS=basic PLATFORMS=linux/arm64 mage package

SNAPSHOT=true INSTANCE_PROVISIONER="kind" TEST_PLATFORMS="kubernetes/arm64/1.33.0/basic" mage integration:TestKubernetes

Related issues

@pkoutsovasilis pkoutsovasilis self-assigned this Jun 17, 2025
@pkoutsovasilis pkoutsovasilis added Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team skip-changelog backport-active-all Automated backport with mergify to all the active branches labels Jun 17, 2025
@elasticmachine
Copy link
Collaborator

⏳ Build in-progress, with failures

Failed CI Steps

cc @pkoutsovasilis

@pkoutsovasilis pkoutsovasilis force-pushed the feat/k8s_integration_init branch from 269ac4d to 5d2c7df Compare June 17, 2025 09:11
@elastic-sonarqube
Copy link

@pkoutsovasilis pkoutsovasilis marked this pull request as ready for review June 17, 2025 19:09
@pkoutsovasilis pkoutsovasilis requested a review from a team as a code owner June 17, 2025 19:09
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@pkoutsovasilis
Copy link
Contributor Author

closing in favour of #8575

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-all Automated backport with mergify to all the active branches skip-changelog Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants