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

Enable testing for ExtensiblePlugins using classpath plugins #16908

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

cwperks
Copy link
Member

@cwperks cwperks commented Dec 23, 2024

Description

This PR enables testing for ExtensiblePlugins using the classpath plugin pattern present in internalClusterTest.

To do this, this PR tries to load all extensions for classpath plugins by defining an extendedPlugin relationship between a classpath plugin and all other classpath plugins. In normal scenarios, a plugin will declare that it extends another plugin through the extendedPlugins keyword that it places in build.gradle (example). This PR also puts logic in place to ensure that any extensions are only loaded once.

Additional Context

I ran into this issue while using the integration test framework in the security plugin to test out a change I have been experimenting with. The integration test framework utilizes classpath plugins and it was impossible to load an extensible plugin and its extension simultaneously and have the extensions loaded.

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Copy link
Contributor

❌ Gradle check result for 4176c46: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Copy link
Contributor

github-actions bot commented Jan 8, 2025

❌ Gradle check result for 7ddd9a3: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

github-actions bot commented Jan 8, 2025

❌ Gradle check result for 7ddd9a3: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

github-actions bot commented Jan 8, 2025

✅ Gradle check result for 7ddd9a3: SUCCESS

final Collection<Class<? extends Plugin>> classpathPlugins,
final Path configPath,
final boolean forbidPrivateIndexSettings,
final Map<Class<? extends Plugin>, Class<? extends Plugin>> extendedPlugins
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need extendedPlugins here if we already have classpathPlugins ? If we need to use PluginInfo here, let's do that instead

Copy link
Member Author

@cwperks cwperks Jan 21, 2025

Choose a reason for hiding this comment

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

Because extendedPlugins contains the relationships between the classpath plugins.

i.e. classpathPluginA extends classpathPluginB.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But this has to pass though PluginInfo::extendedPlugins, right? This is how the relationship between plugins is designed?

Copy link
Member Author

Choose a reason for hiding this comment

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

It does in one of the constructors in this class. I chose to support multiple different constructors to continue to support use-cases such as this. For the majority of tests using classpathPlugins they don't need to declare extensions. For test cases that would need to declare extensions, they can use the respective constructor that supports it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest to have 2 constructors, as we did for Node:

  • one that accepts final Collection<Class<? extends Plugin>> classpathPlugins,
  • one that accepts final Collection<PluginInfo> classpathPlugins,

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it, I will need some time to analyze the different usages of the 7 different constructors in this class. It looks like this class has evolved over time to support many different scenarios for testing.

Copy link
Contributor

❌ Gradle check result for 07df814: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Copy link
Contributor

✅ Gradle check result for df48c29: SUCCESS

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Copy link
Contributor

✅ Gradle check result for a4937bd: SUCCESS

Copy link
Contributor

❌ Gradle check result for 49ec944: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Copy link
Contributor

❕ Gradle check result for f9bc2ae: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

@@ -63,4 +64,9 @@ public Path nodeConfigPath(int nodeOrdinal) {
public Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.emptyList();
}

/** Returns a map corresponding to plugin dependencies to other classpath plugins */
public Map<Class<? extends Plugin>, Class<? extends Plugin>> extendedPlugins() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is the last place where we need PluginInfo (from classpath): public Class<PluginInfo> classpathPlugins() {

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.

2 participants