Skip to content

(unit) test for export functionality #3138

Open
@acpana

Description

@acpana

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions