Skip to content

Commit 1070afd

Browse files
ahkcsclaude
andcommitted
Skip AnalyticsEngineCompatIT when analytics-engine is absent
AnalyticsEngineCompatIT is a coexistence smoke test meant to run only in the dedicated :integ-test:analyticsEngineCompatIT task, which bundles the analytics-engine plugin stack. The distribution integ-test pipeline, however, scans every *IT class against the built distribution and runs it with the security plugin enabled and without analytics-engine. There it fails during REST client init with "ConnectionClosedException: Connection closed by peer", because the test extends a bare OpenSearchRestTestCase that speaks plain HTTP to the TLS-secured port. A build.gradle exclude does not cover that pipeline. Make the test self-inert regardless of how it is discovered: - Extend OpenSearchSQLRestTestCase so the REST client honours the https/user/ password system properties of a secured cluster. - Skip via an assumption when the analytics-engine plugin is not installed, so a build without the plugin reports the test as skipped rather than failed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Kai Huang <ahkcs@amazon.com>
1 parent ea39ffd commit 1070afd

1 file changed

Lines changed: 41 additions & 3 deletions

File tree

integ-test/src/test/java/org/opensearch/sql/plugin/AnalyticsEngineCompatIT.java

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,55 @@
55

66
package org.opensearch.sql.plugin;
77

8+
import static org.junit.Assume.assumeTrue;
9+
10+
import java.io.IOException;
11+
import org.junit.Before;
812
import org.junit.Test;
9-
import org.opensearch.test.rest.OpenSearchRestTestCase;
13+
import org.opensearch.client.Request;
14+
import org.opensearch.client.Response;
15+
import org.opensearch.sql.legacy.OpenSearchSQLRestTestCase;
16+
import org.opensearch.sql.legacy.TestUtils;
1017

1118
/**
1219
* Smoke test: verifies that opensearch-sql loads cleanly alongside arrow-flight-rpc and
1320
* analytics-engine. A successful cluster start is the only assertion — no sql-specific logic runs.
21+
*
22+
* <p>This test is only meaningful when the analytics-engine plugin is installed; the dedicated
23+
* {@code :integ-test:analyticsEngineCompatIT} Gradle task bundles the plugin stack for exactly that
24+
* purpose. Other lanes can still discover this class — notably the distribution integ-test
25+
* pipeline, which scans every {@code *IT} class against the built distribution and may run with the
26+
* security plugin enabled and without analytics-engine. A {@code build.gradle} exclude does not
27+
* protect against that pipeline, so the test guards itself instead:
28+
*
29+
* <ul>
30+
* <li>It extends {@link OpenSearchSQLRestTestCase} so the REST client honours the {@code https},
31+
* {@code user}, and {@code password} system properties of a secured cluster (a bare {@code
32+
* OpenSearchRestTestCase} speaks plain HTTP and gets its connection closed during client init
33+
* on a TLS-secured port).
34+
* <li>It skips via an assumption when analytics-engine is absent, so a build without the plugin
35+
* reports the test as skipped rather than failed.
36+
* </ul>
1437
*/
15-
public class AnalyticsEngineCompatIT extends OpenSearchRestTestCase {
38+
public class AnalyticsEngineCompatIT extends OpenSearchSQLRestTestCase {
39+
40+
/**
41+
* Skips the suite unless the analytics-engine plugin is installed. Runs after the framework has
42+
* established the (security-aware) REST client, so the lookup itself succeeds on both plain and
43+
* secured clusters.
44+
*/
45+
@Before
46+
public void requireAnalyticsEngine() throws IOException {
47+
Response response = client().performRequest(new Request("GET", "/_cat/plugins?h=component"));
48+
String installedPlugins = TestUtils.getResponseBody(response, true);
49+
assumeTrue(
50+
"analytics-engine plugin not installed — skipping coexistence smoke test",
51+
installedPlugins.contains("analytics-engine"));
52+
}
1653

1754
@Test
1855
public void testClusterStarted() {
19-
// If the cluster booted, all three plugins loaded without classloader errors.
56+
// If the cluster booted with analytics-engine present, all plugins loaded without classloader
57+
// errors. The assumption above guarantees we only assert this where it is meaningful.
2058
}
2159
}

0 commit comments

Comments
 (0)