Skip to content

Add BYOK test - #36

Merged
JasonPowr merged 1 commit into
mainfrom
e2e-test-byok
Jul 16, 2025
Merged

Add BYOK test#36
JasonPowr merged 1 commit into
mainfrom
e2e-test-byok

Conversation

@JasonPowr

@JasonPowr JasonPowr commented Jul 15, 2025

Copy link
Copy Markdown
Member

Summary by Sourcery

Add BYOK end-to-end tests and refactor common installation tests with new utilities for dynamic image preparation, TUF root management, templating improvements, and enhanced cleanup.

New Features:

  • Add BYOK end-to-end test suite verifying BYOK policy controller installation and admission webhook flows
  • Implement dynamic test image generation and pushing via PrepareImage to eliminate manual image setup

Enhancements:

  • Refactor common installation tests to use shared constants and e2e_utils for file paths, resource names, and image environments
  • Improve Kubernetes resource cleanup with DeleteResource and exponential backoff polling
  • Introduce template helper nindent and Base64EncodeString for certificate rendering
  • Extract TUF root parsing and RHTAS-specific environment variable handling into dedicated utilities
  • Integrate TSA timestamp server URL into cosign sign, provenance, and SBOM commands

Build:

  • Add github.com/google/go-containerregistry dependency and bump various modules in go.mod

Documentation:

  • Update README to remove manual test image build step and add RHTAS environment variable instructions

@sourcery-ai

sourcery-ai Bot commented Jul 15, 2025

Copy link
Copy Markdown

Reviewer's Guide

This PR refactors the existing common installation test to leverage shared utility functions and constants, extends the end-to-end utility library with exponential backoff deletion, image preparation, and RHTAS-specific TUF parsing, and introduces a new BYOK-focused test suite complete with custom resource templates, while updating dependencies and documentation accordingly.

ER diagram for new BYOK custom resources

erDiagram
    POLICY_CONTROLLER ||--o{ CLUSTER_IMAGE_POLICY : applies
    TRUST_ROOT ||--o{ POLICY_CONTROLLER : trusted_by
    CLUSTER_IMAGE_POLICY {
      string name
      string rules
    }
    POLICY_CONTROLLER {
      string name
      string config
    }
    TRUST_ROOT {
      string name
      string rootData
    }
Loading

Class diagram for new and refactored E2E test utilities

classDiagram
    class CommonInstallTest {
    }
    class BYOKInstallTest {
    }
    class ImageUtil {
        +PrepareTestImage()
    }
    class RHTASUtil {
        +ParseTUF()
        +ExponentialBackoffDelete()
    }
    class KubernetesUtil {
    }
    class CosignUtil {
    }
    CommonInstallTest --|> ImageUtil : uses
    CommonInstallTest --|> RHTASUtil : uses
    BYOKInstallTest --|> ImageUtil : uses
    BYOKInstallTest --|> RHTASUtil : uses
    BYOKInstallTest --|> KubernetesUtil : uses
    BYOKInstallTest --|> CosignUtil : uses
Loading

Class diagram for new BYOK test suite and custom resources

classDiagram
    class BYOKInstallTest {
        +TestBYOKInstallation()
        +TestBYOKPolicyEnforcement()
    }
    class ClusterImagePolicyTemplate {
    }
    class PolicyControllerTemplate {
    }
    class TrustRootTemplate {
    }
    BYOKInstallTest --|> ClusterImagePolicyTemplate : uses
    BYOKInstallTest --|> PolicyControllerTemplate : uses
    BYOKInstallTest --|> TrustRootTemplate : uses
Loading

File-Level Changes

Change Details Files
Refactor common installation test to use shared utilities and constants
  • rename test constants and template path variables with a common prefix
  • replace hardcoded resource names and namespace with e2e_utils constants
  • unify ABS path variables and update render/apply calls to use new naming
  • update cleanup logic to use DeleteResource instead of DeleteManifest
  • adjust ExpectExists and InjectCA calls to reference e2e_utils constants
test/e2e/common_install_test.go
Add BYOK end-to-end test suite
  • introduce new byok_install_test.go with Ordered Ginkgo tests
  • define BYOK-specific template paths, test namespace, and env var
  • implement tests for resource creation, CA injection, TrustRoot and image policy application
  • add DeferCleanup logic to remove BYOK resources
test/e2e/byok_install_test.go
Extend e2e_utils library with new helper functions
  • add exponential backoff deletion in DeleteResource
  • implement Base64EncodeString and template nindent in common utils
  • remove obsolete DeleteManifest function
  • add image.go for PrepareImage using go-containerregistry
  • add rhtas.go for TUF root resolution, parsing, and RHTAS env handling
  • update cosign.go to include timestamp server (TSA) flags
test/e2e/utils/kubernetes.go
test/e2e/utils/common.go
test/e2e/utils/cosign.go
test/e2e/utils/rhtas.go
test/e2e/utils/image.go
Add BYOK custom resource templates
  • create trust_root.yaml.tpl defining TrustRoot spec for BYOK
  • create cluster_image_policy.yaml.tpl for BYOK image policy
  • create policy_controller.yaml.tpl for BYOK PolicyController CR
test/e2e/custom_resources/byok/trust_root.yaml.tpl
test/e2e/custom_resources/byok/cluster_image_policy.yaml.tpl
test/e2e/custom_resources/byok/policy_controller.yaml.tpl
Update dependencies and documentation
  • add github.com/google/go-containerregistry to go.mod and bump indirect deps
  • update go.sum accordingly
  • simplify README: remove manual test image build steps and update RHTAS env instructions
go.mod
go.sum
README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @JasonPowr - I've reviewed your changes - here's some feedback:

  • Extract shared setup and assertion logic between common_install_test.go and byok_install_test.go into reusable helper functions to reduce duplication.
  • Consider separating the new TUF/CA utilities (rhtas.go) and image preparation code (image.go) into dedicated subpackages for clearer organization.
  • DeleteResource only retries the GET after deletion—consider applying the same exponential‐backoff retry to the initial Delete call to handle transient errors.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Extract shared setup and assertion logic between common_install_test.go and byok_install_test.go into reusable helper functions to reduce duplication.
- Consider separating the new TUF/CA utilities (rhtas.go) and image preparation code (image.go) into dedicated subpackages for clearer organization.
- DeleteResource only retries the GET after deletion—consider applying the same exponential‐backoff retry to the initial Delete call to handle transient errors.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@JasonPowr

Copy link
Copy Markdown
Member Author

/retest

@osmman
osmman self-requested a review July 16, 2025 11:53
@osmman

osmman commented Jul 16, 2025

Copy link
Copy Markdown
Contributor

LGTM

@JasonPowr
JasonPowr merged commit 5c9b209 into main Jul 16, 2025
4 checks passed
@JasonPowr
JasonPowr deleted the e2e-test-byok branch July 16, 2025 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants