Skip to content

Commit

Permalink
Add Windows IntegTest support on Jenkins Libs (#308)
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Zhu <[email protected]>
  • Loading branch information
peterzhuamazon authored Sep 13, 2023
1 parent e4e7078 commit 96b32c7
Show file tree
Hide file tree
Showing 11 changed files with 3,218 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jacocoTestReport {
}
}

String version = '5.8.0'
String version = '5.9.0'

task updateVersion {
doLast {
Expand Down
4 changes: 4 additions & 0 deletions src/jenkins/BuildManifest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ class BuildManifest implements Serializable {
return this.build.architecture
}

public String getArtifactPlatform() {
return this.build.platform
}

public String getArtifactBuildId() {
return this.build.id
}
Expand Down
3,015 changes: 3,015 additions & 0 deletions tests/data/opensearch-2.8.0-build-windows.yml

Large diffs are not rendered by default.

132 changes: 132 additions & 0 deletions tests/data/opensearch-2.8.0-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
schema-version: '1.0'
name: OpenSearch
ci:
image:
name: opensearchstaging/ci-runner:ci-runner-centos7-opensearch-build-v2
args: -e JAVA_HOME=/opt/java/openjdk-17
components:
- name: alerting
integ-test:
test-configs:
- with-security
- without-security
additional-cluster-configs:
plugins.destination.host.deny_list: [10.0.0.0/8, 127.0.0.1]
bwc-test:
test-configs:
- with-security

- name: anomaly-detection
integ-test:
build-dependencies:
- job-scheduler
test-configs:
- with-security
- without-security
bwc-test:
test-configs:
- with-security

- name: asynchronous-search
integ-test:
test-configs:
- with-security
- without-security

- name: cross-cluster-replication
integ-test:
topology:
- cluster_name: leader
data_nodes: 1
cluster_manager_nodes: 0
- cluster_name: follower
data_nodes: 1
cluster_manager_nodes: 0
test-configs:
- with-security
- without-security

- name: geospatial
integ-test:
test-configs:
- with-security
- without-security

- name: index-management
integ-test:
build-dependencies:
- job-scheduler
test-configs:
- with-security
- without-security
additional-cluster-configs:
path.repo: [/tmp]
bwc-test:
test-configs:
- with-security

- name: k-NN
integ-test:
test-configs:
- with-security
- without-security

- name: ml-commons
integ-test:
test-configs:
- with-security
- without-security

- name: neural-search
integ-test:
test-configs:
- with-security
- without-security

- name: notifications
working-directory: notifications
integ-test:
test-configs:
- with-security
- without-security
bwc-test:
test-configs:
- with-security

- name: opensearch-observability
integ-test:
test-configs:
- with-security
- without-security
bwc-test:
test-configs:
- with-security

- name: opensearch-reports
integ-test:
test-configs:
- with-security
- without-security

- name: security
integ-test:
test-configs:
- with-security

- name: security-analytics
integ-test:
test-configs:
- with-security
- without-security

- name: sql
integ-test:
test-configs:
- with-security
- without-security
additional-cluster-configs:
script.context.field.max_compilations_rate: 1000/1m
bwc-test:
test-configs:
- with-security
17 changes: 17 additions & 0 deletions tests/jenkins/TestRunIntegTestScript.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,23 @@ class TestRunIntegTestScript extends BuildPipelineTest {
super.testPipeline("tests/jenkins/jobs/RunIntegTestScript_LocalPath_Switch_Non_Root_Jenkinsfile")
}

@Test
void 'IntegTest Windows Zip'() {
this.registerLibTester(new RunIntegTestScriptLibTester(
'dummy_job',
'OpenSearch',
'tests/data/opensearch-2.8.0-build-windows.yml',
'tests/data/opensearch-2.8.0-test.yml',
'',
'',
)
)
super.setUp()
runScript("tests/jenkins/jobs/RunIntegTestScript_Windows_Jenkinsfile")
assertThat(getShellCommands('sh', 'test.sh'), hasItems('env PATH=$PATH ./test.sh integ-test tests/data/opensearch-2.8.0-test.yml --component OpenSearch --test-run-id 987 --paths opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/2.8.0/7923/windows/x64/zip --base-path https://dummy_link/dummy_integ_test/2.8.0/7923/windows/x64/zip '))

}

@Test
void 'IntegTest LocalPath SwitchNonRoot=false'() {
this.registerLibTester(new RunIntegTestScriptLibTester(
Expand Down
4 changes: 3 additions & 1 deletion tests/jenkins/jobs/RunIntegTestScript_Jenkinsfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
runIntegTestScript.library({identifier=jenkins@main, retriever=null})
runIntegTestScript.readYaml({file=tests/data/opensearch-1.3.0-build.yml})
BuildManifest.asBoolean()
BuildManifest.getArtifactArchitecture()
BuildManifest.getDistribution()
runIntegTestScript.echo(Start integTest for distribution type: tar)
BuildManifest.getArtifactPlatform()
runIntegTestScript.echo(Start integTest on: tar x64 linux)
runIntegTestScript.echo(Possible Java Home: )
runIntegTestScript.echo(Build Id: c3ff7a232d25403fa8cc14c97799c323)
BuildManifest.getArtifactRootUrl(dummy_job, c3ff7a232d25403fa8cc14c97799c323)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
runIntegTestScript.library({identifier=jenkins@main, retriever=null})
runIntegTestScript.readYaml({file=tests/data/opensearch-1.3.0-build.yml})
BuildManifest.asBoolean()
BuildManifest.getArtifactArchitecture()
BuildManifest.getDistribution()
runIntegTestScript.echo(Start integTest for distribution type: tar)
BuildManifest.getArtifactPlatform()
runIntegTestScript.echo(Start integTest on: tar x64 linux)
runIntegTestScript.echo(Possible Java Home: )
runIntegTestScript.echo(Build Id: c3ff7a232d25403fa8cc14c97799c323)
BuildManifest.getArtifactRootUrl(dummy_job, c3ff7a232d25403fa8cc14c97799c323)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
runIntegTestScript.library({identifier=jenkins@main, retriever=null})
runIntegTestScript.readYaml({file=tests/data/opensearch-1.3.0-build.yml})
BuildManifest.asBoolean()
BuildManifest.getArtifactArchitecture()
BuildManifest.getDistribution()
runIntegTestScript.echo(Start integTest for distribution type: tar)
BuildManifest.getArtifactPlatform()
runIntegTestScript.echo(Start integTest on: tar x64 linux)
runIntegTestScript.detectTestDockerAgent({testManifest=tests/data/opensearch-1.3.0-test.yml})
detectTestDockerAgent.legacySCM(groovy.lang.Closure)
detectTestDockerAgent.library({identifier=jenkins@main, retriever=null})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
runIntegTestScript.library({identifier=jenkins@main, retriever=null})
runIntegTestScript.readYaml({file=tests/data/opensearch-dashboards-1.2.0-build.yml})
BuildManifest.asBoolean()
BuildManifest.getArtifactArchitecture()
BuildManifest.getDistribution()
runIntegTestScript.echo(Start integTest for distribution type: tar)
BuildManifest.getArtifactPlatform()
runIntegTestScript.echo(Start integTest on: tar x64 linux)
runIntegTestScript.echo(Possible Java Home: )
runIntegTestScript.echo(Build Id: 215)
BuildManifest.getArtifactRootUrl(dummy_job, 215)
Expand Down
26 changes: 26 additions & 0 deletions tests/jenkins/jobs/RunIntegTestScript_Windows_Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

pipeline {
agent none
stages {
stage('integ-test') {
steps {
script {
runIntegTestScript(
jobName: 'dummy_job',
componentName: 'OpenSearch',
buildManifest: 'tests/data/opensearch-2.8.0-build-windows.yml',
testManifest: 'tests/data/opensearch-2.8.0-test.yml',
)
}
}
}
}
}
13 changes: 11 additions & 2 deletions vars/runIntegTestScript.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,19 @@ void call(Map args = [:]) {
String jobName = args.jobName ?: 'distribution-build-opensearch'
def buildManifest = lib.jenkins.BuildManifest.new(readYaml(file: args.buildManifest))

echo "Start integTest for distribution type: " + buildManifest.getDistribution()
String architecture = buildManifest.getArtifactArchitecture()
String distribution = buildManifest.getDistribution()
String platform = buildManifest.getArtifactPlatform()
echo "Start integTest on: " + distribution + " " + architecture + " " + platform

javaVersion = (jobName.equals('distribution-build-opensearch')) ? detectTestDockerAgent(testManifest: args.testManifest).javaVersion : ''
def javaVersion = (jobName.equals('distribution-build-opensearch')) ? detectTestDockerAgent(testManifest: args.testManifest).javaVersion : ''
String javaHomeCommand = (jobName.equals('distribution-build-opensearch') && ! javaVersion.equals('')) ? "JAVA_HOME=/opt/java/${javaVersion}" : ''
if (platform.equals('windows')) { // Windows use scoop to switch the Java Version
String javaVersionNumber = javaVersion.replaceAll("[^0-9]", "") // Only get number
echo("Switching to Java ${javaVersionNumber} on Windows Docker Container")
sh("scoop reset `scoop list jdk | grep ${javaVersionNumber} | head -1 | cut -d ' ' -f1`")
javaHomeCommand = ''
}
echo "Possible Java Home: ${javaHomeCommand}"

String buildId = buildManifest.build.id
Expand Down

0 comments on commit 96b32c7

Please sign in to comment.