-
Notifications
You must be signed in to change notification settings - Fork 7
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
introduce dell adaptor tests based on a fake dell server #24
Conversation
432e12f
to
66dff7e
Compare
/hold We might want to merge Tao's MR first and update this one with new manifests structure |
66dff7e
to
dbb986f
Compare
I would recommend using |
Please add a Makefile target for generating the test server code. I would also recommend putting it in a |
We should also be able to edit the |
Similarly, please rename |
dbb986f
to
86829aa
Compare
86829aa
to
f1ed155
Compare
Thanks for the feedback, @donpenney Comments about my new push below.
Done
I am only re-using your The reason is that the server generated code (the http dispatch infra) does not favour our intend to mock the dispatch functions dynamically on a test basis, as I am doing for our tests: here and here . I believe I am able to provide a better customisation on the http side instead, based on Note that my muxinfra is pretty standard golang code leveraging mux, and orthogonal to openapi changes, so I am expecting not to change this for any reason. Otoh, if we need to update our openapi spec, on the pure server side code I am only expecting to update this routes function when updating endpoints for the corresponding test.
Have not done it so far but we might simply add the
Done
Done |
/unhold |
"github.com/gorilla/mux" | ||
"log" | ||
"net/http" | ||
"time" |
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.
golangci-lint wants the system imports first, with external imports separated
"github.com/gorilla/mux" | |
"log" | |
"net/http" | |
"time" | |
"log" | |
"net/http" | |
"time" | |
"github.com/gorilla/mux" |
@donpenney , see this new commit added: No new functionality, two improvements added:
|
5f994c9
to
783149d
Compare
|
||
// fetch required CRD | ||
crdPath := filepath.Join(tmpDir, crdRepoName) | ||
err := crds.GetRequiredCrdsFromGit(crdRepo, crdPath) |
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.
Is this just getting the main/latest content? The go.mod locks us to a specific version of the APIs from oran-o2ims. We'd need to do the same here, to ensure that the CRD structure aligns with what's expected by the plugin code.
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.
Yes, it is getting the latest. How do we take the decision to update to a specific oran-o2ims api from the code perspective ?
From the testing side, using this git mechanism, we are no more granular than a branch. I am guessing we are not going have a git tag to sync to either. Not sure if can derive the associated CRD file then: go.mod version --> crd file
If we just need a branch as a parameter, it is pretty straightforward; we will just need to update this file on a release branch basis (release-4.18, release-4.19, ...)
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.
This has been addressed as part of the new changes, see the README: Testing dependencies and the new code in utils.go
ctx, cancel = context.WithCancel( | ||
context.Background()) | ||
err := server.Shutdown(ctx) | ||
Expect(err).NotTo(HaveOccurred(), "failed to stop dell server") |
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.
Expect(err).NotTo(HaveOccurred(), "failed to stop dell server") | |
Expect(err).NotTo(HaveOccurred(), "failed to stop test server") |
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
b1c1a15
to
ab9a828
Compare
Please fix remaining linter warnings |
test/adaptors/crds/crds.go
Outdated
|
||
// GetRequiredCRDsFromGit clones an oran-o2ims repo in a specific path and checks out a specific commit | ||
// to fetch required CRDs from there | ||
func GetRequiredCRDsFromGit(crdRepo string, commit string, crdPath string) error { |
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.
func GetRequiredCRDsFromGit(crdRepo string, commit string, crdPath string) error { | |
func GetRequiredCRDsFromGit(crdRepo, commit, crdPath string) error { |
test/adaptors/crds/crds.go
Outdated
backoff := retry.NewFibonacci(1 * time.Second) | ||
err := retry.Do(ctx, retry.WithMaxRetries(retries, backoff), cloneFn) | ||
if err != nil { | ||
return fmt.Errorf("failed to clone repo:%s, err:%v", crdRepo, err) |
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.
return fmt.Errorf("failed to clone repo:%s, err:%v", crdRepo, err) | |
return fmt.Errorf("failed to clone repo:%s, err:%w", crdRepo, err) |
test/adaptors/crds/crds.go
Outdated
// checkout the specific commit | ||
w, err := r.Worktree() | ||
if err != nil { | ||
return fmt.Errorf("failed to get git worktree repo:%s, err:%v", crdRepo, err) |
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.
return fmt.Errorf("failed to get git worktree repo:%s, err:%v", crdRepo, err) | |
return fmt.Errorf("failed to get git worktree repo:%s, err:%w", crdRepo, err) |
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
A minor refactor of the existing loopback tests has been peformed too
ab9a828
to
c7a158a
Compare
Thanks once again, @donpenney . Regarding the linter comments, I have had some issues because of the linter tool already included. Cc'ed you over here: https://redhat-internal.slack.com/archives/C07A9NFCS01/p1732707795237589 |
@rauhersu: The following tests failed, say
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-sigs/prow repository. I understand the commands that are listed here. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: donpenney 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 |
This is a follow-up of the previous loopback plugin effort to increase our test coverage for the plugins initiated with this PR.
Now, this PR targets the dell plugin and as a consequence, a minor refactor of the previous loopback test (mainly dir structure and renaming) has been performed too.
All these new tests are run executing
make test
from the project rootNotes for the reviewers
2.1 - The
loopback-plg
dir contains the existing tests for the loopback plugin.2.2 - The
dell-plg
dir contains the new test code, targeting the dell plugin.2.3 - The
assets
dir contains new manifests needed by the dell plugin for the new testing scenario. It contains 'common logic' used by both plugins.2.4 - The
dell-server
dir contains code generated on parsing the Dell swagger (drop2) specification, tweaked by @donpenneyThis PR is only focused on a rest scenario for the dell plugin, specifically the authentication token request to the dell server, but this dell test suite has been designed to be scalable and might test the whole rest flow plus a complete reconciliation if no architectural constraint prevents it (i.e: a real cluster is needed).
Technicalities
3.1 - Envtest is used to setup a minimal control plane. No cluster is needed.
3.2 - A goroutine is triggered to start up the fake dell server while the test is run in the main one - here -
3.3 - The fake dell server exposes all API routes - here - but only the 'get token' scenario is under test so far - here - . Posterior MRs might cover the whole API. Also, every response is mocked to test the Dell plugin behaviour on a test basis.
Other
4.1 - While writing this I have just noticed we need to update our manifests according to Tao's latest changes: CNF-15609: Enhance Loopback Plugin for Node Pool Configuration Changes #23 we might hold this PR to merge that before and update this PR accordingly.
4.2 - @donpenney , I see a lot of 'errors' indicated by the linter (wrapcheck) for the generated code (from the swagger file)
4.3 - It might be interesting to test this 'get token' scenario provisioning the configmap with a cabundle; so far I have not included this.