Skip to content

[Entitlements] Add test entitlement bootstrap and initialization classes #128625

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

Merged
merged 19 commits into from
May 29, 2025

Conversation

prdoyle
Copy link
Contributor

@prdoyle prdoyle commented May 29, 2025

Entitlement bootstrap and initialization for tests.
It loads the agent, use the TestBuildInfo files to create a test ScopeResolver and to locate and load policies and descriptors for plugins and server.
To be used in BootstrapForTesting.

(Continuation of #127814, merged with main, and including some tweaks we discussed.)

@prdoyle prdoyle added auto-backport Automatically create backport pull requests when merged v8.19.0 :Core/Infra/Entitlements Entitlements infrastructure >test Issues or PRs that are addressing/adding tests labels May 29, 2025
@prdoyle prdoyle self-assigned this May 29, 2025
@prdoyle prdoyle marked this pull request as ready for review May 29, 2025 16:35
@prdoyle prdoyle requested a review from a team as a code owner May 29, 2025 16:35
@prdoyle prdoyle changed the title Test entitlements bootstrap 2 [Entitlements] Add test entitlement bootstrap and initialization classes May 29, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label May 29, 2025
Copy link
Contributor

@jdconrad jdconrad left a comment

Choose a reason for hiding this comment

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

LGTM! One minor comment.

* Activates entitlement checking in tests.
* @param bootstrapArgs arguments used for and passed to entitlement initialization
*/
public static void bootstrap(BootstrapArgs bootstrapArgs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we were going to rename BootstrapArgs to InitializationArgs or something like that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, since this moves a class completely instead of just a simple rename, let's do this in a follow up pr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, that's coming right up! I'm planning to encapsulate BootstrapArgs and PathResolver in the next PR.

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

LGTM

* @return the plugin info
* @throws IOException if an I/O exception occurred reading the plugin descriptor
*/
public static PluginDescriptor readInternalDescriptor(InputStream stream) throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

nit: readFromStream to match readFromProperties above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this does less than readFromProperties: it does not support stable plugins.

I can go with readInternalDescriptorFromStream if that's better.

@prdoyle prdoyle enabled auto-merge (squash) May 29, 2025 17:28
@prdoyle prdoyle merged commit 77595cb into elastic:main May 29, 2025
18 checks passed
@prdoyle prdoyle deleted the test-entitlements-bootstrap-2 branch May 29, 2025 19:37
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.19 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 128625

prdoyle added a commit to prdoyle/elasticsearch that referenced this pull request May 30, 2025
…ses (elastic#128625)

* Initialization class as argument to EntitlementAgent

* visibility changes

* WIP: test entitlement bootstrap and initialization classes

* Simplify

* Moving packages to reduce visibility

* adjust visibility

* add plugins descriptor + policy parsing

* PR comments

* update visibility, uncomment TestBuildInfoParser usage

* [CI] Auto commit changes from spotless

* Factor out createPolicyManager to help merge

* TestEntitlementInitialization is not yet implemented

* Respond to PR comments

---------

Co-authored-by: Lorenzo Dematte <lorenzo.dematte@elastic.co>
Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
@prdoyle
Copy link
Contributor Author

prdoyle commented May 30, 2025

Backporting to 8.19 in #128691

elasticsearchmachine added a commit that referenced this pull request May 30, 2025
…8691)

* Inline call to getVersionSpecificCheckerClass.

This makes the code a smidge more like main to ease the backport

* [Entitlements] Add test entitlement bootstrap and initialization classes (#128625)

* Initialization class as argument to EntitlementAgent

* visibility changes

* WIP: test entitlement bootstrap and initialization classes

* Simplify

* Moving packages to reduce visibility

* adjust visibility

* add plugins descriptor + policy parsing

* PR comments

* update visibility, uncomment TestBuildInfoParser usage

* [CI] Auto commit changes from spotless

* Factor out createPolicyManager to help merge

* TestEntitlementInitialization is not yet implemented

* Respond to PR comments

---------

Co-authored-by: Lorenzo Dematte <lorenzo.dematte@elastic.co>
Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>

---------

Co-authored-by: Lorenzo Dematte <lorenzo.dematte@elastic.co>
Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
joshua-adams-1 pushed a commit to joshua-adams-1/elasticsearch that referenced this pull request Jun 3, 2025
…ses (elastic#128625)

* Initialization class as argument to EntitlementAgent

* visibility changes

* WIP: test entitlement bootstrap and initialization classes

* Simplify

* Moving packages to reduce visibility

* adjust visibility

* add plugins descriptor + policy parsing

* PR comments

* update visibility, uncomment TestBuildInfoParser usage

* [CI] Auto commit changes from spotless

* Factor out createPolicyManager to help merge

* TestEntitlementInitialization is not yet implemented

* Respond to PR comments

---------

Co-authored-by: Lorenzo Dematte <lorenzo.dematte@elastic.co>
Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
Samiul-TheSoccerFan pushed a commit to Samiul-TheSoccerFan/elasticsearch that referenced this pull request Jun 5, 2025
…ses (elastic#128625)

* Initialization class as argument to EntitlementAgent

* visibility changes

* WIP: test entitlement bootstrap and initialization classes

* Simplify

* Moving packages to reduce visibility

* adjust visibility

* add plugins descriptor + policy parsing

* PR comments

* update visibility, uncomment TestBuildInfoParser usage

* [CI] Auto commit changes from spotless

* Factor out createPolicyManager to help merge

* TestEntitlementInitialization is not yet implemented

* Respond to PR comments

---------

Co-authored-by: Lorenzo Dematte <lorenzo.dematte@elastic.co>
Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged :Core/Infra/Entitlements Entitlements infrastructure Team:Core/Infra Meta label for core/infra team >test Issues or PRs that are addressing/adding tests v8.19.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants