-
Notifications
You must be signed in to change notification settings - Fork 24.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new x-pack endpoints to asynchronously track the progress of a se…
…arch
- Loading branch information
Showing
43 changed files
with
2,579 additions
and
43 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
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
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
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
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
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
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,30 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
evaluationDependsOn(xpackModule('core')) | ||
|
||
apply plugin: 'elasticsearch.esplugin' | ||
esplugin { | ||
name 'x-pack-async-search' | ||
description 'A module which allows to track the progress of a search asynchronously.' | ||
classname 'org.elasticsearch.xpack.search.AsyncSearch' | ||
extendedPlugins = ['x-pack-core'] | ||
} | ||
archivesBaseName = 'x-pack-async-search' | ||
|
||
compileJava.options.compilerArgs << "-Xlint:-rawtypes" | ||
compileTestJava.options.compilerArgs << "-Xlint:-rawtypes" | ||
|
||
|
||
dependencies { | ||
compileOnly project(":server") | ||
|
||
compileOnly project(path: xpackModule('core'), configuration: 'default') | ||
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') | ||
testCompile project(path: xpackModule('ilm')) | ||
} | ||
|
||
integTest.enabled = false |
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,18 @@ | ||
import org.elasticsearch.gradle.test.RestIntegTestTask | ||
|
||
apply plugin: 'elasticsearch.build' | ||
test.enabled = false | ||
|
||
dependencies { | ||
compile project(':test:framework') | ||
} | ||
|
||
subprojects { | ||
project.tasks.withType(RestIntegTestTask) { | ||
final File xPackResources = new File(xpackProject('plugin').projectDir, 'src/test/resources') | ||
project.copyRestSpec.from(xPackResources) { | ||
include 'rest-api-spec/api/**' | ||
} | ||
} | ||
|
||
} |
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,24 @@ | ||
import org.elasticsearch.gradle.test.RestIntegTestTask | ||
|
||
apply plugin: 'elasticsearch.testclusters' | ||
apply plugin: 'elasticsearch.standalone-test' | ||
|
||
dependencies { | ||
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') | ||
testCompile project(path: xpackModule('async-search'), configuration: 'runtime') | ||
} | ||
|
||
task restTest(type: RestIntegTestTask) { | ||
mustRunAfter(precommit) | ||
} | ||
|
||
testClusters.restTest { | ||
testDistribution = 'DEFAULT' | ||
setting 'xpack.ml.enabled', 'false' | ||
setting 'xpack.monitoring.enabled', 'false' | ||
setting 'xpack.security.enabled', 'true' | ||
user username: 'async-search-user', password: 'async-search-password' | ||
} | ||
|
||
check.dependsOn restTest | ||
test.enabled = false |
35 changes: 35 additions & 0 deletions
35
.../async-search/qa/rest/src/test/java/org/elasticsearch/xpack/search/AsyncSearchRestIT.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,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.search; | ||
|
||
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; | ||
import org.elasticsearch.common.settings.SecureString; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.util.concurrent.ThreadContext; | ||
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; | ||
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; | ||
|
||
import static org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue; | ||
|
||
public class AsyncSearchRestIT extends ESClientYamlSuiteTestCase { | ||
|
||
public AsyncSearchRestIT(final ClientYamlTestCandidate testCandidate) { | ||
super(testCandidate); | ||
} | ||
|
||
@ParametersFactory | ||
public static Iterable<Object[]> parameters() throws Exception { | ||
return ESClientYamlSuiteTestCase.createParameters(); | ||
} | ||
|
||
@Override | ||
protected Settings restClientSettings() { | ||
final String userAuthHeaderValue = basicAuthHeaderValue("async-search-user", | ||
new SecureString("async-search-password".toCharArray())); | ||
return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", userAuthHeaderValue).build(); | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
x-pack/plugin/async-search/qa/rest/src/test/resources/rest-api-spec/test/search/10_basic.yml
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,78 @@ | ||
--- | ||
"Async search": | ||
- do: | ||
indices.create: | ||
index: test-1 | ||
|
||
- do: | ||
indices.create: | ||
index: test-2 | ||
|
||
- do: | ||
indices.create: | ||
index: test-3 | ||
|
||
- do: | ||
index: | ||
index: test-2 | ||
body: { max: 2 } | ||
|
||
- do: | ||
index: | ||
index: test-1 | ||
body: { max: 1 } | ||
|
||
- do: | ||
index: | ||
index: test-3 | ||
body: { max: 3 } | ||
|
||
- do: | ||
indices.refresh: {} | ||
|
||
- do: | ||
async_search.submit: | ||
index: test-* | ||
batched_reduce_size: 2 | ||
body: | ||
query: | ||
match_all: {} | ||
aggs: | ||
1: | ||
max: | ||
field: max | ||
sort: max | ||
|
||
- set: { id: id } | ||
|
||
- do: | ||
async_search.get: | ||
id: "$id" | ||
wait_for_completion: 10s | ||
|
||
- set: { version: version } | ||
- match: { version: 4 } | ||
- is_false: partial_response | ||
- length: { response.hits.hits: 3 } | ||
- match: { response.hits.hits.0._source.max: 1 } | ||
- match: { response.aggregations.1.value: 3.0 } | ||
|
||
- do: | ||
catch: not_modified | ||
async_search.get: | ||
id: "$id" | ||
last_version: "$version" | ||
|
||
- is_false: partial_response | ||
- is_false: response | ||
|
||
- do: | ||
async_search.delete: | ||
id: "$id" | ||
|
||
- match: { acknowledged: true } | ||
|
||
- do: | ||
catch: missing | ||
async_search.delete: | ||
id: "$id" |
15 changes: 15 additions & 0 deletions
15
...async-search/qa/src/main/java/org/elasticsearch/xpack/search/AsyncSearchRestTestCase.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,15 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
package org.elasticsearch.xpack.search; | ||
|
||
import org.elasticsearch.test.rest.ESRestTestCase; | ||
|
||
public class AsyncSearchRestTestCase extends ESRestTestCase { | ||
@Override | ||
protected boolean preserveClusterUponCompletion() { | ||
return true; | ||
} | ||
} |
Oops, something went wrong.