Skip to content

test(integ-test): gate optional integration environments - #5731

Open
mengweieric wants to merge 1 commit into
opensearch-project:mainfrom
mengweieric:menwe/optional-it-environment-gates
Open

test(integ-test): gate optional integration environments#5731
mengweieric wants to merge 1 commit into
opensearch-project:mainfrom
mengweieric:menwe/optional-it-environment-gates

Conversation

@mengweieric

Copy link
Copy Markdown
Collaborator

Summary

Plain external-cluster integration runs do not always include the Security, geospatial, telemetry, or remote-cluster environments required by their dedicated test suites. Those suites currently fail during setup instead of reporting that the dependency is unavailable.

This change detects optional plugins through _cat/plugins and skips only when the required component is absent. Cross-cluster tests similarly skip when no remote cluster is configured. Dedicated environments continue to run the tests unchanged.

No production behavior is modified.

Validation

  • On a plain five-shard cluster, all optional-environment suites skipped cleanly and the task passed
  • Plugin-present paths remain enabled by runtime detection
  • spotlessCheck, compileTestJava, and git diff --check pass

Detect Security, geospatial, telemetry, and remote-cluster capabilities at runtime so plain external-cluster runs skip unavailable environments while dedicated test tasks continue to execute them.

Signed-off-by: Eric Wei <menwe@amazon.com>
@github-actions

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🧪 No relevant tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ Recommended focus areas for review

Resource Leak

The InputStream from response.getEntity().getContent() is not closed. If readAllBytes() throws an exception, the stream remains open. Wrap the stream in a try-with-resources or ensure it is closed in a finally block.

Response response = client.performRequest(new Request("GET", "/_cat/plugins?h=component"));
String body = new String(response.getEntity().getContent().readAllBytes());

@mengweieric mengweieric added the testing Related to improving software testing label Aug 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Use exact line matching for plugin detection

The contains() check may produce false positives if pluginComponentName is a
substring of another plugin name. Use line-by-line matching to ensure exact
component name matches.

integ-test/src/test/java/org/opensearch/sql/util/ClusterPlugins.java [45-47]

 Response response = client.performRequest(new Request("GET", "/_cat/plugins?h=component"));
 String body = new String(response.getEntity().getContent().readAllBytes());
-return body.contains(pluginComponentName);
+return body.lines().anyMatch(line -> line.trim().equals(pluginComponentName));
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies a potential false positive issue where contains() could match partial plugin names. Using exact line matching with lines().anyMatch() ensures accurate plugin detection and prevents bugs.

Medium
General
Trim cluster names after splitting

The code doesn't trim cluster names after splitting, which could cause
startsWith("remote") to fail if there are spaces around commas in the property
value. Apply trim() to each cluster name.

integ-test/src/test/java/org/opensearch/sql/security/CrossClusterTestBase.java [22-30]

 String clusterNamesProp = System.getProperty("cluster.names");
 String remote = null;
 if (clusterNamesProp != null && !clusterNamesProp.isBlank()) {
   for (var cluster : clusterNamesProp.split(",")) {
-    if (cluster.startsWith("remote")) {
-      remote = cluster;
+    if (cluster.trim().startsWith("remote")) {
+      remote = cluster.trim();
       break;
     }
   }
 }
Suggestion importance[1-10]: 7

__

Why: Valid suggestion that addresses a potential issue where whitespace in the cluster.names property could cause the startsWith("remote") check to fail. Trimming ensures robust parsing of cluster names.

Medium

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Related to improving software testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant