Skip to content

Commit

Permalink
Adding gradle task for running integ tests in remote cluster (opensea…
Browse files Browse the repository at this point in the history
…rch-project#266)

* Adding gradle task for running integ tests in remote cluster

Signed-off-by: Martin Gaievski <gaievski@amazon.com>
  • Loading branch information
martin-gaievski authored Jan 25, 2022
1 parent eb88771 commit 0258415
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
12 changes: 12 additions & 0 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,18 @@ In order to run the integration tests with a 3 node cluster, run this command:
./gradlew :integTest -PnumNodes=3
```

Integration tests can be run with remote cluster. For that run the following command and replace host/port/cluster name values with ones for the target cluster:

```
./gradlew :integTestRemote -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername="integTest-0" -Dhttps=false -PnumNodes=1
```

In case remote cluster is secured it's possible to pass username and password with the following command:

```
./gradlew :integTestRemote -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername="integTest-0" -Dhttps=true -Duser=admin -Dpassword=admin
```

### Debugging

Sometimes it is useful to attach a debugger to either the OpenSearch cluster or the integration test runner to see what's going on. For running unit tests, hit **Debug** from the IDE's gutter to debug the tests. For the OpenSearch cluster, first, make sure that the debugger is listening on port `5005`. Then, to debug the cluster code, run:
Expand Down
20 changes: 20 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.util.concurrent.Callable
import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask
import org.opensearch.gradle.test.RestIntegTestTask

buildscript {
ext {
Expand Down Expand Up @@ -217,6 +218,25 @@ testClusters.integTest {
systemProperty("java.library.path", "$rootDir/jni/release")
}

task integTestRemote(type: RestIntegTestTask) {
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath

systemProperty "https", System.getProperty("https")
systemProperty "user", System.getProperty("user")
systemProperty "password", System.getProperty("password")

systemProperty 'cluster.number_of_nodes', "${_numNodes}"

// Run tests with remote cluster only if rest case is defined
if (System.getProperty("tests.rest.cluster") != null) {
filter {
includeTestsMatching "org.opensearch.knn.*IT"
excludeTestsMatching "org.opensearch.knn.bwc.*IT"
}
}
}

// bwcFilePath contains the gradlew assemble binary files of k-NN plugins
String baseName = "knnBwcCluster"
String bwcFilePath = "src/test/resources/org/opensearch/knn/bwc/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private void tripCb() throws Exception {
updateClusterSettings("knn.memory.circuit_breaker.limit", "1kb");

// Create index with 1 primary and numNodes-1 replicas so that the data will be on every node in the cluster
int numNodes = Integer.parseInt(System.getProperty("cluster.number_of_nodes"));
int numNodes = Integer.parseInt(System.getProperty("cluster.number_of_nodes", "1"));
Settings settings = Settings.builder()
.put("number_of_shards", 1)
.put("number_of_replicas", numNodes - 1)
Expand Down

0 comments on commit 0258415

Please sign in to comment.