forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better support for multi cluster for run task (elastic#89442)
This commit introduces a `./gradlew run-ccs` task with the following goals: * mirror the ease of use of `./gradlew run` for manual cross cluster search development * same credentials * same well known ports * uses ccs specific naming * enable debugging across both clusters This is admittedly kinda hacky. Test clusters have support multi-cluster and are in use for for automated testing. There are some nuances that make that setup (and this setup) a bit cumbersome..specifically needing to read one cluster's config to configure another cluster. The run task adds a bit more config (well defined ports, etc.) than the tests need to so that also complicates this abit more. I found that without the additions here I was unable to get both sharing of cluster configuration (like in the [tests](https://github.com/elastic/elasticsearch/blob/main/qa/ccs-common-rest/build.gradle#L55)) and the run task's hard coded config to work well together. Hopefully the additions to the run task are not too hacky as I could not find any other way.
- Loading branch information
1 parent
3c2fc5a
commit 20ed7e3
Showing
5 changed files
with
100 additions
and
6 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
build-tools-internal/src/main/groovy/elasticsearch.run-ccs.gradle
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,60 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import org.elasticsearch.gradle.testclusters.DefaultTestClustersTask | ||
import org.elasticsearch.gradle.testclusters.RunTask | ||
|
||
boolean proxyMode = true; | ||
|
||
def fulfillingCluster = testClusters.register('fulfilling-cluster') { | ||
setting 'xpack.watcher.enabled', 'false' | ||
setting 'xpack.ml.enabled', 'false' | ||
setting 'xpack.license.self_generated.type', 'trial' | ||
|
||
user username: 'elastic-admin', password: 'elastic-password', role: '_es_test_root' | ||
} | ||
|
||
def queryingCluster = testClusters.register('querying-cluster') { | ||
setting 'xpack.watcher.enabled', 'false' | ||
setting 'xpack.ml.enabled', 'false' | ||
setting 'xpack.license.self_generated.type', 'trial' | ||
if (proxyMode) { | ||
setting 'cluster.remote.my_remote_cluster.mode', 'proxy' | ||
setting 'cluster.remote.my_remote_cluster.proxy_address', { | ||
"\"${fulfillingCluster.get().getAllTransportPortURI().get(0)}\"" | ||
} | ||
} else { | ||
setting 'cluster.remote.my_remote_cluster.seeds', { | ||
fulfillingCluster.get().getAllTransportPortURI().collect { "\"$it\"" }.toString() | ||
} | ||
} | ||
setting 'cluster.remote.connections_per_cluster', "1" | ||
|
||
user username: 'elastic-admin', password: 'elastic-password', role: '_es_test_root' | ||
} | ||
|
||
// the following task is needed to make sure the fulfilling cluster is fully configured before starting both clusters | ||
// this allows the quering cluster to use configuration from the fulfilling cluster while honoring the RunTasks configuration (such as use port 9200) | ||
tasks.register('initfulfillingCluster', RunTask) { | ||
useCluster testClusters.named("fulfilling-cluster") | ||
initOnly = true //only initialize the testCluster, don't start it | ||
portOffset = 1 //when only initializing, instruct to use one above the normal ports to avoid collisions when other cluster also initializes | ||
//debug = true //this task doesn't honor the command line options for run-ccs, so need to statically configure debug | ||
} | ||
|
||
tasks.register("run-ccs", RunTask) { | ||
dependsOn initfulfillingCluster | ||
useCluster testClusters.named("fulfilling-cluster") | ||
useCluster testClusters.named("querying-cluster") | ||
doFirst { | ||
println "** Querying cluster HTTP endpoints are: ${-> queryingCluster.get().allHttpSocketURI.join(",")}" | ||
println "** Querying cluster transport endpoints are: ${-> queryingCluster.get().getAllTransportPortURI().join(",")}" | ||
println "** Fulfilling cluster HTTP endpoints are: ${-> fulfillingCluster.get().allHttpSocketURI.join(",")}" | ||
println "** Fulfilling cluster transport endpoints are: ${-> fulfillingCluster.get().getAllTransportPortURI().join(",")}" | ||
} | ||
} |
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