-
Notifications
You must be signed in to change notification settings - Fork 285
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
Xapi thread classification - part 2 #6154
Open
GabrielBuica
wants to merge
3
commits into
xapi-project:feature/perf
Choose a base branch
from
GabrielBuica:private/dbuica/feature/perf/tgroups-part-2
base: feature/perf
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
(library | ||
(name tgroup) | ||
(modules tgroup) | ||
(public_name tgroup) | ||
(libraries xapi-log xapi-stdext-unix)) | ||
(libraries xapi-log xapi-stdext-unix xapi-stdext-std)) | ||
|
||
(test | ||
(name test_tgroup) | ||
(modules test_tgroup) | ||
(package tgroup) | ||
(libraries tgroup alcotest xapi-log)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
module D = Debug.Make (struct let name = __MODULE__ end) | ||
|
||
let test_identity () = | ||
let specs = | ||
[ | ||
((Some "XenCenter2024", "u1000"), "u1000/XenCenter2024") | ||
; ((None, "u1001"), "u1001") | ||
; ((None, "Special!@#"), "Special") | ||
; ((Some "With-Hyphen", "123"), "123/WithHyphen") | ||
; ((Some "", ""), "root") | ||
; ((Some " Xen Center 2024 ", ", u 1000 "), "u1000/XenCenter2024") | ||
; ((Some "Xen Center ,/@.~# 2024", "root"), "root/XenCenter2024") | ||
; ((Some "XenCenter 2024.3.18", ""), "root/XenCenter2024318") | ||
] | ||
in | ||
|
||
let test_make ((user_agent, subject_sid), expected_identity) = | ||
let actual_identity = | ||
Tgroup.Group.Identity.(make ?user_agent subject_sid |> to_string) | ||
in | ||
Alcotest.(check string) | ||
"Check expected identity" expected_identity actual_identity | ||
in | ||
List.iter test_make specs | ||
|
||
let test_of_creator () = | ||
let dummy_identity = | ||
Tgroup.Group.Identity.make ~user_agent:"XenCenter2024" "root" | ||
in | ||
let specs = | ||
[ | ||
((None, None, None, None), "external/unauthenticated") | ||
; ((Some true, None, None, None), "external/intrapool") | ||
; ( (Some true, Some "external", Some dummy_identity, Some "sm") | ||
, "external/intrapool" | ||
) | ||
; ( (Some true, Some "internal", Some dummy_identity, Some "sm") | ||
, "external/intrapool" | ||
) | ||
; ((None, Some "intenal", Some dummy_identity, Some "cli"), "internal/cli") | ||
; ( (None, None, Some dummy_identity, Some "sm") | ||
, "external/authenticated/root/XenCenter2024" | ||
) | ||
] | ||
in | ||
let test_make ((intrapool, endpoint, identity, originator), expected_group) = | ||
let actual_group = | ||
Tgroup.Group.( | ||
Creator.make ?intrapool ?endpoint ?identity ?originator () | ||
|> of_creator | ||
|> to_string | ||
) | ||
in | ||
Alcotest.(check string) "Check expected group" expected_group actual_group | ||
in | ||
List.iter test_make specs | ||
|
||
let tests = | ||
[ | ||
("identity make", `Quick, test_identity) | ||
; ("group of creator", `Quick, test_of_creator) | ||
] | ||
|
||
let () = Alcotest.run "Tgroup library" [("Thread classification", tests)] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we have to care about collisions? If we consider only the sanitized prefix, we could end up with collisions of the shortened names.
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 don't think collisions matter that much in this case. If the we end up with the same shortened names they should be under the same classification. The important aspect was to differentiate between
auth_user_sid
s.