mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-05 20:48:22 +00:00
This change removes the InternalClient and the InternalSecurityClient. These are replaced with usage of the ThreadContext and a transient value, `action.origin`, to indicate which component the request came from. The security code has been updated to look for this value and ensure the request is executed as the proper user. This work comes from elastic/x-pack-elasticsearch#2808 where @s1monw suggested that we do this. While working on this, I came across index template registries and rather than updating them to use the new method, I replaced the ML one with the template upgrade framework so that we could remove this template registry. The watcher template registry is still needed as the template must be updated for rolling upgrades to work (see elastic/x-pack-elasticsearch#2950). Original commit: elastic/x-pack-elasticsearch@7dbf2f263e
127 lines
5.3 KiB
Groovy
127 lines
5.3 KiB
Groovy
import org.elasticsearch.gradle.test.ClusterConfiguration
|
|
import org.elasticsearch.gradle.test.ClusterFormationTasks
|
|
import org.elasticsearch.gradle.test.NodeInfo
|
|
|
|
apply plugin: 'elasticsearch.standalone-test'
|
|
apply plugin: 'elasticsearch.standalone-rest-test'
|
|
apply plugin: 'elasticsearch.rest-test'
|
|
|
|
dependencies {
|
|
testCompile project(path: ':modules:tribe', configuration: 'runtime')
|
|
testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime')
|
|
testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'testArtifacts')
|
|
testCompile project(path: ':modules:analysis-common', configuration: 'runtime')
|
|
}
|
|
|
|
namingConventions.skipIntegTestInDisguise = true
|
|
|
|
compileTestJava.options.compilerArgs << "-Xlint:-try"
|
|
|
|
String xpackPath = project(':x-pack-elasticsearch:plugin').projectDir.toPath().resolve('src/test/resources').toString()
|
|
sourceSets {
|
|
test {
|
|
resources {
|
|
srcDirs += [xpackPath]
|
|
}
|
|
}
|
|
}
|
|
|
|
forbiddenPatterns {
|
|
exclude '**/*.key'
|
|
exclude '**/*.p12'
|
|
exclude '**/*.der'
|
|
exclude '**/*.zip'
|
|
}
|
|
|
|
task setupClusterOne {}
|
|
ClusterConfiguration configOne = new ClusterConfiguration(project)
|
|
configOne.clusterName = 'cluster1'
|
|
configOne.setting('node.name', 'cluster1-node1')
|
|
configOne.setting('xpack.monitoring.enabled', false)
|
|
configOne.setting('xpack.ml.enabled', false)
|
|
configOne.plugin(':x-pack-elasticsearch:plugin')
|
|
configOne.module(project.project(':modules:analysis-common'))
|
|
configOne.setupCommand('setupDummyUser',
|
|
'bin/x-pack/users', 'useradd', 'test_user', '-p', 'x-pack-test-password', '-r', 'superuser')
|
|
configOne.waitCondition = { node, ant ->
|
|
File tmpFile = new File(node.cwd, 'wait.success')
|
|
ant.get(src: "http://${node.httpUri()}/_cluster/health?wait_for_nodes=>=1&wait_for_status=yellow",
|
|
dest: tmpFile.toString(),
|
|
username: 'test_user',
|
|
password: 'x-pack-test-password',
|
|
ignoreerrors: true,
|
|
retries: 10)
|
|
return tmpFile.exists()
|
|
}
|
|
List<NodeInfo> cluster1Nodes = ClusterFormationTasks.setup(project, 'clusterOne', setupClusterOne, configOne)
|
|
|
|
task setupClusterTwo {}
|
|
ClusterConfiguration configTwo = new ClusterConfiguration(project)
|
|
configTwo.clusterName = 'cluster2'
|
|
configTwo.setting('node.name', 'cluster2-node1')
|
|
configTwo.setting('xpack.monitoring.enabled', false)
|
|
configTwo.setting('xpack.ml.enabled', false)
|
|
configTwo.plugin(':x-pack-elasticsearch:plugin')
|
|
configTwo.module(project.project(':modules:analysis-common'))
|
|
configTwo.setupCommand('setupDummyUser',
|
|
'bin/x-pack/users', 'useradd', 'test_user', '-p', 'x-pack-test-password', '-r', 'superuser')
|
|
configTwo.waitCondition = { node, ant ->
|
|
File tmpFile = new File(node.cwd, 'wait.success')
|
|
ant.get(src: "http://${node.httpUri()}/_cluster/health?wait_for_nodes=>=1&wait_for_status=yellow",
|
|
dest: tmpFile.toString(),
|
|
username: 'test_user',
|
|
password: 'x-pack-test-password',
|
|
ignoreerrors: true,
|
|
retries: 10)
|
|
return tmpFile.exists()
|
|
}
|
|
List<NodeInfo> cluster2Nodes = ClusterFormationTasks.setup(project, 'clusterTwo', setupClusterTwo, configTwo)
|
|
|
|
integTestCluster {
|
|
dependsOn setupClusterOne, setupClusterTwo
|
|
plugin ':x-pack-elasticsearch:plugin'
|
|
setupCommand 'setupDummyUser',
|
|
'bin/x-pack/users', 'useradd', 'test_user', '-p', 'x-pack-test-password', '-r', 'superuser'
|
|
setting 'xpack.monitoring.enabled', false
|
|
setting 'xpack.ml.enabled', false
|
|
setting 'node.name', 'tribe-node'
|
|
setting 'tribe.on_conflict', 'prefer_cluster1'
|
|
setting 'tribe.cluster1.cluster.name', 'cluster1'
|
|
setting 'tribe.cluster1.discovery.zen.ping.unicast.hosts', "'${-> cluster1Nodes.get(0).transportUri()}'"
|
|
setting 'tribe.cluster1.http.enabled', 'true'
|
|
setting 'tribe.cluster1.xpack.ml.enabled', 'false'
|
|
setting 'tribe.cluster2.cluster.name', 'cluster2'
|
|
setting 'tribe.cluster2.discovery.zen.ping.unicast.hosts', "'${-> cluster2Nodes.get(0).transportUri()}'"
|
|
setting 'tribe.cluster2.http.enabled', 'true'
|
|
setting 'tribe.cluster2.xpack.ml.enabled', 'false'
|
|
keystoreSetting 'bootstrap.password', 'x-pack-test-password'
|
|
waitCondition = { node, ant ->
|
|
File tmpFile = new File(node.cwd, 'wait.success')
|
|
// 5 nodes: tribe + clusterOne (1 node + tribe internal node) + clusterTwo (1 node + tribe internal node)
|
|
ant.get(src: "http://${node.httpUri()}/_cluster/health?wait_for_nodes=>=5&wait_for_status=yellow",
|
|
dest: tmpFile.toString(),
|
|
username: 'test_user',
|
|
password: 'x-pack-test-password',
|
|
ignoreerrors: true,
|
|
retries: 10)
|
|
return tmpFile.exists()
|
|
}
|
|
}
|
|
|
|
test {
|
|
/*
|
|
* We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each
|
|
* other if we allow them to set the number of available processors as it's set-once in Netty.
|
|
*/
|
|
systemProperty 'es.set.netty.runtime.available.processors', 'false'
|
|
include '**/*Tests.class'
|
|
}
|
|
|
|
integTestRunner {
|
|
systemProperty 'tests.cluster', "${-> cluster1Nodes.get(0).transportUri()}"
|
|
systemProperty 'tests.cluster2', "${-> cluster2Nodes.get(0).transportUri()}"
|
|
systemProperty 'tests.tribe', "${-> integTest.nodes.get(0).transportUri()}"
|
|
finalizedBy 'clusterOne#stop'
|
|
finalizedBy 'clusterTwo#stop'
|
|
}
|