This is an automated email from the ASF dual-hosted git repository.
fortino pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new 8b63c6930d OAK-10568: ElasticIndexProviderServiceTest should support
key based authentication (#1236)
8b63c6930d is described below
commit 8b63c6930de06761feb2a3ca854b8be3c7d46aa0
Author: Fabrizio Fortino <[email protected]>
AuthorDate: Mon Nov 27 14:21:05 2023 +0100
OAK-10568: ElasticIndexProviderServiceTest should support key based
authentication (#1236)
---
.../elastic/ElasticIndexProviderServiceTest.java | 45 +++++++++++++---------
1 file changed, 26 insertions(+), 19 deletions(-)
diff --git
a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexProviderServiceTest.java
b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexProviderServiceTest.java
index 3981cfbbd0..9141cb86eb 100644
---
a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexProviderServiceTest.java
+++
b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexProviderServiceTest.java
@@ -36,25 +36,25 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.File;
-import java.util.Collections;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static
org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexProviderService.PROP_DISABLED;
+import static
org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexProviderService.PROP_ELASTIC_API_KEY_ID;
+import static
org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexProviderService.PROP_ELASTIC_API_KEY_SECRET;
import static
org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexProviderService.PROP_ELASTIC_HOST;
import static
org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexProviderService.PROP_ELASTIC_PORT;
+import static
org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexProviderService.PROP_ELASTIC_SCHEME;
import static
org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexProviderService.PROP_INDEX_PREFIX;
import static
org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexProviderService.PROP_LOCAL_TEXT_EXTRACTION_DIR;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assume.assumeTrue;
import static org.mockito.Mockito.mock;
public class ElasticIndexProviderServiceTest {
- private static final String elasticConnectionString =
System.getProperty("elasticConnectionString");
-
@Rule
public final TemporaryFolder folder = new TemporaryFolder(new
File("target"));
@@ -62,7 +62,7 @@ public class ElasticIndexProviderServiceTest {
public final OsgiContext context = new OsgiContext();
@ClassRule
- public static ElasticConnectionRule elasticRule = new
ElasticConnectionRule(elasticConnectionString);
+ public static ElasticConnectionRule elasticRule = new
ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
private final ElasticIndexProviderService service = new
ElasticIndexProviderService();
@@ -95,13 +95,8 @@ public class ElasticIndexProviderServiceTest {
}
@Test
- public void withElasticSetup() throws Exception {
- Map<String, Object> props = new HashMap<>();
- props.put(PROP_LOCAL_TEXT_EXTRACTION_DIR,
folder.newFolder("localTextExtractionDir").getAbsolutePath());
- props.put(PROP_INDEX_PREFIX, "elastic");
- props.put(PROP_ELASTIC_HOST, "localhost");
- props.put(PROP_ELASTIC_PORT,
elasticRule.getElasticConnectionModel().getElasticPort());
- MockOsgi.activate(service, context.bundleContext(), props);
+ public void withElasticSetup() {
+ MockOsgi.activate(service, context.bundleContext(),
getElasticConfig());
assertNotNull(context.getService(QueryIndexProvider.class));
assertNotNull(context.getService(IndexEditorProvider.class));
@@ -112,12 +107,8 @@ public class ElasticIndexProviderServiceTest {
}
@Test
- public void withIndexCleanerSetup() throws Exception {
- Map<String, Object> props = new HashMap<>();
- props.put(PROP_LOCAL_TEXT_EXTRACTION_DIR,
folder.newFolder("localTextExtractionDir").getAbsolutePath());
- props.put(PROP_INDEX_PREFIX, "elastic");
- props.put(PROP_ELASTIC_HOST, "localhost");
- props.put(PROP_ELASTIC_PORT,
elasticRule.getElasticConnectionModel().getElasticPort());
+ public void withIndexCleanerSetup() {
+ Map<String, Object> props = new HashMap<>(getElasticConfig());
props.put("remoteIndexCleanupFrequency", 600);
MockOsgi.activate(service, context.bundleContext(), props);
@@ -131,7 +122,7 @@ public class ElasticIndexProviderServiceTest {
@Test
public void disabled() {
- MockOsgi.activate(service, context.bundleContext(),
Collections.singletonMap(PROP_DISABLED, true));
+ MockOsgi.activate(service, context.bundleContext(),
Map.of(PROP_DISABLED, true));
assertNull(context.getService(QueryIndexProvider.class));
assertNull(context.getService(IndexEditorProvider.class));
@@ -141,4 +132,20 @@ public class ElasticIndexProviderServiceTest {
MockOsgi.deactivate(service, context.bundleContext());
}
+ private HashMap<String, Object> getElasticConfig() {
+ HashMap<String, Object> config = new HashMap<>();
+ config.put(PROP_INDEX_PREFIX, "elastic");
+ config.put(PROP_ELASTIC_SCHEME,
elasticRule.getElasticConnectionModel().getScheme());
+ config.put(PROP_ELASTIC_HOST,
elasticRule.getElasticConnectionModel().getElasticHost());
+ config.put(PROP_ELASTIC_PORT,
elasticRule.getElasticConnectionModel().getElasticPort());
+ config.put(PROP_ELASTIC_API_KEY_ID,
elasticRule.getElasticConnectionModel().getElasticApiKey());
+ config.put(PROP_ELASTIC_API_KEY_SECRET,
elasticRule.getElasticConnectionModel().getElasticApiSecret());
+ try {
+ config.put(PROP_LOCAL_TEXT_EXTRACTION_DIR,
folder.newFolder("localTextExtractionDir").getAbsolutePath());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ return config;
+ }
+
}