-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ip2geo processor integ test for failure case (#303)
Signed-off-by: Heemin Kim <[email protected]>
- Loading branch information
Showing
2 changed files
with
68 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/test/java/org/opensearch/geospatial/ip2geo/processor/Ip2GeoProcessorIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.geospatial.ip2geo.processor; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import lombok.SneakyThrows; | ||
|
||
import org.opensearch.client.Response; | ||
import org.opensearch.client.ResponseException; | ||
import org.opensearch.geospatial.GeospatialRestTestCase; | ||
import org.opensearch.geospatial.GeospatialTestHelper; | ||
|
||
public class Ip2GeoProcessorIT extends GeospatialRestTestCase { | ||
|
||
@SneakyThrows | ||
public void testCreateIp2GeoProcessor_whenNoSuchDatasourceExist_thenFails() { | ||
String pipelineName = GeospatialTestHelper.randomLowerCaseString(); | ||
|
||
// Run | ||
ResponseException exception = expectThrows( | ||
ResponseException.class, | ||
() -> createIp2GeoProcessorPipeline(pipelineName, Collections.emptyMap()) | ||
); | ||
|
||
// Verify | ||
assertTrue(exception.getMessage().contains("doesn't exist")); | ||
} | ||
|
||
private Response createIp2GeoProcessorPipeline(final String pipelineName, final Map<String, String> properties) throws IOException { | ||
String field = GeospatialTestHelper.randomLowerCaseString(); | ||
String datasourceName = GeospatialTestHelper.randomLowerCaseString(); | ||
Map<String, String> defaultProperties = Map.of( | ||
Ip2GeoProcessor.CONFIG_FIELD, | ||
field, | ||
Ip2GeoProcessor.CONFIG_DATASOURCE, | ||
datasourceName | ||
); | ||
Map<String, String> baseProperties = new HashMap<>(); | ||
baseProperties.putAll(defaultProperties); | ||
baseProperties.putAll(properties); | ||
Map<String, Object> processorConfig = buildProcessorConfig(Ip2GeoProcessor.TYPE, baseProperties); | ||
|
||
return createPipeline(pipelineName, Optional.empty(), Arrays.asList(processorConfig)); | ||
} | ||
} |