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

OCPVE-677: chore: refactor vgmanager into different interfaces and introduce tests #406

Conversation

jakobmoellerdev
Copy link
Contributor

@jakobmoellerdev jakobmoellerdev commented Sep 5, 2023

This refactors vgmanager by using a new different Interface: lvm.LVM encapsulates ALL lvm commands in the entire code and simultaneously enables unit testing.

This allows the mocking / replacement / redirection of these interfaces at will. Also there is a new suite_test.go with the accompanying test in pkg/vgmanager. The tests are powered by mockery, a configuration generator for mocks using testify. (used instead of gomock because gomock has been moved to uber and we already have testify so I didnt need to introduce new direct dependencies). The mock generation is configured via a central .mockery.yaml in the root of the repo.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Sep 5, 2023
@openshift-ci-robot
Copy link

openshift-ci-robot commented Sep 5, 2023

@jakobmoellerdev: This pull request references OCPVE-677 which is a valid jira issue.

In response to this:

This refactors vgmanager by using 3 new different Interfaces:

  1. lvm.LVM encapsulates ALL lvm commands in the entire code
  2. lsblk.LSBLK encapsulates ALL block device related commands in the entire code
  3. lvmd.LVMDConfig encapsulates the Read/Write/Delete for the lvmd config file.

This allows the mocking / replacement / redirection of these interfaces at will for testing. Also there is a new suite_test.go with the accompanying test in pkg/vgmanager which now tests vgmanager functionality natively in case the suite is run as root. If it is not run as root, the tests currently get skipped. We have to see if its feasible to run them within our existing pipelines. If its not feasible to run tests with root, we need to either give permissions to the host commands or we need to completely stub the local lvm implementation.

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.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 5, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 5, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 5, 2023
@jakobmoellerdev
Copy link
Contributor Author

/test all

@jakobmoellerdev
Copy link
Contributor Author

/test all

@openshift-ci-robot
Copy link

openshift-ci-robot commented Sep 5, 2023

@jakobmoellerdev: This pull request references OCPVE-677 which is a valid jira issue.

In response to this:

This refactors vgmanager by using 3 new different Interfaces:

  1. lvm.LVM encapsulates ALL lvm commands in the entire code
  2. lsblk.LSBLK encapsulates ALL block device related commands in the entire code
  3. lvmd.LVMDConfig encapsulates the Read/Write/Delete for the lvmd config file.

This allows the mocking / replacement / redirection of these interfaces at will for testing. Also there is a new suite_test.go with the accompanying test in pkg/vgmanager which now tests vgmanager functionality natively in case the suite is run as root. If it is not run as root, the tests currently get skipped. We have to see if its feasible to run them within our existing pipelines. If its not feasible to run tests with root, we need to either give permissions to the host commands or we need to completely stub the local lvm implementation.

NOTE: Requires #404 as the vg/pvremove command is necessary to be extended with lvmdevices --deldev by pid to have proper losetup device cleanup without orphaned devices.

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.

@jakobmoellerdev
Copy link
Contributor Author

/test all

@codecov-commenter
Copy link

codecov-commenter commented Sep 5, 2023

Codecov Report

Merging #406 (1221854) into main (d147fcb) will increase coverage by 0.76%.
The diff coverage is 12.14%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #406      +/-   ##
==========================================
+ Coverage   54.11%   54.87%   +0.76%     
==========================================
  Files          27       28       +1     
  Lines        2360     2657     +297     
==========================================
+ Hits         1277     1458     +181     
- Misses        997     1067      +70     
- Partials       86      132      +46     
Files Changed Coverage Δ
pkg/lvm/LVM_mock.go 0.00% <0.00%> (ø)
pkg/lvm/lvm.go 43.71% <33.89%> (+5.46%) ⬆️
pkg/vgmanager/vgmanager_controller.go 44.85% <45.16%> (+34.85%) ⬆️
pkg/vgmanager/devices.go 85.93% <57.14%> (+10.15%) ⬆️
pkg/filter/filter.go 62.74% <61.53%> (ø)
controllers/topolvm_node.go 95.14% <100.00%> (ø)
pkg/vgmanager/status.go 55.78% <100.00%> (+55.78%) ⬆️

@jakobmoellerdev jakobmoellerdev force-pushed the OCPVE-677-vgtesting-refactor branch 2 times, most recently from 1dbd4ff to 6f5fdd3 Compare September 5, 2023 16:57
@jakobmoellerdev
Copy link
Contributor Author

/test all

@jakobmoellerdev
Copy link
Contributor Author

/test lvm-operator-e2e-aws

@jakobmoellerdev
Copy link
Contributor Author

/test all

@jakobmoellerdev
Copy link
Contributor Author

/test all

@jakobmoellerdev
Copy link
Contributor Author

/test all

@jakobmoellerdev
Copy link
Contributor Author

/test all

@jakobmoellerdev
Copy link
Contributor Author

/test all

@jakobmoellerdev jakobmoellerdev force-pushed the OCPVE-677-vgtesting-refactor branch 2 times, most recently from bf60dc6 to 57ff80b Compare September 6, 2023 16:21
@jakobmoellerdev
Copy link
Contributor Author

/test all

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 7, 2023
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 7, 2023
@jakobmoellerdev
Copy link
Contributor Author

/test all

@jakobmoellerdev
Copy link
Contributor Author

/test all

1 similar comment
@jakobmoellerdev
Copy link
Contributor Author

/test all

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 9, 2023
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 11, 2023
@jakobmoellerdev jakobmoellerdev force-pushed the OCPVE-677-vgtesting-refactor branch 3 times, most recently from 11e556f to 1221854 Compare September 11, 2023 15:26
@jakobmoellerdev
Copy link
Contributor Author

/test all

@jakobmoellerdev jakobmoellerdev marked this pull request as ready for review September 11, 2023 15:50
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 11, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 11, 2023

@jakobmoellerdev: all tests passed!

Full PR test history. Your PR dashboard.

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-ci-robot
Copy link

openshift-ci-robot commented Sep 11, 2023

@jakobmoellerdev: This pull request references OCPVE-677 which is a valid jira issue.

In response to this:

This refactors vgmanager by using a new different Interface: lvm.LVM encapsulates ALL lvm commands in the entire code and simultaneously enables unit testing.

This allows the mocking / replacement / redirection of these interfaces at will. Also there is a new suite_test.go with the accompanying test in pkg/vgmanager. The tests are powered by mockery, a configuration generator for mocks using testify. (used instead of gomock because gomock has been moved to uber and we already have testify so I didnt need to introduce new direct dependencies). The mock generation is configured via a central .mockery.yaml in the root of the repo.

NOTE: Requires #404 as the vg/pvremove command is necessary to be extended with lvmdevices --deldev by pid to have proper losetup device cleanup without orphaned devices.

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.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Sep 11, 2023

@jakobmoellerdev: This pull request references OCPVE-677 which is a valid jira issue.

In response to this:

This refactors vgmanager by using a new different Interface: lvm.LVM encapsulates ALL lvm commands in the entire code and simultaneously enables unit testing.

This allows the mocking / replacement / redirection of these interfaces at will. Also there is a new suite_test.go with the accompanying test in pkg/vgmanager. The tests are powered by mockery, a configuration generator for mocks using testify. (used instead of gomock because gomock has been moved to uber and we already have testify so I didnt need to introduce new direct dependencies). The mock generation is configured via a central .mockery.yaml in the root of the repo.

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.

@suleymanakbas91
Copy link
Contributor

/lgtm
/approve

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 12, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 12, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jakobmoellerdev, suleymanakbas91

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

The pull request process is described here

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 12, 2023
@openshift-merge-robot openshift-merge-robot merged commit 99c6473 into openshift:main Sep 12, 2023
7 checks passed
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. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants