-
Notifications
You must be signed in to change notification settings - Fork 39.9k
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
Storage testsuite refactor & cleanup #96573
Conversation
/assign @chrishenzie @jingxu97 |
} | ||
|
||
// CreateVolumeSource creates a volume source object | ||
func CreateVolumeSource(pvcName string, readOnly bool) *v1.VolumeSource { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chrishenzie Replying to your concern on the CreateVolumeSource function. I think you are absolutely right. Ideally this function should be a private function in the api package. However, since previously it is under testsuite package so it has been abused by provisioning testsuite:
Volume: *createVolumeSource(claim.Name, false /* readOnly */), |
So definitely if we fix provisioning testsuite to not use this, I can put it under storageapi and make it unexported. One thing I noticed when doing this refactor is that a lot of functions have been abused. This PR has been too large to also include those cleanup. So I think it would be good to focus on move the package first. And then we can do clean up for each individual testsuite to make it clean. Does that make sense?
} | ||
|
||
// TODO: put this under e2epod once https://github.com/kubernetes/kubernetes/issues/81245 | ||
// is resolved. Otherwise there will be dependency issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chrishenzie Replying to your concern on this function:
There are two possible location I think this function could lie in other than this:
-
test/e2e/storage/utils/pod.go
The problem with that is this function is being used by "VerifyExecInPodSucceed" and "VerifyExecInPodFail" which are used by "CheckVolumeModeOfPath".
And this "CheckVolumeModeOfPath" is used by e2evolume. So ideally we dont want to put them under storage utils because that will have a situation where parent package import subpackage. This against our principle. -
test/e2e/framework/pod
This is a better place for sure. However, currently there is a dependency issue Core e2e test framework should not import sub e2e test frameworks #81245 which prevent us from putting it there. So I add a comment to this. Once that is fixed we can move it over.
test/e2e/storage/api/testsuite.go
Outdated
} | ||
|
||
// 2. Check if fsType is supported | ||
if !dInfo.SupportedFsType.Has(pattern.FsType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replying to @jingxu97 question on #96538 (comment)
When we define an external driver, and e2e framework reads from the config file, it will always add "" so that makes sure it support default fsType
driver := &driverDefinition{ |
@jingxu97 @chrishenzie Sorry for making so many different PRs. I think there are indeed a lot of things we can improve in the current testsuite package. I want to keep this PR as simple as I can but apparently this is the best I can, lol. So I think it would be good to focus on extracting api things to a new library in this PR. If there is any other changes not related to that, I will keep those in mind or create an issue if necessary and I will submit separate PR for them. This PR does not have any functional change or code logic change. It is pure code refactor so the code for each testsuite that being executed should be the same. The goal is to make the code looks cleaner. If there is anything related to that you think we can change, please point them out and I will fix them. Thanks! |
} | ||
} | ||
} | ||
|
||
// VerifyFSGroupInPod verifies that the passed in filePath contains the expectedFSGroup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how to decide which function goes to utils, and which one goes to e2evolume?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The principles I am using here are:
- If this function has only been called by e2e/storage/..., it should go to e2e/storage/utils, because no other component is using it so lets just keep it at the lowest level
- If there is any function that has been called outside of storage, it should go to a more general location namely e2evolume or e2epod.
In addition to this, dependency management here is that subpackage can import corepackage, but core cannot import sub.
That being said, previously e2evolume import e2e/storage/utils which is not the right direction. So I move these function up to the e2evolume to clear the dependency.
I think this direction of dependency also align with another effort from sig testing. Does this make sense?
@@ -696,3 +697,71 @@ func GetLinuxLabel() *v1.SELinuxOptions { | |||
return &v1.SELinuxOptions{ | |||
Level: "s0:c0,c1"} | |||
} | |||
|
|||
// CheckVolumeModeOfPath check mode of volume | |||
func CheckVolumeModeOfPath(f *framework.Framework, pod *v1.Pod, volMode v1.PersistentVolumeMode, path string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any other tests using this besides storage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, CheckVolumeModeOfPath is used by testVolumeContent in e2evolume and testVolumeContent is used by TestVolumeClient(), TestVolumeClient is used by e2e/common
https://github.com/kubernetes/kubernetes/search?q=TestVolumeClient
Hmm, maybe I can move everything related to it down and clear the dependency for everything uses TestVolumeClient. I will create a commit for that change to see if that makes the dependency look better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tried... It is too much change, almost move everything in e2evolume to storageutils.
The code has reference almost in all the function in e2evolume. I think let's make the dependency change in the next PR. And focus this PR on just restructure the testsuite. The utils definitely need some effort to clean up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, then I am ok with this PR.
/retest |
lgtm, |
26cf6d2
to
5ffe59c
Compare
@msau42 @xing-yang |
// CreateSnapshot creates a VolumeSnapshotClass with given SnapshotDeletionPolicy and a VolumeSnapshot | ||
// from the VolumeSnapshotClass using a dynamic client. | ||
// Returns the unstructured VolumeSnapshotClass and VolumeSnapshot objects. | ||
func CreateSnapshot(sDriver SnapshottableTestDriver, config *PerTestConfig, pattern TestPattern, pvcName string, pvcNamespace string, timeouts *framework.TimeoutContext) (*unstructured.Unstructured, *unstructured.Unstructured) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me, this seems more of a util compared to the testsuite framework because it's helpers for specific tests. What is your method for distinction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are right, I need to move this to util
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubled check on this and find it is not easy to do so because this function as you can tell from the signature:
func CreateSnapshot(sDriver SnapshottableTestDriver, config *PerTestConfig, pattern TestPattern, pvcName string, pvcNamespace string, timeouts *framework.TimeoutContext)
It has a lot of dependency of storage framework(SnapshottableTestDriver, PerTestConfig, TestPattern). That being said, it cannot be moved to storageutils. From my understanding, storageutils should be self-encapsulated. The dependency direction is framework can depend on storageutils while storageutils cannot depend on framework...
I feel like there are a lot of code refactor we can do around the utils for the testsuites. But I think this can be our first step towards that. Let's make this in and then we can babystep the utils refactor and cleanup slowly.
Cleanup all the f.BeforeEach() before new framework to move all the testskips in the new SkipUnsupportedTests() to make the structure easier. And provide the standard way of RegisterTests() Add a InitCustomXXXTestSuite(patterns []patterns) function for each TestSuite to enable custom test suite definition.
Extract TestSuite, TestDriver, TestPattern, TestConfig and VolumeResource, SnapshotVolumeResource from testsuite package and put them into a new package called api. The ultimate goal here is to make the testsuites as clean as possible. And only testsuites in the package.
/lgtm Thanks! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Jiawei0227, msau42 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 |
/retest |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Right now there are too many different things in the testsuite package which makes it really hard to read and understand.
This PR is to code refactor the
test/e2e/storage/testsuite
package to extract all the public type definition out and move to a new package calledtest/e2e/storage/api
. The ultimate goal here is to keep the testsuite package as clean and easy to extend as possible. And also isolate the type definition so that we can make the testsuite pkg no different than a third party package. This also makes sure a third party user is easy to use these code and write their own testsuite.testskips in the new SkipUnsupportedTests() to make the structure easier.
And provide the standard way of RegisterTests()
TestSuite to enable custom test suite definition.
and VolumeResource, SnapshotVolumeResource from testsuite
package and put them into a new package called api.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
This is a first step to the testsuite cleanup. We will need to reduce redundant code after this and make sure the utility we write is not building the same wheel again and again.
Does this PR introduce a user-facing change?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
/sig storage
/sig testing