-
Notifications
You must be signed in to change notification settings - Fork 18
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
Make it easy to run a single test #178
base: main
Are you sure you want to change the base?
Make it easy to run a single test #178
Conversation
1dd9ce4
to
7450989
Compare
Isn't only second commit is enough for the required behavior, assuming the behavior is to have operator namespace to be set? First commit just delays the initialization w/o any functionality change, isn't it? |
Good question. If I run the test with just the commit that sets the env var then I see this error:
The reason is that these variables were being assigned at the global scope by calling a function.
This makes these function calls part of the Go Init() process. The setting of env var in suite_test.go would be run after the Init() process but that would be too late as this function panics on not finding the env var set. |
@@ -66,6 +67,11 @@ var _ = BeforeSuite(func() { | |||
fmt.Sprintf("1.29.0-%s-%s", runtime.GOOS, runtime.GOARCH)), | |||
} | |||
|
|||
_, set := os.LookupEnv("OPERATOR_NAMESPACE") | |||
if !set { | |||
Expect(os.Setenv("OPERATOR_NAMESPACE", "ceph-csi-operator-system")).To(Succeed()) |
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.
in the AfterSuit lets unset this env if we are setting it
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.
Done
7450989
to
d64c66a
Compare
internal/controller/defaults.go
Outdated
) | ||
|
||
func InitConfig() { | ||
if operatorNamespace := os.Getenv("OPERATOR_NAMESPACE"); operatorNamespace == "" { |
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.
Isn't the walrus shawdowing global operatorNamespace var here? Similar for others as well.
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.
Fixed, thanks!
Possible to hold off the merge till tomorrow? pls excuse I missed checking this today. The approach isn't sitting well w/ me for a couple of reasons, BTW open to be corrected.
|
Yes, I am in no hurry to get this merged. I will reply with examples to answer the above questions. |
Looked again, the fix introduces a bug in both test & runtime environments which I already left a comment. I couldn't find any simpler alternatives, I don't use the feature (vscode & ginkgo) which requires this fix and leave the decision to maintainers. BTW, see if |
d64c66a
to
f67324d
Compare
This is not true. Just importing the controllers package in main.go wasn't enough even before. The SetupWithManager() has to be invoked for every controller in the package, which are 3 at this time, ClientProfileMappingReconciler, ClientProfileReconciler, and DriverReconciler.
I don't understand which requirement is amended here? |
5fc229d
to
576e374
Compare
This will make it easier to setup the test framework with a different config when required. If the configuration is built in the global init of the controller then it can not be skipped. Signed-off-by: Raghavendra Talur <[email protected]>
This allows one to run the a specific test using the ginkgo cli or by using the vscode test decorators. For example: ``` $ ginkgo -focus "ClientProfile Controller" -r [1732083376] Controller Suite - 1/3 specs SS• SUCCESS! 5.797831s PASS Starting ceph-csi-operator suite [1732083376] e2e suite - 0/1 specs S SUCCESS! 59.25µs PASS Ginkgo ran 2 suites in 10.605577042s Test Suite Passed ``` Signed-off-by: Raghavendra Talur <[email protected]>
576e374
to
74c2c6e
Compare
Ok, the tests have passed but now I agree with @leelavg that it is starting to look like a big change for a project which I am not the maintainer. @nb-ohad @Madhu-1 I will leave it up to you to merge or close the PR. Ginkgo and VSCode both provide users a way to specify an env var file and that is one alternative option for the users. |
having said that, I acknowledge the usage of global vars which might be used in more than one place is problematic in existing code and I feel proposed fix isn't easing it much. |
@raghavendra-talur we are reworking on the new framework for the testing, Lets keep this PR open for sometime and we can see if we can get this in or we need any additional changes later on. |
Describe what this PR does
This PR moves the config init code to the main function from the global init. Doing so, it allows for such config init to be skipped for tests or other scenarios.
In the second commit, we set the os environment variable for the operator namespace in the BeforeSuite() function if it is not already set. This allows users to run a specific test by using the ginkgo cli or by using the test decorators in vscode.
For example:
Provide some context for the reviewer
Is there anything that requires special attention
Earlier, the configuration was automatically inited. Now, it is being done manually in the main function.
Is the change backward compatible?
Yes
Are there concerns around backward compatibility?
No
Checklist:
guidelines in the developer
guide.
Request
notes
updated with breaking and/or notable changes for the next major release.