-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Run some REST tests against a cluster running in docker containers #39515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
36ad7e7
0962587
cf69ae3
0244955
02278b6
012e88a
76f8ead
ef0e33a
ef8bbb8
df7c5fb
48eba36
5f6b3f8
aa95613
d6fa767
d86c25d
39b2597
6794c14
8d50f21
4b785b8
c0cac7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,15 @@ import org.elasticsearch.gradle.BuildPlugin | |
import org.elasticsearch.gradle.LoggedExec | ||
import org.elasticsearch.gradle.MavenFilteringHack | ||
import org.elasticsearch.gradle.VersionProperties | ||
import com.carrotsearch.gradle.junit4.RandomizedTestingTask | ||
|
||
apply plugin: 'base' | ||
import javax.net.ssl.KeyManager | ||
mark-vieira marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import javax.net.ssl.SSLContext | ||
import javax.net.ssl.TrustManagerFactory | ||
import java.security.KeyStore | ||
import java.security.SecureRandom | ||
|
||
apply plugin: 'elasticsearch.standalone-rest-test' | ||
apply plugin: 'elasticsearch.test.fixtures' | ||
|
||
configurations { | ||
|
@@ -91,20 +98,79 @@ void addCopyDockerfileTask(final boolean oss) { | |
} | ||
} | ||
|
||
Closure createAndSetWritable = {location -> | ||
mark-vieira marked this conversation as resolved.
Show resolved
Hide resolved
|
||
File file = file(location); | ||
file.mkdirs() | ||
file.setWritable(true, false) | ||
} | ||
|
||
task copyKeystore(type: Sync) { | ||
from project(':x-pack:plugin:core') | ||
.file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') | ||
into "${buildDir}/certs" | ||
doLast { | ||
file("${buildDir}/certs").setReadable(true, false) | ||
file("${buildDir}/certs/testnode.jks").setReadable(true, false) | ||
} | ||
} | ||
|
||
preProcessFixture { | ||
dependsOn taskName("copy", true, "DockerContext") | ||
dependsOn taskName("copy", true, "Dockerfile") | ||
dependsOn taskName("copy", false, "DockerContext") | ||
dependsOn taskName("copy", false, "Dockerfile") | ||
dependsOn copyKeystore | ||
doLast { | ||
// tests expect to have an empty repo | ||
project.delete("${buildDir}/repo") | ||
mark-vieira marked this conversation as resolved.
Show resolved
Hide resolved
|
||
project.delete("${buildDir}/oss-repo") | ||
createAndSetWritable("${buildDir}/repo") | ||
createAndSetWritable("${buildDir}/oss-repo") | ||
createAndSetWritable("${buildDir}/logs/default-1") | ||
createAndSetWritable("${buildDir}/logs/default-2") | ||
createAndSetWritable("${buildDir}/logs/oss-1") | ||
createAndSetWritable("${buildDir}/logs/oss-2") | ||
} | ||
} | ||
|
||
postProcessFixture.doLast { | ||
println "docker default distro is on port: ${ext."test.fixtures.elasticsearch-default.tcp.9200"}, " + | ||
"oss is on: ${ext."test.fixtures.elasticsearch-oss.tcp.9200"}" | ||
configurations { | ||
mark-vieira marked this conversation as resolved.
Show resolved
Hide resolved
|
||
restSpec | ||
} | ||
dependencies { | ||
restSpec "org.elasticsearch:rest-api-spec:${version}" | ||
} | ||
|
||
task copyRestTests(type: Sync) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than define a new task here, we should just configure the existing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I specifically wanted to have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
from { zipTree(configurations.restSpec.singleFile) } | ||
from project(':x-pack:plugin:core') | ||
.file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') | ||
into sourceSets.test.output.resourcesDir | ||
if (System.getProperty("tests.distribution", "default") == "default") { | ||
from { project(':x-pack:plugin').sourceSets.test.resources } | ||
into sourceSets.test.output.resourcesDir | ||
mark-vieira marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
dependsOn configurations.restSpec | ||
// FIXME: check why these tests fail | ||
exclude "**/data_frame/**" | ||
exclude "**/ml/**" | ||
} | ||
processTestResources.dependsOn copyRestTests | ||
|
||
task integTest(type: RandomizedTestingTask) { | ||
parallelism = '1' | ||
include '**/*IT.class' | ||
// FIXME: see why these tests fail | ||
systemProperty 'tests.rest.blacklist', [ | ||
'watcher/execute_watch/60_http_input/HTTP input supports extracting of keys', | ||
'token/10_basic/Test invalidate realm\'s tokens', | ||
'monitoring/bulk/10_basic/Bulk indexing of monitoring data on closed indices should throw an export exception', | ||
'monitoring/bulk/20_privileges/Monitoring Bulk API', | ||
'indices.get_alias/10_basic/Get alias against closed indices', | ||
'ssl/10_basic/Test get SSL certificates', | ||
].join(",") | ||
} | ||
|
||
// TODO: Add some actual tests, this will just check that the TPC port in the container is up | ||
check.dependsOn postProcessFixture | ||
check.dependsOn integTest | ||
|
||
void addBuildDockerImage(final boolean oss) { | ||
final Task buildDockerImageTask = task(taskName("build", oss, "DockerImage"), type: LoggedExec) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,137 @@ | ||
# Only used for testing the docker images | ||
version: '3' | ||
services: | ||
elasticsearch-default: | ||
elasticsearch-default-1: | ||
build: | ||
context: ./build/docker | ||
dockerfile: Dockerfile | ||
environment: | ||
- node.name=elasticsearch-default-1 | ||
- cluster.initial_master_nodes=elasticsearch-default-1,elasticsearch-default-2 | ||
- discovery.seed_hosts=elasticsearch-default-2:9300 | ||
- cluster.name=elasticsearch-default | ||
- discovery.type=single-node | ||
- bootstrap.memory_lock=true | ||
- "ES_JAVA_OPTS=-Xms512m -Xmx512m" | ||
- path.repo=/tmp/es-repo | ||
- node.attr.testattr=test | ||
- cluster.routing.allocation.disk.watermark.low=1b | ||
- cluster.routing.allocation.disk.watermark.high=1b | ||
- cluster.routing.allocation.disk.watermark.flood_stage=1b | ||
- script.max_compilations_rate=2048/1m | ||
- node.store.allow_mmap=false | ||
- xpack.security.enabled=true | ||
- xpack.security.transport.ssl.enabled=true | ||
- xpack.security.http.ssl.enabled=true | ||
- xpack.security.authc.token.enabled=true | ||
- xpack.security.audit.enabled=true | ||
- xpack.security.authc.realms.file.file1.order=0 | ||
- xpack.security.authc.realms.native.native1.order=1 | ||
- xpack.security.transport.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks | ||
- xpack.security.http.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks | ||
- xpack.http.ssl.verification_mode=certificate | ||
- xpack.security.transport.ssl.verification_mode=certificate | ||
- xpack.license.self_generated.type=trial | ||
volumes: | ||
- ./build/repo:/tmp/es-repo | ||
- ./build/certs/testnode.jks:/usr/share/elasticsearch/config/testnode.jks | ||
- ./build/logs/default-1:/usr/share/elasticsearch/logs | ||
- ./docker-test-entrypoint.sh:/docker-test-entrypoint.sh | ||
ports: | ||
- "9200" | ||
elasticsearch-oss: | ||
ulimits: | ||
memlock: | ||
soft: -1 | ||
hard: -1 | ||
entrypoint: /docker-test-entrypoint.sh | ||
elasticsearch-default-2: | ||
build: | ||
context: ./build/docker | ||
environment: | ||
- node.name=elasticsearch-default-2 | ||
- cluster.initial_master_nodes=elasticsearch-default-1,elasticsearch-default-2 | ||
- discovery.seed_hosts=elasticsearch-default-1:9300 | ||
- cluster.name=elasticsearch-default | ||
- bootstrap.memory_lock=true | ||
- "ES_JAVA_OPTS=-Xms512m -Xmx512m" | ||
- path.repo=/tmp/es-repo | ||
- node.attr.testattr=test | ||
- cluster.routing.allocation.disk.watermark.low=1b | ||
- cluster.routing.allocation.disk.watermark.high=1b | ||
- cluster.routing.allocation.disk.watermark.flood_stage=1b | ||
- script.max_compilations_rate=2048/1m | ||
- node.store.allow_mmap=false | ||
- xpack.security.enabled=true | ||
- xpack.security.transport.ssl.enabled=true | ||
- xpack.security.http.ssl.enabled=true | ||
- xpack.security.authc.token.enabled=true | ||
- xpack.security.audit.enabled=true | ||
- xpack.security.authc.realms.file.file1.order=0 | ||
- xpack.security.authc.realms.native.native1.order=1 | ||
- xpack.security.transport.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks | ||
- xpack.security.http.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks | ||
- xpack.http.ssl.verification_mode=certificate | ||
- xpack.security.transport.ssl.verification_mode=certificate | ||
- xpack.license.self_generated.type=trial | ||
volumes: | ||
- ./build/repo:/tmp/es-repo | ||
- ./build/certs/testnode.jks:/usr/share/elasticsearch/config/testnode.jks | ||
- ./build/logs/default-2:/usr/share/elasticsearch/logs | ||
- ./docker-test-entrypoint.sh:/docker-test-entrypoint.sh | ||
ports: | ||
- "9200" | ||
ulimits: | ||
memlock: | ||
soft: -1 | ||
hard: -1 | ||
entrypoint: /docker-test-entrypoint.sh | ||
elasticsearch-oss-1: | ||
build: | ||
context: ./build/oss-docker | ||
environment: | ||
- node.name=elasticsearch-oss-1 | ||
- cluster.initial_master_nodes=elasticsearch-oss-1,elasticsearch-oss-2 | ||
- discovery.seed_hosts=elasticsearch-oss-2:9300 | ||
- cluster.name=elasticsearch-oss | ||
- bootstrap.memory_lock=true | ||
- "ES_JAVA_OPTS=-Xms512m -Xmx512m" | ||
- path.repo=/tmp/es-repo | ||
- node.attr.testattr=test | ||
- cluster.routing.allocation.disk.watermark.low=1b | ||
- cluster.routing.allocation.disk.watermark.high=1b | ||
- cluster.routing.allocation.disk.watermark.flood_stage=1b | ||
- script.max_compilations_rate=2048/1m | ||
- node.store.allow_mmap=false | ||
volumes: | ||
- ./build/oss-repo:/tmp/es-repo | ||
- ./build/logs/oss-1:/usr/share/elasticsearch/logs | ||
ports: | ||
- "9200" | ||
ulimits: | ||
memlock: | ||
soft: -1 | ||
hard: -1 | ||
elasticsearch-oss-2: | ||
build: | ||
context: ./build/oss-docker | ||
dockerfile: Dockerfile | ||
environment: | ||
- node.name=elasticsearch-oss-2 | ||
- cluster.initial_master_nodes=elasticsearch-oss-1,elasticsearch-oss-2 | ||
- discovery.seed_hosts=elasticsearch-oss-1:9300 | ||
- cluster.name=elasticsearch-oss | ||
- discovery.type=single-node | ||
- bootstrap.memory_lock=true | ||
- "ES_JAVA_OPTS=-Xms512m -Xmx512m" | ||
- path.repo=/tmp/es-repo | ||
- node.attr.testattr=test | ||
- cluster.routing.allocation.disk.watermark.low=1b | ||
- cluster.routing.allocation.disk.watermark.high=1b | ||
- cluster.routing.allocation.disk.watermark.flood_stage=1b | ||
- script.max_compilations_rate=2048/1m | ||
- node.store.allow_mmap=false | ||
volumes: | ||
- ./build/oss-repo:/tmp/es-repo | ||
- ./build/logs/oss-2:/usr/share/elasticsearch/logs | ||
ports: | ||
- "9200" | ||
ulimits: | ||
memlock: | ||
soft: -1 | ||
hard: -1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
cd /usr/share/elasticsearch/bin/ | ||
./elasticsearch-users useradd x_pack_rest_user -p x-pack-test-password -r superuser || true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we do these with docker exec instead of modifying the entry point? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rather not. The test fixtures are transparent w.r.t the technology used to implement them. In general there's nothing docker specific in the build scripts, and the plugin disables everything that can't run if docker is not available. I would like to keep this and thus avoid using docker exec. Maybe this is a generic enough use-case to add env vars for creating a super-user when bringing up the container if these are present ? |
||
echo "testnode" > /tmp/password | ||
cat /tmp/password | ./elasticsearch-keystore add -x -f -v 'xpack.security.transport.ssl.keystore.secure_password' | ||
cat /tmp/password | ./elasticsearch-keystore add -x -f -v 'xpack.security.http.ssl.keystore.secure_password' | ||
/usr/local/bin/docker-entrypoint.sh > /usr/share/elasticsearch/logs/console.log | ||
mark-vieira marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.