-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: mgodwan <[email protected]>
- Loading branch information
Showing
4 changed files
with
354 additions
and
0 deletions.
There are no files selected for viewing
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 @@ | ||
name: Test Custom Codecs BWC | ||
on: | ||
push: | ||
branches: | ||
- "*" | ||
pull_request: | ||
branches: | ||
- "*" | ||
|
||
jobs: | ||
Get-CI-Image-Tag: | ||
uses: opensearch-project/opensearch-build/.github/workflows/get-ci-image-tag.yml@main | ||
with: | ||
product: opensearch | ||
|
||
Build-custom-codecs-linux: | ||
needs: Get-CI-Image-Tag | ||
strategy: | ||
matrix: | ||
java: [11,17,21] | ||
fail-fast: false | ||
|
||
name: Test Custom Codecs BWC | ||
runs-on: ubuntu-latest | ||
container: | ||
# using the same image which is used by opensearch-build team to build the OpenSearch Distribution | ||
# this image tag is subject to change as more dependencies and updates will arrive over time | ||
image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }} | ||
# need to switch to root so that github actions can install runner binary on container without permission issues. | ||
options: --user root | ||
|
||
steps: | ||
- name: Setup Java ${{ matrix.java }} | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: ${{ matrix.java }} | ||
|
||
# custom-codecs | ||
- name: Checkout Custom codecs | ||
uses: actions/checkout@v3 | ||
|
||
- name: Assemble custom-codecs | ||
run: | | ||
plugin_version=`./gradlew properties -q | grep "opensearch_build:" | awk '{print $2}'` | ||
chown -R 1000:1000 `pwd` | ||
echo plugin_version $plugin_version | ||
su `id -un 1000` -c "./gradlew assemble" | ||
echo "Creating ./src/test/resources/org/opensearch/customcodecs/bwc/custom-codecs/custom-codecs/$plugin_version ..." | ||
su `id -un 1000` -c "mkdir -p ./src/test/resources/org/opensearch/customcodecs/bwc/custom-codecs/$plugin_version" | ||
echo "Copying ./build/distributions/*.zip to ./src/test/resources/org/opensearch/customcodecs/bwc/custom-codecs/$plugin_version ..." | ||
ls ./build/distributions/ | ||
su `id -un 1000` -c "cp ./build/distributions/*.zip ./src/test/resources/org/opensearch/customcodecs/bwc/custom-codecs/$plugin_version" | ||
echo "Copied ./build/distributions/*.zip to ./src/test/resources/org/opensearch/customcodecs/bwc/custom-codecs/$plugin_version ..." | ||
ls ./src/test/resources/org/opensearch/customcodecs/bwc/custom-codecs/$plugin_version | ||
- name: Run Custom Codecs Backwards Compatibility Tests | ||
run: | | ||
echo "Running backwards compatibility tests ..." | ||
chown -R 1000:1000 `pwd` | ||
su `id -un 1000` -c "./gradlew bwcTestSuite -Dtests.security.manager=false --debug" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
function usage() { | ||
echo "" | ||
echo "This script is used to run Backwards Compatibility tests" | ||
echo "--------------------------------------------------------------------------" | ||
echo "Usage: $0 [args]" | ||
echo "" | ||
echo "Required arguments:" | ||
echo "None" | ||
echo "" | ||
echo -e "-h\tPrint this message." | ||
echo "--------------------------------------------------------------------------" | ||
} | ||
|
||
while getopts ":h" arg; do | ||
case $arg in | ||
h) | ||
usage | ||
exit 1 | ||
;; | ||
?) | ||
echo "Invalid option: -${OPTARG}" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
./gradlew bwcTestSuite -Dtests.security.manager=false |
83 changes: 83 additions & 0 deletions
83
src/test/java/org/opensearch/index/codec/customcodecs/bwc/SampleBWCIT.java
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,83 @@ | ||
package org.opensearch.index.codec.customcodecs.bwc; | ||
|
||
import org.junit.Before; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.test.rest.OpenSearchRestTestCase; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class SampleBWCIT extends OpenSearchRestTestCase { | ||
|
||
private static final ClusterType CLUSTER_TYPE = ClusterType.parse(System.getProperty("tests.rest.bwcsuite")); | ||
// private static final String CLUSTER_NAME = System.getProperty("tests.clustername"); | ||
// private static final String MIXED_CLUSTER_TEST_ROUND = System.getProperty("tests.rest.bwcsuite_round"); | ||
private String dataIndexName = "test_data_for_ad_plugin"; | ||
private int detectionIntervalInMinutes = 1; | ||
private int windowDelayIntervalInMinutes = 1; | ||
private String aggregationMethod = "sum"; | ||
private int totalDocsPerCategory = 10_000; | ||
private int categoryFieldSize = 2; | ||
private List<String> runningRealtimeDetectors; | ||
private List<String> historicalDetectors; | ||
|
||
@Override | ||
@Before | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
this.runningRealtimeDetectors = new ArrayList<>(); | ||
this.historicalDetectors = new ArrayList<>(); | ||
} | ||
|
||
@Override | ||
protected final boolean preserveIndicesUponCompletion() { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected final boolean preserveReposUponCompletion() { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected boolean preserveTemplatesUponCompletion() { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected final Settings restClientSettings() { | ||
return Settings | ||
.builder() | ||
.put(super.restClientSettings()) | ||
// increase the timeout here to 90 seconds to handle long waits for a green | ||
// cluster health. the waits for green need to be longer than a minute to | ||
// account for delayed shards | ||
.put(OpenSearchRestTestCase.CLIENT_SOCKET_TIMEOUT, "90s") | ||
.build(); | ||
} | ||
|
||
private enum ClusterType { | ||
OLD, | ||
MIXED, | ||
UPGRADED; | ||
|
||
public static ClusterType parse(String value) { | ||
switch (value) { | ||
case "old_cluster": | ||
return OLD; | ||
case "mixed_cluster": | ||
return MIXED; | ||
case "upgraded_cluster": | ||
return UPGRADED; | ||
default: | ||
throw new AssertionError("unknown cluster type: " + value); | ||
} | ||
} | ||
} | ||
|
||
|
||
@SuppressWarnings("unchecked") | ||
public void testBackwardsCompatibility() throws Exception { | ||
logger.info("Cluster type ::: -> " + CLUSTER_TYPE); | ||
} | ||
} |