Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
Improves test coverage of Elasticsearch clients
Browse files Browse the repository at this point in the history
  + Backfills Java client tests and augments REST tests
  + Re-creates indexes for every REST ES test method
  + Adds Awaitility dependency for async testing
  + Runs in-memory ES instance in config-local.props

Signed-off-by: Nick Wade <[email protected]>
  • Loading branch information
davidwadden authored and nwade committed Dec 10, 2018
1 parent 6fed6f4 commit 3601347
Show file tree
Hide file tree
Showing 10 changed files with 976 additions and 235 deletions.
2 changes: 1 addition & 1 deletion docker/server/config/config-local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ queues.dynomite.nonQuorum.port=22122
# memory: The instance is created in memory and lost when the server dies. Useful for development and testing.
# external: Elastic search instance runs outside of the server. Data is persisted and does not get lost when
# the server dies. Useful for more stable environments like staging or production.
workflow.elasticsearch.instanceType=external
workflow.elasticsearch.instanceType=memory

# Transport address to elasticsearch
workflow.elasticsearch.url=localhost:9300
Expand Down
1 change: 1 addition & 0 deletions es5-persistence/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ dependencies {
compile "org.apache.logging.log4j:log4j-core:${revLog4jCore}"

testCompile "org.slf4j:slf4j-log4j12:${revSlf4jlog4j}"
testCompile "org.awaitility:awaitility:${revAwaitility}"
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,14 @@ public class ElasticSearchRestDAOV5 implements IndexDAO {
private static final int RETRY_COUNT = 3;

private static final String WORKFLOW_DOC_TYPE = "workflow";

private static final String TASK_DOC_TYPE = "task";

private static final String LOG_DOC_TYPE = "task_log";

private static final String EVENT_DOC_TYPE = "event";

private static final String MSG_DOC_TYPE = "message";

private static final TimeZone GMT = TimeZone.getTimeZone("GMT");
private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyyMMww");

private @interface HttpMethod {
String GET = "GET";
String POST = "POST";
Expand All @@ -95,18 +94,14 @@ public class ElasticSearchRestDAOV5 implements IndexDAO {

private static final String className = ElasticSearchRestDAOV5.class.getSimpleName();

private String indexName;
private String logIndexPrefix;
private final String indexName;
private final String logIndexPrefix;
private String logIndexName;

private ObjectMapper objectMapper;
private RestHighLevelClient elasticSearchClient;
private RestClient elasticSearchAdminClient;

private final ObjectMapper objectMapper;
private final RestHighLevelClient elasticSearchClient;
private final RestClient elasticSearchAdminClient;
private final ExecutorService executorService;

private static final TimeZone GMT = TimeZone.getTimeZone("GMT");
private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyyMMww");
static {
SIMPLE_DATE_FORMAT.setTimeZone(GMT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ public RestClient get() {
}

private HttpHost[] convertToHttpHosts(List<URI> hosts) {
List<HttpHost> list = hosts.stream().map(host ->
new HttpHost(host.getHost(), host.getPort(), host.getScheme()))
.collect(Collectors.toList());
List<HttpHost> list = hosts.stream()
.map(host -> new HttpHost(host.getHost(), host.getPort(), host.getScheme()))
.collect(Collectors.toList());

return list.toArray(new HttpHost[list.size()]);
}
}

This file was deleted.

Loading

0 comments on commit 3601347

Please sign in to comment.