Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(unit) test for export functionality #3138

Open
acpana opened this issue Nov 8, 2024 · 0 comments
Open

(unit) test for export functionality #3138

acpana opened this issue Nov 8, 2024 · 0 comments

Comments

@acpana
Copy link
Collaborator

acpana commented Nov 8, 2024

Overview

How can we tell that an exported k8s object is correct? For instance:

apiVersion: cloudbuild.cnrm.cloud.google.com/v1beta1
kind: CloudBuildWorkerPool
metadata:
name: projects-${projectNumber}-locations-us-central1-workerpools-cloudbuildworkerpool-${uniqueId}
spec:
displayName: Updated CloudBuild WorkerPool
location: us-central1
privatePoolV1Config:
networkConfig:
egressOption: PUBLIC_EGRESS
peeredNetworkIPRange: /29
peeredNetworkRef:
external: projects/${projectNumber}/global/networks/computenetwork-${uniqueId}
workerConfig:
diskSizeGb: 150
machineType: e2-highmem-4
projectRef:
external: //cloudbuild.googleapis.com/projects/${projectId}/locations/us-central1/workerPools/cloudbuildworkerpool-${uniqueId}

The best bet we have today is to check the Spec field against the golden object's Spec:

spec:
displayName: Updated CloudBuild WorkerPool
location: us-central1
privatePoolV1Config:
networkConfig:
egressOption: PUBLIC_EGRESS
peeredNetworkIPRange: /29
peeredNetworkRef:
external: projects/${projectId}/global/networks/computenetwork-${uniqueId}
workerConfig:
diskSizeGb: 150
machineType: e2-highmem-4
projectRef:
external: projects/${projectId}

Possible solution

Unit test approach

  • Since both of those files are both "golden" files they can be statically analyzed after the fact with a unit test. This can be parallelized and could be pretty fast.

At e2e runtime check

  • We could also add a check in the unified_test for this need but we can probably get more value out of the unit test approach.
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

No branches or pull requests

1 participant