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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃尡 added tests for loadTLSConfigFromEnv in factory_test.go #1589

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

danish9039
Copy link
Contributor

@danish9039 danish9039 commented Mar 4, 2024

This commit introduces a set of comprehensive tests for the in theloadingTLSconfiguration in"factory_test.go" file of the ironic package. The tests cover various scenarios and edge cases related to loading configuration from environment variables, handling endpoints, and loading TLSconfiguration.

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
part of #1574

@metal3-io-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kashifest for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@metal3-io-bot metal3-io-bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 4, 2024
@metal3-io-bot
Copy link
Contributor

Hi @danish9039. Thanks for your PR.

I'm waiting for a metal3-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@metal3-io-bot metal3-io-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 4, 2024
@tuminoid
Copy link
Member

tuminoid commented Mar 5, 2024

Please sign-off your commit to fulfill DCO requirement.

/ok-to-test

@metal3-io-bot metal3-io-bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 5, 2024
@lentzi90
Copy link
Member

lentzi90 commented Mar 5, 2024

Thanks for the PR!
You will need to fix the test failures. Try running make lint to see the issues in your environment also.

@metal3-io-bot metal3-io-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 5, 2024
danish9039 and others added 3 commits March 6, 2024 01:04
This commit introduces a set of comprehensive tests for the factory functions in the "factory_test.go" file of the ironic package. The tests cover various scenarios and edge cases related to loading configuration from environment variables, handling endpoints, and loading TLS configuration.

Signed-off-by: danish siddiqui <danishsiddiqui040@gmail.com>
Signed-off-by: danish siddiqui <danishsiddiqui040@gmail.com>
Signed-off-by: danish siddiqui <danishsiddiqui040@gmail.com>
@lentzi90
Copy link
Member

lentzi90 commented Mar 6, 2024

Could you update the description so it says "Part of #1574" instead of "Fixes", since the issue has multiple parts?

@danish9039
Copy link
Contributor Author

Could you update the description so it says "Part of #1574" instead of "Fixes", since the issue has multiple parts?

sure

@@ -181,35 +181,78 @@ func TestLoadConfigFromEnv(t *testing.T) {
}
}

func TestLoadEndpointsFromEnv(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Do I understand correctly that you removed this test? Why?
I think we should keep it and add a separate test for the TLS config.

Comment on lines +190 to +201
os.Setenv("IRONIC_CACERT_FILE", "/path/to/ca.crt")
os.Setenv("IRONIC_CLIENT_CERT_FILE", "/path/to/client.crt")
os.Setenv("IRONIC_CLIENT_PRIVATE_KEY_FILE", "/path/to/client.key")
os.Setenv("IRONIC_INSECURE", "false")
os.Setenv("IRONIC_SKIP_CLIENT_SAN_VERIFY", "true")
defer func() {
os.Unsetenv("IRONIC_CACERT_FILE")
os.Unsetenv("IRONIC_CLIENT_CERT_FILE")
os.Unsetenv("IRONIC_CLIENT_PRIVATE_KEY_FILE")
os.Unsetenv("IRONIC_INSECURE")
os.Unsetenv("IRONIC_SKIP_CLIENT_SAN_VERIFY")
}()
Copy link
Member

Choose a reason for hiding this comment

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

If you check the other tests in this file, you will see that they make use of a struct EnvFixture. There are helpful functions for setting and unsetting the environment from this struct. Put all of this together and you get a nice way of looping through test cases described by structs. Could you try to mimic this?

Signed-off-by: danish siddiqui <danishsiddiqui040@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants