Skip to content

Commit

Permalink
Adding 1.1 test-report.yml support to Jenkins lib (#470)
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Zhu <[email protected]>
  • Loading branch information
peterzhuamazon authored Aug 20, 2024
1 parent f0eeaff commit 571310e
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 38 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jacocoTestReport {
}
}

String version = '6.8.2'
String version = '6.8.3'

task updateVersion {
doLast {
Expand Down
5 changes: 3 additions & 2 deletions tests/jenkins/TestCreateUploadTestReportManifest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ class TestCreateUploadTestReportManifest extends BuildPipelineTest {
)
super.setUp()
super.testPipeline("tests/jenkins/jobs/CreateUploadTestReportManifest_Jenkinsfile")
assertThat(getShellCommands('sh', 'report.sh'), hasItems('./report.sh tests/data/opensearch-1.3.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/29/linux/x64/tar --test-run-id 1234 --test-type integ-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_integ_test/1.3.0/29/linux/x64/tar '))
assertThat(getShellCommands('sh', 'report.sh'), hasItems('./report.sh tests/data/opensearch-dashboards-1.3.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/29/linux/x64/tar opensearch-dashboards=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar --test-run-id 1234 --test-type integ-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_integ_test/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar '))
assertThat(getShellCommands('sh', 'report.sh'), hasItems('./report.sh tests/data/opensearch-1.3.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/29/linux/x64/tar --test-run-id 1234 --test-type integ-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_integ_test/1.3.0/29/linux/x64/tar '))
assertThat(getShellCommands('sh', 'report.sh'), hasItems('./report.sh tests/data/opensearch-dashboards-1.3.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/29/linux/x64/tar opensearch-dashboards=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar --test-run-id 1234 --test-type integ-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_integ_test/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar '))
assertThat(getShellCommands('sh', 'report.sh'), hasItems('./report.sh tests/data/opensearch-dashboards-1.3.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/29/linux/x64/tar opensearch-dashboards=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar --test-run-id 1234 --test-type integ-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_integ_test/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar --release-candidate 100 '))
}

def getShellCommands(methodName, searchString) {
Expand Down
20 changes: 3 additions & 17 deletions tests/jenkins/TestPublishIntegTestResults.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,9 @@ class TestPublishIntegTestResults extends BuildPipelineTest {
void testCallWithMissingArgs() {
def script = loadScript('vars/publishIntegTestResults.groovy')
def args = [
version: "1.0",
distributionBuildNumber: null, // Missing required argument
distributionBuildUrl: "http://example.com/distribution/456",
rc: "rc1",
rcNumber: "1",
platform: "linux",
architecture: "x64",
distribution: "tar",
testReportManifestYml: "path/to/testReportManifest.yml",
jobName: "test-job"
//jobName: "test-job" // Missing required argument
]

def result = script.call(args)
Expand All @@ -279,16 +272,9 @@ class TestPublishIntegTestResults extends BuildPipelineTest {
void testCallWithEmptyArgs() {
def script = loadScript('vars/publishIntegTestResults.groovy')
def args = [
version: "1.0",
distributionBuildNumber: "", // Empty required argument
distributionBuildUrl: "http://example.com/distribution/456",
rc: "rc1",
rcNumber: "1",
platform: "linux",
architecture: "x64",
distribution: "tar",
testReportManifestYml: "path/to/testReportManifest.yml",
jobName: "test-job"
jobName: "" // Empty required argument
]

def result = script.call(args)
Expand All @@ -299,4 +285,4 @@ class TestPublishIntegTestResults extends BuildPipelineTest {
def normalizeString(String str) {
return str.replaceAll(/\s+/, " ").trim()
}
}
}
8 changes: 8 additions & 0 deletions tests/jenkins/jobs/CreateUploadTestReportManifest_Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ pipeline {
testRunID: "1234",
testType: "integ-test",
)
createUploadTestReportManifest(
testManifest: "tests/data/opensearch-dashboards-1.3.0-test.yml",
buildManifest: "tests/data/opensearch-1.3.0-build.yml",
dashboardsBuildManifest: "tests/data/opensearch-dashboards-build-1.3.0.yml",
testRunID: "1234",
testType: "integ-test",
rcNumber: "100",
)
}
}
}
Expand Down
35 changes: 31 additions & 4 deletions tests/jenkins/jobs/CreateUploadTestReportManifest_Jenkinsfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
createUploadTestReportManifest.echo(Paths: opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/29/linux/x64/tar)
createUploadTestReportManifest.echo(Base Path DUMMY_PUBLIC_ARTIFACT_URL/dummy_integ_test/1.3.0/29/linux/x64/tar)
createUploadTestReportManifest.echo(Component: null)
createUploadTestReportManifest.echo(Run command: ./report.sh tests/data/opensearch-1.3.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/29/linux/x64/tar --test-run-id 1234 --test-type integ-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_integ_test/1.3.0/29/linux/x64/tar )
createUploadTestReportManifest.sh(./report.sh tests/data/opensearch-1.3.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/29/linux/x64/tar --test-run-id 1234 --test-type integ-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_integ_test/1.3.0/29/linux/x64/tar )
createUploadTestReportManifest.echo(Run command: ./report.sh tests/data/opensearch-1.3.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/29/linux/x64/tar --test-run-id 1234 --test-type integ-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_integ_test/1.3.0/29/linux/x64/tar )
createUploadTestReportManifest.sh(./report.sh tests/data/opensearch-1.3.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/29/linux/x64/tar --test-run-id 1234 --test-type integ-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_integ_test/1.3.0/29/linux/x64/tar )
createUploadTestReportManifest.echo(Build Id: 29)
BuildManifest.getArtifactRoot(dummy_integ_test, 29)
createUploadTestReportManifest.string({credentialsId=jenkins-artifact-bucket-name, variable=ARTIFACT_BUCKET_NAME})
Expand All @@ -44,8 +44,35 @@
createUploadTestReportManifest.echo(Paths: opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/29/linux/x64/tar opensearch-dashboards=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar)
createUploadTestReportManifest.echo(Base Path DUMMY_PUBLIC_ARTIFACT_URL/dummy_integ_test/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar)
createUploadTestReportManifest.echo(Component: null)
createUploadTestReportManifest.echo(Run command: ./report.sh tests/data/opensearch-dashboards-1.3.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/29/linux/x64/tar opensearch-dashboards=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar --test-run-id 1234 --test-type integ-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_integ_test/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar )
createUploadTestReportManifest.sh(./report.sh tests/data/opensearch-dashboards-1.3.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/29/linux/x64/tar opensearch-dashboards=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar --test-run-id 1234 --test-type integ-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_integ_test/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar )
createUploadTestReportManifest.echo(Run command: ./report.sh tests/data/opensearch-dashboards-1.3.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/29/linux/x64/tar opensearch-dashboards=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar --test-run-id 1234 --test-type integ-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_integ_test/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar )
createUploadTestReportManifest.sh(./report.sh tests/data/opensearch-dashboards-1.3.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/29/linux/x64/tar opensearch-dashboards=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar --test-run-id 1234 --test-type integ-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_integ_test/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar )
createUploadTestReportManifest.echo(Build Id: 25b38c278cdd45efa583765d8ba76346)
BuildManifest.getArtifactRoot(dummy_integ_test, 25b38c278cdd45efa583765d8ba76346)
createUploadTestReportManifest.string({credentialsId=jenkins-artifact-bucket-name, variable=ARTIFACT_BUCKET_NAME})
createUploadTestReportManifest.string({credentialsId=jenkins-aws-account-public, variable=AWS_ACCOUNT_PUBLIC})
createUploadTestReportManifest.withCredentials([ARTIFACT_BUCKET_NAME, AWS_ACCOUNT_PUBLIC], groovy.lang.Closure)
createUploadTestReportManifest.echo(Uploading to s3://dummy_integ_test/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar/test-results/1234/integ-test/test-report.yml)
createUploadTestReportManifest.withAWS({role=opensearch-test, roleAccount=AWS_ACCOUNT_PUBLIC, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure)
createUploadTestReportManifest.s3Upload({file=/tmp/workspace/test-report.yml, bucket=ARTIFACT_BUCKET_NAME, path=dummy_integ_test/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar/test-results/1234/integ-test/test-report.yml})
CreateUploadTestReportManifest_Jenkinsfile.createUploadTestReportManifest({testManifest=tests/data/opensearch-dashboards-1.3.0-test.yml, buildManifest=tests/data/opensearch-1.3.0-build.yml, dashboardsBuildManifest=tests/data/opensearch-dashboards-build-1.3.0.yml, testRunID=1234, testType=integ-test, rcNumber=100})
createUploadTestReportManifest.legacySCM(groovy.lang.Closure)
createUploadTestReportManifest.library({identifier=jenkins@main, retriever=null})
createUploadTestReportManifest.readYaml({file=tests/data/opensearch-dashboards-1.3.0-test.yml})
TestManifest.asBoolean()
createUploadTestReportManifest.readYaml({file=tests/data/opensearch-1.3.0-build.yml})
BuildManifest.asBoolean()
createUploadTestReportManifest.readYaml({file=tests/data/opensearch-dashboards-build-1.3.0.yml})
BuildManifest.asBoolean()
BuildManifest.getDistribution()
createUploadTestReportManifest.echo(Start Reporting workflow for test type: tar)
BuildManifest.getArtifactRootUrl(distribution-build-opensearch, 29)
BuildManifest.getArtifactRootUrl(distribution-build-opensearch-dashboards, 25b38c278cdd45efa583765d8ba76346)
createUploadTestReportManifest.echo(Artifact root URL: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/29/linux/x64/tar)
createUploadTestReportManifest.echo(Paths: opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/29/linux/x64/tar opensearch-dashboards=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar)
createUploadTestReportManifest.echo(Base Path DUMMY_PUBLIC_ARTIFACT_URL/dummy_integ_test/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar)
createUploadTestReportManifest.echo(Component: null)
createUploadTestReportManifest.echo(Run command: ./report.sh tests/data/opensearch-dashboards-1.3.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/29/linux/x64/tar opensearch-dashboards=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar --test-run-id 1234 --test-type integ-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_integ_test/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar --release-candidate 100 )
createUploadTestReportManifest.sh(./report.sh tests/data/opensearch-dashboards-1.3.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/29/linux/x64/tar opensearch-dashboards=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar --test-run-id 1234 --test-type integ-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_integ_test/1.3.0/25b38c278cdd45efa583765d8ba76346/linux/x64/tar --release-candidate 100 )
createUploadTestReportManifest.echo(Build Id: 25b38c278cdd45efa583765d8ba76346)
BuildManifest.getArtifactRoot(dummy_integ_test, 25b38c278cdd45efa583765d8ba76346)
createUploadTestReportManifest.string({credentialsId=jenkins-artifact-bucket-name, variable=ARTIFACT_BUCKET_NAME})
Expand Down
3 changes: 3 additions & 0 deletions vars/createUploadTestReportManifest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@param args.dashboardsBuildManifest <optional> - The path of the build manifest of OpenSearch Dashboards
@param args.testRunID <required> - Test run id of the test workflow being reported.
@param args.testType <required> - Type of the test workflow being reported.
@param args.rcNumber <Optional> - The RC Number of the distribution in test workflow being reported.
@param args.componentName <Optional> - Components that workflow runs on.
*/

Expand All @@ -24,6 +25,7 @@ def call(Map args = [:]) {

def testRunID = args.testRunID;
def testType = args.testType;
def rcNumber = args.rcNumber

def testManifest = lib.jenkins.TestManifest.new(readYaml(file: args.testManifest))
def buildManifest = lib.jenkins.BuildManifest.new(readYaml(file: args.buildManifest))
Expand All @@ -50,6 +52,7 @@ def call(Map args = [:]) {
"--test-run-id ${testRunID}",
"--test-type ${testType}",
"--base-path ${basePath}",
isNullOrEmpty(rcNumber) ? "" : "--release-candidate ${rcNumber}",
isNullOrEmpty(component) ? "" : "--component ${component}",
].join(' ')

Expand Down
22 changes: 8 additions & 14 deletions vars/publishIntegTestResults.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@
/** Library to fetch the failing Integration test details at the end of Integration Test Jenkins build and index the results to OpenSearch Metrics cluster.
*
* @param Map args = [:] args A map of the following parameters.
* @param args.version <required> - The version against which the integration test is executed.
* @param args.distributionBuildNumber <required> - The jenkins distribution build number.
* @param args.distributionBuildUrl <required> - The jenkins distribution build number.
* @param args.rc <required> - If the integration tests are running on an RC.
* @param args.rcNumber <required> - The RC number against which the integration test is executed.
* @param args.platform <required> - The platform of the integration test build.
* @param args.architecture <required> - The architecture of the integration test build.
* @param args.distribution <required> - The distribution of the integration test build.
* @param args.testReportManifestYml <required> - The generated test report YAML file using test report workflow.
* @param args.jobName <required> - The integ test job name, used in `testReportManifestYmlUrl`.
*/
Expand All @@ -39,26 +32,27 @@ void call(Map args = [:]) {
return null
}

def version = args.version.toString()
def integTestBuildNumber = currentBuild.number
def integTestBuildUrl = env.RUN_DISPLAY_URL
def distributionBuildNumber = args.distributionBuildNumber
def distributionBuildUrl = args.distributionBuildUrl
def buildStartTime = currentBuild.startTimeInMillis
def currentDate = new Date()
def formattedDate = new SimpleDateFormat("MM-yyyy").format(currentDate)
def rc = args.rc
def rcNumber = args.rcNumber.toInteger()
def platform = args.platform
def architecture = args.architecture
def distribution = args.distribution
def testReportManifestYml = args.testReportManifestYml
def jobName = args.jobName
def testReportManifestYmlUrl = "https://ci.opensearch.org/ci/dbc/${jobName}/${version}/${distributionBuildNumber}/${platform}/${architecture}/${distribution}/test-results/${integTestBuildNumber}/integ-test/test-report.yml"
def manifestFile = readFile testReportManifestYml
def manifest = readYaml text: manifestFile
def indexName = "opensearch-integration-test-results-${formattedDate}"
def finalJsonDoc = ""
def version = manifest.version.toString()
def distributionBuildNumber = manifest.id
def rcNumber = manifest.rc.toInteger()
def rc = (rcNumber > 0)
def platform = manifest.platform
def architecture = manifest.architecture
def distribution = manifest.distribution

manifest.components.each { component ->
def componentName = component.name
def componentCategory = manifest.name
Expand Down

0 comments on commit 571310e

Please sign in to comment.