Skip to content

Conversation

@twoGiants
Copy link
Member

Changes

Create pkg/reconciler/testing/status.go and move status related helper functions for TaskRun/CustomRun and later PipelineRun there. Remove duplication from helper functions.

Move yaml parsing helper functions to test/parse/yaml.go.

Rename import ttesting ==> th, short for "testing helpers".

Issue #8760, #7166.

/kind cleanup

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • pre-commit Passed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

NONE

@tekton-robot tekton-robot added release-note-none Denotes a PR that doesnt merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 27, 2025
@tekton-robot tekton-robot requested review from abayer and afrittoli June 27, 2025 14:59
Create `pkg/reconciler/testing/status.go` and move status related
helper functions for `TaskRun/CustomRun` and later `PipelineRun` there.
Remove duplication from helper functions.

Move yaml parsing helper functions to `test/parse/yaml.go`.

Rename import `ttesting ==> th`, short for "testing helpers".

Issue tektoncd#8760, tektoncd#7166.

Signed-off-by: Stanislav Jakuschevskij <[email protected]>
@twoGiants twoGiants force-pushed the issue-8760-tep-0056-refactor-tests-extract-status-checks-and-yaml-parsing branch from ee7adb9 to 0fa2316 Compare June 27, 2025 15:01
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/testing/status.go Do not exist 0.0%

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/testing/status.go Do not exist 0.0%

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

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

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 30, 2025
Copy link
Member

@afrittoli afrittoli left a comment

Choose a reason for hiding this comment

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

Thanks @twoGiants - is the idea that these functions will be used elsewhere in testing as well, e.g. for pip testing?
/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 30, 2025
@tekton-robot tekton-robot merged commit 18736c3 into tektoncd:main Jun 30, 2025
20 checks passed
@twoGiants
Copy link
Member Author

Thanks @twoGiants - is the idea that these functions will be used elsewhere in testing as well, e.g. for pip testing?

@afrittoli they are already, see here. I extracted them into the new file and extend them with pip related helpers here in my working branch. I want to avoid bloating pipelinerun_test.go anymore which has 19k lines of code and contains different types of tests and helpers.

I started to put the pip tests which are not part of a table driven test cases in existing test functions in their own file here. This file will grow when more functionality (Params, Timeouts, Results, ...) will be implemented.

I think that is how pipelinerun_test.go could actually be refactored:

  • pipelinerun_pinp_test.go
  • pipelinerun_task_test.go
  • pipelinerun_customtask_test.go
  • maybe pipelinerun_test.go with stuff which does not belong to any of the three or applies to all of them, not sure yet
  • and the shared test framework in pkg/reconciler/testing
    • configmap.go
    • factory.go => mock data creation
    • status.go
    • fakecontroller.go => test env setup and reconcileOnce / reconcileWithError functions
    • validators.go
    • selectors.go => getTaskRunByName, getTaskRunsForPipelineRun, ...
    • ... probably more

Even without refactoring the actual helpers/tests much, this will reduce the cognitive load in the tests by an order of magnitude. Working in this giant pipelinerun_test.go test file turned out as the most difficult part so far.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesnt merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants