Skip to content

test(backend): increase apiserver/template test coverage to 64.5%#13203

Merged
google-oss-prow[bot] merged 1 commit intokubeflow:masterfrom
jsonmp-k8:test/apiserver-template-coverage
Apr 7, 2026
Merged

test(backend): increase apiserver/template test coverage to 64.5%#13203
google-oss-prow[bot] merged 1 commit intokubeflow:masterfrom
jsonmp-k8:test/apiserver-template-coverage

Conversation

@jsonmp-k8
Copy link
Copy Markdown
Contributor

@jsonmp-k8 jsonmp-k8 commented Apr 3, 2026

Summary

  • Add unit tests for 40+ untested functions/methods in backend/src/apiserver/template/
  • Covers helper functions (modelToPipelineJobRuntimeConfig, StringMapToCRDParameters, stringArrayToCRDParameters, modelToParametersMap), trigger conversion (modelToCRDTrigger periodic path), service account defaults, Argo/V2Spec constructors, and all simple Template interface methods including nil-receiver safety
  • Comprehensive validatePipelineJobInputs coverage: all parameter types (STRING, NUMBER_DOUBLE, BOOLEAN, LIST, STRUCT), error paths (UNSPECIFIED, TASK_FINAL_STATUS), optional params, extra params, missing required params
  • No production code changes

Coverage: 40.1% → 64.5% (+24.4%)

Test plan

  • go test -v -cover ./backend/src/apiserver/template/ — all tests pass, 64.5% coverage
  • golangci-lint run --new --new-from-merge-base=origin/master — 0 issues
  • gofmt applied

Copilot AI review requested due to automatic review settings April 3, 2026 06:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds comprehensive unit tests for 30+ previously untested functions and methods in the backend/src/apiserver/template/ package, significantly increasing test coverage from 40.1% to 61.9%. The tests include coverage for helper functions, trigger conversion, service account configuration, V2 pipeline job input validation, template constructors, and all simple Template interface methods including nil-receiver safety checks.

Changes:

  • Added structpb import for protobuf value construction in tests
  • Added 446 lines of well-structured unit tests covering helper functions, template constructors, Template interface methods, nil-receiver safety, and validation logic
  • Tests cover both happy paths and error conditions with meaningful assertions

@jsonmp-k8
Copy link
Copy Markdown
Contributor Author

/ok-to-test

@jsonmp-k8 jsonmp-k8 force-pushed the test/apiserver-template-coverage branch from f1ec8a5 to 19eb4ac Compare April 3, 2026 06:19
@google-oss-prow google-oss-prow bot added size/XL and removed size/L labels Apr 3, 2026
@github-actions github-actions bot added the ci-passed All CI tests on a pull request have passed label Apr 3, 2026
@jsonmp-k8 jsonmp-k8 changed the title test(backend): increase apiserver/template test coverage to 61.9% test(backend): increase apiserver/template test coverage to 64.5% Apr 3, 2026
@jsonmp-k8
Copy link
Copy Markdown
Contributor Author

jsonmp-k8 commented Apr 7, 2026

/retest

2 similar comments
@jsonmp-k8
Copy link
Copy Markdown
Contributor Author

/retest

@jeffspahr
Copy link
Copy Markdown
Contributor

/retest

Copy link
Copy Markdown
Contributor

@jeffspahr jeffspahr left a comment

Choose a reason for hiding this comment

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

Reviewed the added coverage in backend/src/apiserver/template/template_test.go and found no blocking issues.

Verification:

  • go test -v -cover ./backend/src/apiserver/template/...\n- go test -shuffle=on ./backend/src/apiserver/template

Both passed locally. I could not rerun golangci-lint in this environment because golangci-lint is not installed here.

@jeffspahr
Copy link
Copy Markdown
Contributor

/retest

@jeffspahr
Copy link
Copy Markdown
Contributor

/lgtm

@jsonmp-k8
Copy link
Copy Markdown
Contributor Author

/retest

…o 61.9%

Add unit tests for untested functions in the template package:
- modelToPipelineJobRuntimeConfig: nil, empty, valid, and invalid JSON
- StringMapToCRDParameters: empty, valid map, invalid JSON
- stringArrayToCRDParameters: empty, valid array, invalid JSON
- modelToParametersMap: empty, valid, invalid JSON
- modelToCRDTrigger: periodic schedule and empty trigger paths
- setDefaultServiceAccount: explicit and fallback-to-config paths
- validatePipelineJobInputs: missing inputs, correct type, wrong type,
  extra params
- NewArgoTemplate/NewArgoTemplateFromWorkflow constructors
- Argo method coverage: GetTemplateType, Bytes, IsV2, V2PipelineName,
  OverrideV2PipelineName, ParametersJSON, IsCacheDisabled, nil receivers
- V2Spec method coverage: GetTemplateType, IsV2, V2PipelineName,
  OverrideV2PipelineName, ParametersJSON, IsCacheDisabled, PipelineSpec,
  PlatformSpec, Bytes, nil receivers
- NewV2SpecTemplate validation: empty input, invalid YAML
- NewGenericScheduledWorkflow: full field verification
- AddRuntimeMetadata: annotation and label checks
- New factory: unknown format error path

Signed-off-by: Jaison Paul <paul.jaison@gmail.com>
@jsonmp-k8 jsonmp-k8 force-pushed the test/apiserver-template-coverage branch from 19eb4ac to 1fdc3d2 Compare April 7, 2026 03:14
@google-oss-prow google-oss-prow bot removed the lgtm label Apr 7, 2026
@github-actions github-actions bot added ci-passed All CI tests on a pull request have passed and removed ci-passed All CI tests on a pull request have passed labels Apr 7, 2026
@jeffspahr
Copy link
Copy Markdown
Contributor

/lgtm

@google-oss-prow google-oss-prow bot added the lgtm label Apr 7, 2026
Copy link
Copy Markdown
Contributor

@hbelmiro hbelmiro left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@google-oss-prow
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hbelmiro

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow bot merged commit 392ad84 into kubeflow:master Apr 7, 2026
172 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved ci-passed All CI tests on a pull request have passed lgtm ok-to-test size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants