Skip to content

Commit a9e5d39

Browse files
authored
Split bwc-tests to bwc-rolling-upgrade and bwc-full-restart (#4716)
Signed-off-by: Lantao Jin <[email protected]>
1 parent a003e8c commit a9e5d39

File tree

4 files changed

+201
-93
lines changed

4 files changed

+201
-93
lines changed

.github/workflows/sql-test-and-build-workflow.yml

Lines changed: 81 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ jobs:
179179
doctest/build/testclusters/docTestCluster-0/logs/*
180180
integ-test/build/testclusters/*/logs/*
181181
182-
bwc-tests:
182+
bwc-tests-rolling-upgrade:
183183
needs: Get-CI-Image-Tag
184184
runs-on: ubuntu-latest
185185
strategy:
@@ -190,37 +190,83 @@ jobs:
190190
options: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }}
191191

192192
steps:
193-
- name: Run start commands
194-
run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }}
195-
196-
- uses: actions/checkout@v4
197-
198-
- name: Set up JDK ${{ matrix.java }}
199-
uses: actions/setup-java@v4
200-
with:
201-
distribution: 'temurin'
202-
java-version: ${{ matrix.java }}
203-
204-
- name: Run backward compatibility tests
205-
run: |
206-
chown -R 1000:1000 `pwd`
207-
su `id -un 1000` -c "./scripts/bwctest.sh"
208-
209-
- name: Upload test reports
210-
if: ${{ always() }}
211-
uses: actions/upload-artifact@v4
212-
continue-on-error: true
213-
with:
214-
name: test-reports-ubuntu-latest-${{ matrix.java }}-bwc
215-
path: |
216-
sql/build/reports/**
217-
ppl/build/reports/**
218-
core/build/reports/**
219-
common/build/reports/**
220-
opensearch/build/reports/**
221-
integ-test/build/reports/**
222-
protocol/build/reports/**
223-
legacy/build/reports/**
224-
plugin/build/reports/**
225-
doctest/build/testclusters/docTestCluster-0/logs/*
226-
integ-test/build/testclusters/*/logs/*
193+
- name: Run start commands
194+
run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }}
195+
196+
- uses: actions/checkout@v4
197+
198+
- name: Set up JDK ${{ matrix.java }}
199+
uses: actions/setup-java@v4
200+
with:
201+
distribution: 'temurin'
202+
java-version: ${{ matrix.java }}
203+
204+
- name: Run backward compatibility tests in rolling upgrade
205+
run: |
206+
chown -R 1000:1000 `pwd`
207+
su `id -un 1000` -c "./scripts/bwctest-rolling-upgrade.sh"
208+
209+
- name: Upload test reports
210+
if: ${{ always() }}
211+
uses: actions/upload-artifact@v4
212+
continue-on-error: true
213+
with:
214+
name: test-reports-ubuntu-latest-${{ matrix.java }}-bwc
215+
path: |
216+
sql/build/reports/**
217+
ppl/build/reports/**
218+
core/build/reports/**
219+
common/build/reports/**
220+
opensearch/build/reports/**
221+
integ-test/build/reports/**
222+
protocol/build/reports/**
223+
legacy/build/reports/**
224+
plugin/build/reports/**
225+
doctest/build/testclusters/docTestCluster-0/logs/*
226+
integ-test/build/testclusters/*/logs/*
227+
228+
bwc-tests-full-restart:
229+
needs: Get-CI-Image-Tag
230+
runs-on: ubuntu-latest
231+
strategy:
232+
matrix:
233+
java: [21, 24]
234+
container:
235+
image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }}
236+
options: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }}
237+
238+
steps:
239+
- name: Run start commands
240+
run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }}
241+
242+
- uses: actions/checkout@v4
243+
244+
- name: Set up JDK ${{ matrix.java }}
245+
uses: actions/setup-java@v4
246+
with:
247+
distribution: 'temurin'
248+
java-version: ${{ matrix.java }}
249+
250+
- name: Run backward compatibility tests in full restart
251+
run: |
252+
chown -R 1000:1000 `pwd`
253+
su `id -un 1000` -c "./scripts/bwctest-full-restart.sh"
254+
255+
- name: Upload test reports
256+
if: ${{ always() }}
257+
uses: actions/upload-artifact@v4
258+
continue-on-error: true
259+
with:
260+
name: test-reports-ubuntu-latest-${{ matrix.java }}-bwc
261+
path: |
262+
sql/build/reports/**
263+
ppl/build/reports/**
264+
core/build/reports/**
265+
common/build/reports/**
266+
opensearch/build/reports/**
267+
integ-test/build/reports/**
268+
protocol/build/reports/**
269+
legacy/build/reports/**
270+
plugin/build/reports/**
271+
doctest/build/testclusters/docTestCluster-0/logs/*
272+
integ-test/build/testclusters/*/logs/*

integ-test/build.gradle

Lines changed: 61 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -592,101 +592,96 @@ task comparisonTest(type: RestIntegTestTask) {
592592
systemProperty "queries", System.getProperty("queries")
593593
}
594594

595-
2.times { i ->
596-
testClusters {
597-
"${baseName}$i" {
598-
testDistribution = "ARCHIVE"
599-
versions = [baseVersion, opensearch_version]
600-
numberOfNodes = 3
601-
plugin(provider { (RegularFile) (() -> {
602-
if (new File("$project.rootDir/$bwcFilePath/job-scheduler/$bwcVersion").exists()) {
603-
project.delete(files("$project.rootDir/$bwcFilePath/job-scheduler/$bwcVersion"))
604-
}
605-
project.mkdir bwcJobSchedulerPath + bwcVersion
606-
ant.get(src: bwcOpenSearchJSDownload,
607-
dest: bwcJobSchedulerPath + bwcVersion,
608-
httpusecaches: false)
609-
return fileTree(bwcJobSchedulerPath + bwcVersion).getSingleFile()
610-
})})
611-
plugin(provider { (RegularFile) (() -> {
612-
return configurations.zipArchive.asFileTree.matching {
613-
include '**/opensearch-sql-plugin*'
614-
}.singleFile
615-
})})
616-
setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
617-
setting 'http.content_type.required', 'true'
618-
}
595+
testClusters {
596+
"${baseName}" {
597+
testDistribution = "ARCHIVE"
598+
versions = [baseVersion, opensearch_version]
599+
numberOfNodes = 3
600+
plugin(provider { (RegularFile) (() -> {
601+
if (new File("$project.rootDir/$bwcFilePath/job-scheduler/$bwcVersion").exists()) {
602+
project.delete(files("$project.rootDir/$bwcFilePath/job-scheduler/$bwcVersion"))
603+
}
604+
project.mkdir bwcJobSchedulerPath + bwcVersion
605+
ant.get(src: bwcOpenSearchJSDownload,
606+
dest: bwcJobSchedulerPath + bwcVersion,
607+
httpusecaches: false)
608+
return fileTree(bwcJobSchedulerPath + bwcVersion).getSingleFile()
609+
})})
610+
plugin(provider { (RegularFile) (() -> {
611+
return configurations.zipArchive.asFileTree.matching {
612+
include '**/opensearch-sql-plugin*'
613+
}.singleFile
614+
})})
615+
setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
616+
setting 'http.content_type.required', 'true'
619617
}
620618
}
621-
622619
List<Provider<RegularFile>> plugins = [
623620
getJobSchedulerPlugin(),
624621
provider { (RegularFile) (() ->
625622
fileTree(bwcFilePath + project.version).getSingleFile())
626623
}
627624
]
628625

629-
// Creates 2 test clusters with 3 nodes of the old version.
630-
2.times { i ->
631-
task "${baseName}#oldVersionClusterTask$i"(type: StandaloneRestIntegTestTask) {
632-
useCluster testClusters."${baseName}$i"
633-
filter {
634-
includeTestsMatching "org.opensearch.sql.bwc.*IT"
635-
}
636-
systemProperty 'tests.rest.bwcsuite', 'old_cluster'
637-
systemProperty 'tests.rest.bwcsuite_round', 'old'
638-
systemProperty 'tests.plugin_bwc_version', bwcVersion
639-
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}$i".allHttpSocketURI.join(",")}")
640-
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}$i".getName()}")
626+
// Creates test cluster with 3 nodes of the old version.
627+
task "${baseName}#oldVersionClusterTask"(type: StandaloneRestIntegTestTask) {
628+
useCluster testClusters."${baseName}"
629+
filter {
630+
includeTestsMatching "org.opensearch.sql.bwc.*IT"
641631
}
632+
systemProperty 'tests.rest.bwcsuite', 'old_cluster'
633+
systemProperty 'tests.rest.bwcsuite_round', 'old'
634+
systemProperty 'tests.plugin_bwc_version', bwcVersion
635+
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
636+
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
642637
}
643638

644639
// Upgrade one node of the old cluster to new OpenSearch version with upgraded plugin version.
645640
// This results in a mixed cluster with 2 nodes on the old version and 1 upgraded node.
646641
// This is also used as a one third upgraded cluster for a rolling upgrade.
647642
task "${baseName}#mixedClusterTask"(type: StandaloneRestIntegTestTask) {
648-
useCluster testClusters."${baseName}0"
649-
dependsOn "${baseName}#oldVersionClusterTask0"
643+
useCluster testClusters."${baseName}"
644+
dependsOn "${baseName}#oldVersionClusterTask"
650645
doFirst {
651-
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
646+
testClusters."${baseName}".upgradeNodeAndPluginToNextVersion(plugins)
652647
}
653648
filter {
654649
includeTestsMatching "org.opensearch.sql.bwc.*IT"
655650
}
656651
systemProperty 'tests.rest.bwcsuite', 'mixed_cluster'
657652
systemProperty 'tests.rest.bwcsuite_round', 'first'
658653
systemProperty 'tests.plugin_bwc_version', bwcVersion
659-
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}0".allHttpSocketURI.join(",")}")
660-
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}0".getName()}")
654+
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
655+
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
661656
}
662657

663658
// Upgrade the second node to new OpenSearch version with upgraded plugin version after the first node is upgraded.
664659
// This results in a mixed cluster with 1 node on the old version and 2 upgraded nodes.
665660
// This is used for rolling upgrade.
666661
task "${baseName}#twoThirdsUpgradedClusterTask"(type: StandaloneRestIntegTestTask) {
667662
dependsOn "${baseName}#mixedClusterTask"
668-
useCluster testClusters."${baseName}0"
663+
useCluster testClusters."${baseName}"
669664
doFirst {
670-
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
665+
testClusters."${baseName}".upgradeNodeAndPluginToNextVersion(plugins)
671666
}
672667
filter {
673668
includeTestsMatching "org.opensearch.sql.bwc.*IT"
674669
}
675670
systemProperty 'tests.rest.bwcsuite', 'mixed_cluster'
676671
systemProperty 'tests.rest.bwcsuite_round', 'second'
677672
systemProperty 'tests.plugin_bwc_version', bwcVersion
678-
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}0".allHttpSocketURI.join(",")}")
679-
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}0".getName()}")
673+
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
674+
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
680675
}
681676

682677
// Upgrade the third node to new OpenSearch version with upgraded plugin version after the second node is upgraded.
683678
// This results in a fully upgraded cluster.
684679
// This is used for rolling upgrade.
685680
task "${baseName}#rollingUpgradeClusterTask"(type: StandaloneRestIntegTestTask) {
686681
dependsOn "${baseName}#twoThirdsUpgradedClusterTask"
687-
useCluster testClusters."${baseName}0"
682+
useCluster testClusters."${baseName}"
688683
doFirst {
689-
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
684+
testClusters."${baseName}".upgradeNodeAndPluginToNextVersion(plugins)
690685
}
691686
filter {
692687
includeTestsMatching "org.opensearch.sql.bwc.*IT"
@@ -695,36 +690,45 @@ task "${baseName}#rollingUpgradeClusterTask"(type: StandaloneRestIntegTestTask)
695690
systemProperty 'tests.rest.bwcsuite', 'mixed_cluster'
696691
systemProperty 'tests.rest.bwcsuite_round', 'third'
697692
systemProperty 'tests.plugin_bwc_version', bwcVersion
698-
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}0".allHttpSocketURI.join(",")}")
699-
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}0".getName()}")
693+
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
694+
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
700695
}
701696

702697
// Upgrade all the nodes of the old cluster to new OpenSearch version with upgraded plugin version
703698
// at the same time resulting in a fully upgraded cluster.
704699
task "${baseName}#fullRestartClusterTask"(type: StandaloneRestIntegTestTask) {
705-
dependsOn "${baseName}#oldVersionClusterTask1"
706-
useCluster testClusters."${baseName}1"
700+
dependsOn "${baseName}#oldVersionClusterTask"
701+
useCluster testClusters."${baseName}"
707702
doFirst {
708-
testClusters."${baseName}1".upgradeAllNodesAndPluginsToNextVersion(plugins)
703+
testClusters."${baseName}".upgradeAllNodesAndPluginsToNextVersion(plugins)
709704
}
710705
filter {
711706
includeTestsMatching "org.opensearch.sql.bwc.*IT"
712707
}
713708
systemProperty 'tests.rest.bwcsuite', 'upgraded_cluster'
714709
systemProperty 'tests.plugin_bwc_version', bwcVersion
715-
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}1".allHttpSocketURI.join(",")}")
716-
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}1".getName()}")
710+
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
711+
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
717712
}
718713

719-
// A bwc test suite which runs all the bwc tasks combined
720-
task bwcTestSuite(type: StandaloneRestIntegTestTask) {
714+
// A bwc test suite which runs all the bwc tasks in rolling upgrade
715+
task bwcTestRollingUpgradeSuite(type: StandaloneRestIntegTestTask) {
721716
testLogging {
722717
events "passed", "skipped", "failed"
723718
}
724719
exclude '**/*Test*'
725720
exclude '**/*IT*'
726721
dependsOn tasks.named("${baseName}#mixedClusterTask")
727722
dependsOn tasks.named("${baseName}#rollingUpgradeClusterTask")
723+
}
724+
725+
// A bwc test suite which runs all the bwc tasks in full restart
726+
task bwcTestFullRestartSuite(type: StandaloneRestIntegTestTask) {
727+
testLogging {
728+
events "passed", "skipped", "failed"
729+
}
730+
exclude '**/*Test*'
731+
exclude '**/*IT*'
728732
dependsOn tasks.named("${baseName}#fullRestartClusterTask")
729733
}
730734

scripts/bwctest.sh renamed to scripts/bwctest-full-restart.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ function setup_bwc_artifact() {
5454
}
5555

5656
setup_bwc_artifact
57-
./gradlew bwcTestSuite -Dtests.security.manager=false
57+
./gradlew bwcTestFullRestartSuite -Dtests.security.manager=false
5858

scripts/bwctest-rolling-upgrade.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
function usage() {
6+
echo ""
7+
echo "This script is used to run Backwards Compatibility tests"
8+
echo "--------------------------------------------------------------------------"
9+
echo "Usage: $0 [args]"
10+
echo ""
11+
echo "Required arguments:"
12+
echo "None"
13+
echo ""
14+
echo -e "-h\tPrint this message."
15+
echo "--------------------------------------------------------------------------"
16+
}
17+
18+
while getopts ":h" arg; do
19+
case $arg in
20+
h)
21+
usage
22+
exit 1
23+
;;
24+
?)
25+
echo "Invalid option: -${OPTARG}"
26+
exit 1
27+
;;
28+
esac
29+
done
30+
31+
# Place SQL artifact for the current version for bwc
32+
function setup_bwc_artifact() {
33+
# This gets opensearch version from build.gradle (e.g. 1.2.0-SNAPSHOT),
34+
# then converts to plugin version by appending ".0" (e.g. 1.2.0.0-SNAPSHOT),
35+
# assuming one line in build.gradle is 'opensearch_version = System.getProperty("opensearch.version", "<opensearch_version>")'.
36+
plugin_version=$(grep 'opensearch_version = System.getProperty' build.gradle | \
37+
grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+[^"]*' | sed -e 's/\(.*\)\(\.[0-9]\)/\1\2.0/')
38+
plugin_artifact="./plugin/build/distributions/opensearch-sql-$plugin_version.zip"
39+
bwc_artifact_dir="./integ-test/src/test/resources/bwc/$plugin_version"
40+
41+
if [ -z "${plugin_version// }" ]; then
42+
echo "Error: failed to retrieve plugin version from build.gradle." >&2
43+
exit 1
44+
fi
45+
46+
# copy current artifact to bwc artifact directory if it's not there
47+
if [ ! -f "$bwc_artifact_dir/opensearch-sql-$plugin_version.zip" ]; then
48+
if [ ! -f "$plugin_artifact" ]; then
49+
./gradlew assemble
50+
fi
51+
mkdir -p "$bwc_artifact_dir"
52+
cp "$plugin_artifact" "$bwc_artifact_dir"
53+
fi
54+
}
55+
56+
setup_bwc_artifact
57+
./gradlew bwcTestRollingUpgradeSuite -Dtests.security.manager=false
58+

0 commit comments

Comments
 (0)