Skip to content

OTA-1159: [1/x] Refactor syncStatus for testability#1031

Merged
openshift-merge-bot[bot] merged 4 commits intoopenshift:masterfrom
petr-muller:ota-1159-refactor-syncStatus-for-testability
Jan 31, 2024
Merged

OTA-1159: [1/x] Refactor syncStatus for testability#1031
openshift-merge-bot[bot] merged 4 commits intoopenshift:masterfrom
petr-muller:ota-1159-refactor-syncStatus-for-testability

Conversation

@petr-muller
Copy link
Copy Markdown
Member

updateClusterVersionStatus: add godoc and linewrap signature


status: work with ClusterVersionStatus instead of ClusterVersion

Status-computing methods can only read and modify ClusterVersionStatus
instead of ClusterVersion, resulting in simpler code and lower chance
of making a mistake.


status: uncouple updateClusterVersionStatus with Operator

Operator is a pretty beefy object with access to half of the universe, but updateClusterVersionStatus only uses its member very little. It reads its release member and calls its getAvailableUpdates method.

We can uncouple the long method by passing these two members as parameters. It is slightly awkward for the getAvailableUpdates method but I think the benefits outweight this.


status: extract status update logic to method

I would like to unit-test this logic but syncStatus does API operation so such tests would need a fake. Computing new status is enough logic to constitute a method, so we can extract it so that we can test it without a mock server.

Extracted with an IDE refactor helper.

I would like to unit-test this logic but `syncStatus` does apiserver
operation so such tests would need a fake. Computing new status is
enough logic to constitute a method, so we can extract it so that we
can test it without a mock server.

Extracted with an IDE refactor helper.
`Operator` is a pretty beefy object with access to half of the universe,
but `updateClusterVersionStatus` only uses its member very little. It
reads its `release` member and calls its `getAvailableUpdates` method.

We can uncouple the long method by passing these two members as
parameters. It is slightly awkward for the `getAvailableUpdates` method
but I think the benefits outweight this.
Status-computing methods can only read and modify `ClusterVersionStatus`
instead of `ClusterVersion`, resulting in simpler code and lower chance
of making a mistake.
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jan 30, 2024
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

openshift-ci-robot commented Jan 30, 2024

@petr-muller: This pull request references OTA-1159 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.16.0" version, but no target version was set.

Details

In response to this:

updateClusterVersionStatus: add godoc and linewrap signature


status: work with ClusterVersionStatus instead of ClusterVersion

Status-computing methods can only read and modify ClusterVersionStatus
instead of ClusterVersion, resulting in simpler code and lower chance
of making a mistake.


status: uncouple updateClusterVersionStatus with Operator

Operator is a pretty beefy object with access to half of the universe, but updateClusterVersionStatus only uses its member very little. It reads its release member and calls its getAvailableUpdates method.

We can uncouple the long method by passing these two members as parameters. It is slightly awkward for the getAvailableUpdates method but I think the benefits outweight this.


status: extract status update logic to method

I would like to unit-test this logic but syncStatus does API operation so such tests would need a fake. Computing new status is enough logic to constitute a method, so we can extract it so that we can test it without a mock server.

Extracted with an IDE refactor helper.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 30, 2024
Copy link
Copy Markdown
Member

@wking wking left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jan 30, 2024
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Jan 30, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: petr-muller, wking

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

@petr-muller
Copy link
Copy Markdown
Member Author

/retest
/label no-qe

No pre-merge testing necessary, will get solid amount of testing after merge

@openshift-ci openshift-ci Bot added the no-qe Allows PRs to merge without qe-approved label label Jan 31, 2024
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Jan 31, 2024

@petr-muller: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot Bot merged commit ce6169c into openshift:master Jan 31, 2024
@petr-muller petr-muller deleted the ota-1159-refactor-syncStatus-for-testability branch January 31, 2024 16:31
@openshift-bot
Copy link
Copy Markdown
Contributor

[ART PR BUILD NOTIFIER]

This PR has been included in build cluster-version-operator-container-v4.16.0-202401311812.p0.gce6169c.assembly.stream for distgit cluster-version-operator.
All builds following this will include this PR.

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. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. no-qe Allows PRs to merge without qe-approved label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants