- 
                Notifications
    You must be signed in to change notification settings 
- Fork 25.6k
Generate a test dependencies file to support unit tests in entitlements #127486
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
Conversation
| Pinging @elastic/es-core-infra (Team:Core/Infra) | 
| We could reduce redundancy by mapping just package names to modules, instead of every individual class. That should make the file much smaller. | 
| Jack pointed out that this already has just one entry per jar/directory. 
 Update: the reason for using the representative class instead of the jar/directory is because its location could be different at runtime depending on which tests are running. If we're not careful, that info could be not just useless, but misleading. | 
| @ryan @ldematte @mark-vieira Patrick and I believe this is ready for another round of review. Thanks! | 
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.
One additional clarification but otherwise LGTM.
        
          
                build-tools/src/main/java/org/elasticsearch/gradle/plugin/PluginBuildPlugin.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
      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.
LGTM
| 💚 Backport successful
 | 
…ts (elastic#127486) Generates a test file with the following information and format: { "component": "<component name>", "locations": [ { "representative_class": <class name with package>, "module": "<module name>" }, ... ] } For painless: { "component": "lang-painless", "locations": [ { "representative_class": "org/objectweb/asm/tree/analysis/Analyzer.class", "module": "org.objectweb.asm.tree.analysis" }, ... ] } Then it copies the following files into the jar for consumption by unit tests: * META-INF/plugin-test-build-info.json * META-INF/es-plugins/<plugin name>/plugin-descriptor.properties * META-INF/es-plugins/<plugin name>/entitlement-policy.yaml For server, the files in the jar become the following: * META-INF/server-test-build-info.json This should provide enough information for BootstrapForTesting to be able to build a mapping of caller class to policy file using the class file to look up the jar or directory within the class path and then associating that with it's specified module and finally using the specified module to look up the appropriate entitlement policy. caller class -> specified module -> entitlement policy --------- Co-authored-by: Patrick Doyle <[email protected]>
…ts (#127486) (#128280) Generates a test file with the following information and format: { "component": "<component name>", "locations": [ { "representative_class": <class name with package>, "module": "<module name>" }, ... ] } For painless: { "component": "lang-painless", "locations": [ { "representative_class": "org/objectweb/asm/tree/analysis/Analyzer.class", "module": "org.objectweb.asm.tree.analysis" }, ... ] } Then it copies the following files into the jar for consumption by unit tests: * META-INF/plugin-test-build-info.json * META-INF/es-plugins/<plugin name>/plugin-descriptor.properties * META-INF/es-plugins/<plugin name>/entitlement-policy.yaml For server, the files in the jar become the following: * META-INF/server-test-build-info.json This should provide enough information for BootstrapForTesting to be able to build a mapping of caller class to policy file using the class file to look up the jar or directory within the class path and then associating that with it's specified module and finally using the specified module to look up the appropriate entitlement policy. caller class -> specified module -> entitlement policy --------- Co-authored-by: Patrick Doyle <[email protected]>
…solver) (#127719) This PR introduces a test-specific ScopeResolver to use with PolicyManager for checking entitlements within test code running in a test runner (unit tests and integ tests, where code is running withing the same JVM). The information for resolving component and module names is derived from the file created in #127486
…solver) (elastic#127719) This PR introduces a test-specific ScopeResolver to use with PolicyManager for checking entitlements within test code running in a test runner (unit tests and integ tests, where code is running withing the same JVM). The information for resolving component and module names is derived from the file created in elastic#127486
…solver) (#127719) (#128301) This PR introduces a test-specific ScopeResolver to use with PolicyManager for checking entitlements within test code running in a test runner (unit tests and integ tests, where code is running withing the same JVM). The information for resolving component and module names is derived from the file created in #127486
Generates a test file with the following information and format:
For painless:
Then it copies the following files into the jar for consumption by unit tests:
For server, the files in the jar become the following:
This should provide enough information for
BootstrapForTestingto be able to build a mapping of caller class to policy file using the class file to look up the jar or directory within the class path and then associating that with it's specified module and finally using the specified module to look up the appropriate entitlement policy.caller class -> specified module -> entitlement policy