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

CP-40116 xapi-guard: Add unit tests #4813

Merged
merged 9 commits into from
Oct 26, 2022

Conversation

psafont
Copy link
Member

@psafont psafont commented Oct 7, 2022

These were developed in conjunction with a deprivileged interface to gather vtpm data, but it was dropped: #4670

I've removed that part of the tests and kept the rest, including an file descriptor leak test that found actually found one. The fix was included in the codebase months ago.

@psafont
Copy link
Member Author

psafont commented Oct 7, 2022

The FD leak test is noisy, there's probably some interference with dune and opam

@psafont
Copy link
Member Author

psafont commented Oct 7, 2022

I'm unable to reproduce the failure locally, neither with dune or opam nor without them:

$ opam exec -- dune runtest ocaml/xapi-guard/test/ -f --profile=release --no-buffer -j 12
$ _build/default/ocaml/xapi-guard/test/xapi_guard_test.exe -v

Copy link
Contributor

@lindig lindig left a comment

Choose a reason for hiding this comment

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

Nice to see code more concise and using the let*syntax.

avoid using up 100% CPU waiting for it,
better than Lwt.pause ()
*)
let* () = Lwt_unix.sleep 0.001 in
Copy link
Contributor

Choose a reason for hiding this comment

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

The wait is a lot shorter now. Is this just for Lwt scheduling?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is for getting the unit tests to pass quickly while still yielding the CPU to other tasks, see #4670 (comment)

@psafont psafont force-pushed the private/paus/guard-tests branch 5 times, most recently from d15b774 to e6921da Compare October 20, 2022 11:49
…esting

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
Check that basic API calls get forwarded

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
…e socket

This is the socket created by xapi-guard itself through Conduit,
but Conduit doesn't currently have an API to notify us when the socket
got created and listen()-ed on.
And we don't want to return too early to our caller
(the unit test or xenopsd) since they may get an ECONNREFUSED if they
try to connect too early.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
Instead of `foo () >>= fun result -> ...` use `let* result = foo () in ...`.
Instead of `foo () >|= fun result -> ...` use `let+ result = foo () in ...`.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
The test is commented out because under certain conditions which
couldn't be replicated at the end there are _less_ file descriptors that
at the beginning.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
@psafont psafont merged commit 1fd731c into xapi-project:master Oct 26, 2022
@psafont psafont deleted the private/paus/guard-tests branch October 26, 2022 13:34
@psafont psafont changed the title xapi-guard: Add unit tests CP-40116 xapi-guard: Add unit tests Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants