diff options
author | sblimkie <steven.blimkie@amdocs.com> | 2019-02-25 15:24:30 -0500 |
---|---|---|
committer | sblimkie <steven.blimkie@amdocs.com> | 2019-02-25 15:29:29 -0500 |
commit | 5ea47abeeb1713b56006fd69b1564cbd4c4220c7 (patch) | |
tree | 0abf4da88301db41ca46fc82fa6a9669b33cb50b /src/test/java | |
parent | 0afd8dd50d1a9c141b9135f491de9f8cc83f9b29 (diff) |
Search service configurable index settings
When deploying the search service, an optional settings-confg.json
file can be used to define the index settings if the deployer does
not want to use the default settings.
Change-Id: I67902684ac4a432b5a010a7177e9980a0c7592d1
Issue-ID: AAI-2191
Signed-off-by: sblimkie <steven.blimkie@amdocs.com>
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/org/onap/aai/sa/rest/SettingConfigurationTest.java | 57 | ||||
-rw-r--r-- | src/test/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpControllerTest.java | 9 |
2 files changed, 65 insertions, 1 deletions
diff --git a/src/test/java/org/onap/aai/sa/rest/SettingConfigurationTest.java b/src/test/java/org/onap/aai/sa/rest/SettingConfigurationTest.java new file mode 100644 index 0000000..9cc4e3b --- /dev/null +++ b/src/test/java/org/onap/aai/sa/rest/SettingConfigurationTest.java @@ -0,0 +1,57 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2019 AT&T Intellectual Property. All rights reserved. + * Copyright © 2019 Amdocs + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.aai.sa.rest; + +import org.junit.Assert; +import org.junit.Test; + + +public class SettingConfigurationTest { + + @Test + public void settingConfigTest() throws Exception { + SettingConfiguration config = new SettingConfiguration(); + config.init("src/test/resources/json/settings-config.json"); + String settings = config.getSettings(); + System.out.println("SettingsConfig:\n" + settings); + Assert.assertTrue(settings.contains("number_of_shards")); + } + + @Test + public void settingConfigAnalysisTest() throws Exception { + AnalysisConfiguration ac = new AnalysisConfiguration(); + ac.init("src/test/resources/json/filter-config.json", "src/test/resources/json/analysis-config.json"); + System.out.println("AnalysisConfig:\n" + ac.buildEsIndexSettings()); + + SettingConfiguration config = new SettingConfiguration(); + config.init("src/test/resources/json/settings-config.json"); + String settings = config.getSettingsWithAnalysis(ac); + System.out.println("SettingsAnalysisConfig:\n" + settings); + Assert.assertTrue(settings.contains("number_of_shards")); + Assert.assertTrue(settings.contains("nGram_analyzer")); + + config = new SettingConfiguration(); + config.init("src/test/resources/json/missing-file.json"); + settings = config.getSettingsWithAnalysis(ac); + System.out.println("SettingsAnalysisConfigMissing:\n" + settings); + Assert.assertFalse(ac.getEsIndexSettings().isEmpty()); + } +} diff --git a/src/test/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpControllerTest.java b/src/test/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpControllerTest.java index 23d0ea2..007e3fc 100644 --- a/src/test/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpControllerTest.java +++ b/src/test/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpControllerTest.java @@ -34,7 +34,9 @@ import org.json.JSONObject; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; +import org.onap.aai.sa.rest.AnalysisConfiguration; import org.onap.aai.sa.rest.DocumentSchema; +import org.onap.aai.sa.rest.SettingConfiguration; import org.onap.aai.sa.searchdbabstraction.elasticsearch.config.ElasticSearchConfig; import org.onap.aai.sa.searchdbabstraction.entity.OperationResult; @@ -114,8 +116,13 @@ public class ElasticSearchHttpControllerTest { @Test public void testCreateTable() throws Exception { + AnalysisConfiguration ac = new AnalysisConfiguration(); + ac.init("src/test/resources/json/filter-config.json", "src/test/resources/json/analysis-config.json"); + SettingConfiguration sc = new SettingConfiguration(); + sc.init("src/test/resources/json/settings-config.json"); + OperationResult result = - elasticSearch.createTable(TEST_INDEX_NAME, "aai-entities", indexSettings, indexMappings); + elasticSearch.createTable(TEST_INDEX_NAME, "aai-entities", ac, indexMappings, sc); assertThat(result.getResult(), containsString("\"index\":\"test\"}")); assertThat(result.getResultCode(), either(is(200)).or(is(400))); } |