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

OAK-11289: remove remaining elastiknn references in test #1883

Merged
merged 2 commits into from
Dec 2, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,24 @@ public class ElasticConnectionRule extends ExternalResource {

private static final Logger LOG = LoggerFactory.getLogger(ElasticConnectionRule.class);

// Set this connection string as
// <scheme>://<hostname>:<port>?key_id=<>,key_secret=<>
// key_id and key_secret are optional in case the ES server
// needs authentication
// Do not set this if docker is running and you want to run the tests on docker instead.
private static final String ELASTIC_CONNECTION_STRING = System.getProperty("elasticConnectionString");

private final String indexPrefix;
private static boolean useDocker = false;

private final String elasticConnectionString;

private ElasticConnectionModel elasticConnectionModel;

public ElasticConnectionRule() {
this(ELASTIC_CONNECTION_STRING);
}

public ElasticConnectionRule(String elasticConnectionString) {
this(elasticConnectionString,
"elastic_test_" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
public class ElasticDynamicBoostTest extends DynamicBoostCommonTest {

@ClassRule
public static final ElasticConnectionRule elasticRule =
new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

public ElasticDynamicBoostTest() {
this.indexOptions = new ElasticIndexOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.jackrabbit.oak.plugins.index.elastic;

import org.apache.jackrabbit.oak.api.*;
Expand All @@ -28,8 +27,7 @@
public class ElasticExcerptTest extends ExcerptTest {

@ClassRule
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(
ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

public ElasticExcerptTest() {
indexOptions = new ElasticIndexOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
public class ElasticFacetTest extends FacetCommonTest {

@ClassRule
public static final ElasticConnectionRule elasticRule =
new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING, "elastic_test_");
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

protected Repository createJcrRepository() {
indexOptions = new ElasticIndexOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
public class ElasticFullTextAnalyzerTest extends FullTextAnalyzerCommonTest {

@ClassRule
public static final ElasticConnectionRule elasticRule =
new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

public ElasticFullTextAnalyzerTest() {
this.indexOptions = new ElasticIndexOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
public class ElasticFullTextIndexTest extends FullTextIndexCommonTest {

@ClassRule
public static final ElasticConnectionRule elasticRule =
new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

public ElasticFullTextIndexTest() {
this.indexOptions = new ElasticIndexOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@

public class ElasticFunctionIndexCommonTest extends FunctionIndexCommonTest {
@ClassRule
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(
ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

public ElasticFunctionIndexCommonTest() {
indexOptions = new ElasticIndexOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
public class ElasticIndexAggregation2Test extends IndexAggregation2CommonTest {

@ClassRule
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(
ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();


private final ElasticTestRepositoryBuilder builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
public class ElasticIndexAggregationTest extends IndexAggregationCommonTest {

@ClassRule
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(
ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

public ElasticIndexAggregationTest() {
this.indexOptions = new ElasticIndexOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
public class ElasticIndexAndTraversalQueriesSimilarResultsCommonTest extends IndexAndTraversalQueriesSimilarResultsCommonTest {

@ClassRule
public static final ElasticConnectionRule elasticRule =
new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

public ElasticIndexAndTraversalQueriesSimilarResultsCommonTest() {
indexOptions = new ElasticIndexOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
public class ElasticIndexDescendantSpellcheckCommonTest extends IndexDescendantSpellcheckCommonTest {

@ClassRule
public static final ElasticConnectionRule elasticRule =
new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

@Override
protected Repository createJcrRepository() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
public class ElasticIndexDescendantSuggestionCommonTest extends IndexDescendantSuggestionCommonTest {

@ClassRule
public static final ElasticConnectionRule elasticRule =
new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

@Override
protected Repository createJcrRepository() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
public class ElasticIndexExclusionQueryCommonTest extends IndexExclusionQueryCommonTest {

@ClassRule
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(
ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

@Override
protected ContentRepository createRepository() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
public class ElasticIndexImproperUsageCommonTest extends IndexImproperUsageCommonTest {

@ClassRule
public static final ElasticConnectionRule elasticRule =
new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

@Override
protected ContentRepository createRepository() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,16 @@
import org.junit.Rule;
import org.junit.contrib.java.lang.system.ProvideSystemProperty;
import org.junit.contrib.java.lang.system.RestoreSystemProperties;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.slf4j.event.Level;

import java.util.Collection;
import java.util.Collections;

@RunWith(Parameterized.class)
public class ElasticIndexPathRestrictionCommonTest extends IndexPathRestrictionCommonTest {

@ClassRule
public static final ElasticConnectionRule elasticRule =
new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

// Default refresh is 1 minute - so we need to lower that otherwise test would need to wait at least 1 minute
// before it can get the estimated doc count from the remote ES index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@
public class ElasticIndexPlannerCommonTest extends IndexPlannerCommonTest {

@ClassRule
public static final ElasticConnectionRule elasticRule =
new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

// Default refresh is 1 minute - so we need to lower that otherwise test would need to wait at least 1 minute
// before it can get the estimated doc count from the remote ES index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class ElasticIndexProviderServiceTest {
public final OsgiContext context = new OsgiContext();

@ClassRule
public static ElasticConnectionRule elasticRule = new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static ElasticConnectionRule elasticRule = new ElasticConnectionRule();

private final ElasticIndexProviderService service = new ElasticIndexProviderService();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
public class ElasticIndexQueryCommonTest extends IndexQueryCommonTest {

@ClassRule
public static final ElasticConnectionRule elasticRule =
new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

public ElasticIndexQueryCommonTest() {
indexOptions = new ElasticIndexOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,13 @@
public class ElasticIndexQuerySQL2OptimisationCommonTest extends IndexQuerySQL2OptimisationCommonTest {

protected TestRepository repositoryOptionsUtil;
private final ElasticConnection esConnection;
private final ElasticIndexTracker indexTracker;


@ClassRule
public static final ElasticConnectionRule elasticRule =
new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

public ElasticIndexQuerySQL2OptimisationCommonTest() {
this.esConnection = elasticRule.useDocker() ? elasticRule.getElasticConnectionForDocker() :
ElasticConnection esConnection = elasticRule.useDocker() ? elasticRule.getElasticConnectionForDocker() :
elasticRule.getElasticConnectionFromString();
this.indexTracker = new ElasticIndexTracker(esConnection, new ElasticMetricHandler(StatisticsProvider.NOOP));
this.editorProvider = new ElasticIndexEditorProvider(indexTracker, esConnection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
public class ElasticIndexSuggestionCommonTest extends IndexSuggestionCommonTest {

@ClassRule
public static final ElasticConnectionRule elasticRule =
new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

protected Repository createJcrRepository() {
indexOptions = new ElasticIndexOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
public class ElasticOrderByTest extends OrderByCommonTest {

@ClassRule
public static final ElasticConnectionRule elasticRule =
new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

public ElasticOrderByTest() {
indexOptions = new ElasticIndexOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
public class ElasticPropertyIndexCommonTest extends PropertyIndexCommonTest {

@ClassRule
public static final ElasticConnectionRule elasticRule =
new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

public ElasticPropertyIndexCommonTest() {
indexOptions = new ElasticIndexOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ public class ElasticReindexTest {
protected int DEFAULT_ASYNC_INDEXING_TIME_IN_SECONDS = 5;

@ClassRule
public static final ElasticConnectionRule elasticRule =
new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

private Session adminSession;
private QueryManager qe;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
public class ElasticSpellcheckCommonTest extends SpellcheckCommonTest {

@ClassRule
public static final ElasticConnectionRule elasticRule =
new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

@After
public void cleanup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
public class ElasticStrictPathRestrictionEnableCommonTest extends StrictPathRestrictionEnableCommonTest {

@ClassRule
public static final ElasticConnectionRule elasticRule =
new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule();

@Override
protected ContentRepository createRepository() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

public class ElasticTestServer implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(ElasticTestServer.class);
private static final String ELASTIC_DOCKER_IMAGE_VERSION = System.getProperty("elasticDockerImageVersion");

private static final ElasticTestServer SERVER = new ElasticTestServer();
private static volatile ElasticsearchContainer CONTAINER;
Expand Down Expand Up @@ -62,10 +63,7 @@ public static synchronized ElasticsearchContainer getESTestServer() {
}

private synchronized void setup() {
String esDockerImageVersion = ElasticTestUtils.ELASTIC_DOCKER_IMAGE_VERSION;
if (esDockerImageVersion == null) {
esDockerImageVersion = Version.VERSION.toString();
}
String esDockerImageVersion = ELASTIC_DOCKER_IMAGE_VERSION != null ? ELASTIC_DOCKER_IMAGE_VERSION : Version.VERSION.toString();
LOG.info("Elasticsearch test Docker image version: {}.", esDockerImageVersion);
checkIfDockerClientAvailable();
Network network = Network.newNetwork();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@

public final class ElasticTestUtils {

// Set this connection string as
// <scheme>://<hostname>:<port>?key_id=<>,key_secret=<>
// key_id and key_secret are optional in case the ES server
// needs authentication
// Do not set this if docker is running and you want to run the tests on docker instead.
public static final String ELASTIC_CONNECTION_STRING = System.getProperty("elasticConnectionString");

public static final String ELASTIC_DOCKER_IMAGE_VERSION = System.getProperty("elasticDockerImageVersion");
public static final String ELASTIC_KNN_PLUGIN_URI_KEY = "elasticKnnPluginUri";
public static final String ELASTIC_KNN_PLUGIN_URI = System.getProperty(ELASTIC_KNN_PLUGIN_URI_KEY);

public static String randomString(int size) {
return randomString(new Random(42), size);
}
Expand Down
Loading