Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions integ-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ task integTestWithSecurity(type: RestIntegTestTask) {
configureSecurityPlugin(cluster)
}

useJUnitPlatform()
dependsOn ':opensearch-sql-plugin:bundlePlugin'
testLogging {
events "passed", "skipped", "failed"
Expand Down Expand Up @@ -433,11 +432,8 @@ task integTestWithSecurity(type: RestIntegTestTask) {
jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005'
}

// NOTE: this IT config discovers only junit5 (jupiter) tests.
// https://github.com/opensearch-project/sql/issues/1974
filter {
includeTestsMatching 'org.opensearch.sql.security.CrossClusterSearchIT'
includeTestsMatching 'org.opensearch.sql.security.PPLPermissionsIT'
includeTestsMatching 'org.opensearch.sql.security.*'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ protected static void configureHttpsClient(RestClientBuilder builder, Settings s
* cluster.
*/
public void configureMultiClusters(String remote) throws IOException {
initRemoteClient(remote);
if (remoteClient == null) {
initRemoteClient(remote);
}

Request connectionRequest = new Request("PUT", "_cluster/settings");
String connectionSetting =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

package org.opensearch.sql.security;

import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_ACCOUNT;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_BANK;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_DOG;
import static org.opensearch.sql.util.MatcherUtils.columnName;
import static org.opensearch.sql.util.MatcherUtils.rows;
import static org.opensearch.sql.util.MatcherUtils.schema;
Expand All @@ -16,51 +13,21 @@
import static org.opensearch.sql.util.MatcherUtils.verifySchema;

import java.io.IOException;
import lombok.SneakyThrows;
import org.json.JSONObject;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.opensearch.sql.ppl.PPLIntegTestCase;
import org.junit.Test;

/** Cross Cluster Search tests with Calcite enabled for enhanced fields features. */
public class CalciteCrossClusterSearchIT extends PPLIntegTestCase {

static {
String[] clusterNames = System.getProperty("cluster.names").split(",");
var remote = "remoteCluster";
for (var cluster : clusterNames) {
if (cluster.startsWith("remote")) {
remote = cluster;
break;
}
}
REMOTE_CLUSTER = remote;
}

public static final String REMOTE_CLUSTER;
private static final String TEST_INDEX_ACCOUNT_REMOTE = REMOTE_CLUSTER + ":" + TEST_INDEX_ACCOUNT;
private static final String TEST_INDEX_DOG_REMOTE = REMOTE_CLUSTER + ":" + TEST_INDEX_DOG;
private static final String TEST_INDEX_BANK_REMOTE = REMOTE_CLUSTER + ":" + TEST_INDEX_BANK;
private static boolean initialized = false;

@SneakyThrows
@BeforeEach
public void initialize() {
if (!initialized) {
setUpIndices();
initialized = true;
}
}
public class CalciteCrossClusterSearchIT extends CrossClusterTestBase {

@Override
protected void init() throws Exception {
configureMultiClusters(REMOTE_CLUSTER);
super.init();
loadIndex(Index.BANK);
loadIndex(Index.BANK, remoteClient());
loadIndex(Index.ACCOUNT);
loadIndex(Index.ACCOUNT, remoteClient());
loadIndex(Index.DOG);
loadIndex(Index.DOG, remoteClient());
loadIndex(Index.ACCOUNT);
loadIndex(Index.ACCOUNT, remoteClient());
loadIndex(Index.TIME_TEST_DATA);
loadIndex(Index.TIME_TEST_DATA, remoteClient());
enableCalcite();
Expand All @@ -87,8 +54,8 @@ public void testCrossClusterFieldsWildcardPrefix() throws IOException {
public void testCrossClusterFieldsWildcardSuffix() throws IOException {
JSONObject result =
executeQuery(String.format("search source=%s | fields *Name", TEST_INDEX_DOG_REMOTE));
verifyColumn(result, columnName("dog_name"), columnName("holdersName"));
verifySchema(result, schema("dog_name", "string"), schema("holdersName", "string"));
verifyColumn(result, columnName("holdersName"));
verifySchema(result, schema("holdersName", "string"));
}

@Test
Expand Down Expand Up @@ -165,7 +132,7 @@ public void testDefaultBinCrossCluster() throws IOException {
TEST_INDEX_ACCOUNT_REMOTE));
verifySchema(result, schema("count()", null, "bigint"), schema("age", null, "string"));

verifyDataRows(result, rows(451L, "20-30"), rows(504L, "30-40"), rows(45L, "40-50"));
verifyDataRows(result, rows(451, "20.0-30.0"), rows(504L, "30.0-40.0"), rows(45L, "40.0-50.0"));
}

@Test
Expand Down Expand Up @@ -218,18 +185,18 @@ public void testRangeBinCrossCluster() throws IOException {
TEST_INDEX_ACCOUNT_REMOTE));
verifySchema(result, schema("count()", null, "bigint"), schema("age", null, "string"));

verifyDataRows(result, rows(1000L, "0-100"));
verifyDataRows(result, rows(451, "20-30"), rows(504L, "30-40"), rows(45L, "40-50"));
}

@Test
public void testTimeBinCrossCluster() throws IOException {
// Time-based binning with span
JSONObject result =
executeQuery(
REMOTE_CLUSTER
+ ":opensearch-sql_test_index_time_data"
+ " | bin @timestamp span=1h"
+ " | fields `@timestamp`, value | sort `@timestamp` | head 3");
String.format(
"source=%s | bin @timestamp span=1h | fields `@timestamp`, value | sort"
+ " `@timestamp` | head 3",
TEST_INDEX_TIME_DATA_REMOTE));
verifySchema(result, schema("@timestamp", null, "timestamp"), schema("value", null, "int"));

// With 1-hour spans
Expand Down Expand Up @@ -285,12 +252,27 @@ public void testCrossClusterRenameFullWildcard() throws IOException {
JSONObject result =
executeQuery(String.format("search source=%s | rename * as old_*", TEST_INDEX_DOG_REMOTE));
verifyColumn(
result, columnName("old_dog_name"), columnName("old_holdersName"), columnName("old_age"));
result,
columnName("old_dog_name"),
columnName("old_holdersName"),
columnName("old_age"),
columnName("old__id"),
columnName("old__index"),
columnName("old__score"),
columnName("old__maxscore"),
columnName("old__sort"),
columnName("old__routing"));
verifySchema(
result,
schema("old_dog_name", "string"),
schema("old_holdersName", "string"),
schema("old_age", "bigint"));
schema("old_age", "bigint"),
schema("old__id", "string"),
schema("old__index", "string"),
schema("old__score", "float"),
schema("old__maxscore", "float"),
schema("old__sort", "bigint"),
schema("old__routing", "string"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,21 @@

package org.opensearch.sql.security;

import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_DOG;
import static org.opensearch.sql.util.MatcherUtils.columnName;
import static org.opensearch.sql.util.MatcherUtils.verifyColumn;

import java.io.IOException;
import lombok.SneakyThrows;
import org.json.JSONObject;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.opensearch.sql.ppl.PPLIntegTestCase;
import org.junit.Test;

public class CrossClusterCoalesceIT extends PPLIntegTestCase {

static {
String[] clusterNames = System.getProperty("cluster.names").split(",");
var remote = "remoteCluster";
for (var cluster : clusterNames) {
if (cluster.startsWith("remote")) {
remote = cluster;
break;
}
}
REMOTE_CLUSTER = remote;
}

public static final String REMOTE_CLUSTER;
private static final String TEST_INDEX_DOG_REMOTE = REMOTE_CLUSTER + ":" + TEST_INDEX_DOG;
private static boolean initialized = false;

@SneakyThrows
@BeforeEach
public void initialize() {
if (!initialized) {
setUpIndices();
initialized = true;
}
}
public class CrossClusterCoalesceIT extends CrossClusterTestBase {

@Override
protected void init() throws Exception {
enableCalcite();
configureMultiClusters(REMOTE_CLUSTER);
super.init();
loadIndex(Index.DOG);
loadIndex(Index.DOG, remoteClient());
enableCalcite();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,23 @@

package org.opensearch.sql.security;

import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_ACCOUNT;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_BANK;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_DOG;
import static org.opensearch.sql.util.MatcherUtils.columnName;
import static org.opensearch.sql.util.MatcherUtils.rows;
import static org.opensearch.sql.util.MatcherUtils.verifyColumn;
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows;

import java.io.IOException;
import lombok.SneakyThrows;
import org.json.JSONObject;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.opensearch.client.ResponseException;
import org.opensearch.sql.ppl.PPLIntegTestCase;

/** Cross Cluster Search tests to be executed with security plugin. */
public class CrossClusterSearchIT extends PPLIntegTestCase {

static {
// find a remote cluster
String[] clusterNames = System.getProperty("cluster.names").split(",");
var remote = "remoteCluster";
for (var cluster : clusterNames) {
if (cluster.startsWith("remote")) {
remote = cluster;
break;
}
}
REMOTE_CLUSTER = remote;
}

public static final String REMOTE_CLUSTER;

private static final String TEST_INDEX_BANK_REMOTE = REMOTE_CLUSTER + ":" + TEST_INDEX_BANK;
private static final String TEST_INDEX_DOG_REMOTE = REMOTE_CLUSTER + ":" + TEST_INDEX_DOG;
private static final String TEST_INDEX_DOG_MATCH_ALL_REMOTE =
MATCH_ALL_REMOTE_CLUSTER + ":" + TEST_INDEX_DOG;
private static final String TEST_INDEX_ACCOUNT_REMOTE = REMOTE_CLUSTER + ":" + TEST_INDEX_ACCOUNT;

private static boolean initialized = false;

@SneakyThrows
@BeforeEach
public void initialize() {
if (!initialized) {
setUpIndices();
initialized = true;
}
}
public class CrossClusterSearchIT extends CrossClusterTestBase {

@Override
protected void init() throws Exception {
configureMultiClusters(REMOTE_CLUSTER);
super.init();
loadIndex(Index.BANK);
loadIndex(Index.BANK, remoteClient());
loadIndex(Index.DOG);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.sql.security;

import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_ACCOUNT;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_BANK;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_DOG;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_TIME_DATA;

import org.opensearch.sql.ppl.PPLIntegTestCase;

public class CrossClusterTestBase extends PPLIntegTestCase {
static {
// find a remote cluster
String[] clusterNames = System.getProperty("cluster.names").split(",");
var remote = "remoteCluster";
for (var cluster : clusterNames) {
if (cluster.startsWith("remote")) {
remote = cluster;
break;
}
}
REMOTE_CLUSTER = remote;
}

public static final String REMOTE_CLUSTER;

protected static final String TEST_INDEX_BANK_REMOTE = REMOTE_CLUSTER + ":" + TEST_INDEX_BANK;
protected static final String TEST_INDEX_DOG_REMOTE = REMOTE_CLUSTER + ":" + TEST_INDEX_DOG;
protected static final String TEST_INDEX_DOG_MATCH_ALL_REMOTE =
MATCH_ALL_REMOTE_CLUSTER + ":" + TEST_INDEX_DOG;
protected static final String TEST_INDEX_ACCOUNT_REMOTE =
REMOTE_CLUSTER + ":" + TEST_INDEX_ACCOUNT;
protected static final String TEST_INDEX_TIME_DATA_REMOTE =
REMOTE_CLUSTER + ":" + TEST_INDEX_TIME_DATA;

@Override
protected void init() throws Exception {
super.init();
configureMultiClusters(REMOTE_CLUSTER);
}
}
Loading
Loading