Skip to content
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

simplify ./gradlew run-ccs #89711

Merged
merged 2 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions TESTING.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@ You can also place this config in custom init script (see above) to avoid accide
If you are passing in the --debug-jvm flag with multiple nodes, you will need multiple remote debuggers running. One
for each node listening at port 5007, 5008, 5009, and so on. Ensure that each remote debugger has auto restart enabled.

==== Manually testing cross cluster search

Use ./gradlew run-ccs to launch 2 clusters wired together for the purposes of cross cluster search.
For example send a search request "my_remote_cluster:*/_search" to the querying cluster (:9200) to query data
in the fulfilling cluster.

If you are passing in the --debug-jvm flag, you will need two remote debuggers running. One at port 5007 and another
one at port 5008. Ensure that each remote debugger has auto restart enabled.

=== Test case filtering.

You can run a single test, provided that you specify the Gradle project. See the documentation on
Expand Down
37 changes: 13 additions & 24 deletions build-tools-internal/src/main/groovy/elasticsearch.run-ccs.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
* Side Public License, v 1.
*/

import org.elasticsearch.gradle.testclusters.DefaultTestClustersTask
import org.elasticsearch.gradle.testclusters.RunTask

boolean proxyMode = true;
boolean proxyMode = Boolean.valueOf(providers.systemProperty('proxyMode').getOrElse('true'))

def fulfillingCluster = testClusters.register('fulfilling-cluster') {
setting 'xpack.watcher.enabled', 'false'
Expand All @@ -23,35 +22,25 @@ 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")
useCluster fulfillingCluster
useCluster queryingCluster
doFirst {
queryingCluster.get().getNodes().each { node ->
if (proxyMode) {
node.setting('cluster.remote.my_remote_cluster.mode', 'proxy')
node.setting('cluster.remote.my_remote_cluster.proxy_address', "\"${fulfillingCluster.get().getAllTransportPortURI().get(0)}\"")
} else {
node.setting('cluster.remote.my_remote_cluster.seeds', fulfillingCluster.get().getAllTransportPortURI().collect { "\"$it\"" }.toString())
}
}
queryingCluster.get().restart() //updates the on-disk config
Copy link
Contributor Author

@jakelandis jakelandis Aug 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the main change. specifically calling .restart() to update the configuration on disk


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(",")}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,12 @@ public class RunTask extends DefaultTestClustersTask {

private Boolean debug = false;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all changes are part of the revert

private Boolean initOnly = false;

private Boolean preserveData = false;

private Path dataDir = null;

private String keystorePassword = "";

private Integer offset = 0;

@Option(option = "debug-jvm", description = "Enable debugging configuration, to allow attaching a debugger to elasticsearch.")
public void setDebug(boolean enabled) {
this.debug = enabled;
Expand Down Expand Up @@ -90,36 +86,10 @@ public String getDataDir() {
return dataDir.toString();
}

@Input
@Optional
Boolean getInitOnly() {
return initOnly;
}

/**
* Only initialize, but don't actually run. This is useful for multi-cluster run tasks.
*/
public void setInitOnly(Boolean initOnly) {
this.initOnly = initOnly;
}

@Input
@Optional
public Integer getPortOffset() {
return offset;
}

/**
* Manually increase the port offset. This is useful for multi-cluster run tasks.
*/
public void setPortOffset(Integer offset) {
this.offset = offset;
}

@Override
public void beforeStart() {
int httpPort = 9200 + offset;
int transportPort = 9300 + offset;
int httpPort = 9200;
int transportPort = 9300;
Map<String, String> additionalSettings = System.getProperties()
.entrySet()
.stream()
Expand Down Expand Up @@ -153,15 +123,12 @@ public void beforeStart() {
}
}
if (debug) {
enableDebug(getPortOffset());
enableDebug();
}
}

@TaskAction
public void runAndWait() throws IOException {
if (initOnly) {
return;
}
List<BufferedReader> toRead = new ArrayList<>();
List<BooleanSupplier> aliveChecks = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public WorkResult delete(Object... objects) {
@Override
public void beforeStart() {
if (debugServer) {
enableDebug(0);
enableDebug();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

part of the revert

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ default void useCluster(Provider<ElasticsearchCluster> cluster) {

default void beforeStart() {}

default void enableDebug(int portOffset) {
int debugPort = 5007 + portOffset;
default void enableDebug() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

part of the revert

int debugPort = 5007;
for (ElasticsearchCluster cluster : getClusters()) {
for (ElasticsearchNode node : cluster.getNodes()) {
getLogger().lifecycle("Running elasticsearch in debug mode, {} expecting running debug server on port {}", node, debugPort);
Expand Down