Skip to content

Commit

Permalink
Add TestReleaseNotesCheck.groovy (#2765)
Browse files Browse the repository at this point in the history
* Add TestReleaseNotesCheck.groovy

Signed-off-by: Jeff Lu <chunglu@amazon.com>

* add additional test to verify if the needed sh script in place

Signed-off-by: Jeff Lu <chunglu@amazon.com>

Signed-off-by: Jeff Lu <chunglu@amazon.com>
  • Loading branch information
jordarlu committed Oct 21, 2022
1 parent d277073 commit eb8024d
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tests/jenkins/TestReleaseNotesCheck.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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.
*/
import jenkins.tests.BuildPipelineTest
import org.junit.Before
import org.junit.Test
import static com.lesfurets.jenkins.unit.global.lib.LibraryConfiguration.library
import static com.lesfurets.jenkins.unit.MethodCall.callArgsToString
import static org.assertj.core.api.Assertions.assertThat

class TestReleaseNotesCheck extends BuildPipelineTest {

String gitLogDate = '2022-10-10'
String comment = 'NO_COMMENT'
String gitIssueNumber = '123456'
String commentUniqueID = '123456'
String inputManifest = '2.2.0/opensearch-2.2.0.yml'

@Override
@Before
void setUp() {
super.setUp()

binding.setVariable('INPUT_MANIFEST', inputManifest)
binding.setVariable('GIT_LOG_DATE', gitLogDate)
binding.setVariable('COMMENT', comment)
binding.setVariable('GIT_ISSUE_NUMBER', gitIssueNumber)
binding.setVariable('COMMENT_UNIQUE_ID', commentUniqueID)
binding.setVariable('AGENT_X64','Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host')
binding.setVariable('dockerAgent', [image:'opensearchstaging/ci-runner:ci-runner-centos7-v1', args:'-e JAVA_HOME=/opt/java/openjdk-11'])

}

@Test
public void testReleaseNoteCheckPipeline() {
super.testPipeline("jenkins/release-notes-check/release-notes-check.jenkinsfile",
"tests/jenkins/jenkinsjob-regression-files/release-notes-check/release-notes-check.jenkinsfile")
}

@Test
public void releaseNoteExecuteWithoutErrors() {
runScript("jenkins/release-notes-check/release-notes-check.jenkinsfile")

assertJobStatusSuccess()

assertThat(helper.callStack.findAll { call ->
call.methodName == 'sh'
}.any { call ->
callArgsToString(call).contains('release_notes.sh')
}).isTrue()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
release-notes-check.run()
release-notes-check.modernSCM({$class=GitSCMSource, remote=https://github.com/opensearch-project/opensearch-build-libraries.git})
release-notes-check.library({identifier=jenkins@1.0.4, retriever=null})
release-notes-check.pipeline(groovy.lang.Closure)
release-notes-check.timeout({time=2, unit=HOURS})
release-notes-check.echo(Executing on agent [label:none])
release-notes-check.stage(detect docker image + args, groovy.lang.Closure)
release-notes-check.echo(Executing on agent [docker:[image:alpine:3, reuseNode:false, stages:[:], args:, alwaysPull:true, containerPerStageRoot:false, label:Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host]])
release-notes-check.script(groovy.lang.Closure)
release-notes-check.detectDockerAgent()
detectDockerAgent.legacySCM(groovy.lang.Closure)
detectDockerAgent.library({identifier=jenkins@1.0.4, retriever=null})
detectDockerAgent.readYaml({file=manifests/2.2.0/opensearch-2.2.0.yml})
InputManifest.asBoolean()
detectDockerAgent.echo(Using Docker image opensearchstaging/ci-runner:ci-runner-centos7-opensearch-build-v2 (-e JAVA_HOME=/opt/java/openjdk-17))
detectDockerAgent.echo(Using java version openjdk-17)
release-notes-check.postCleanup()
postCleanup.cleanWs({disableDeferredWipeout=true, deleteDirs=true})
release-notes-check.stage(Parameters Check, groovy.lang.Closure)
release-notes-check.script(groovy.lang.Closure)
release-notes-check.stage(Generate MarkDown table, groovy.lang.Closure)
release-notes-check.echo(Executing on agent [docker:[image:opensearchstaging/ci-runner:ci-runner-centos7-v1, reuseNode:false, stages:[:], args:, alwaysPull:true, containerPerStageRoot:false, label:Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host]])
release-notes-check.script(groovy.lang.Closure)
release-notes-check.usernamePassword({credentialsId=jenkins-github-bot-token, usernameVariable=GITHUB_USER, passwordVariable=GITHUB_TOKEN})
release-notes-check.withCredentials([[GITHUB_USER, GITHUB_TOKEN]], groovy.lang.Closure)
release-notes-check.sh(
#!/bin/bash
set +e
./release_notes.sh check manifests/${INPUT_MANIFEST} --date ${GIT_LOG_DATE} --output table.md
echo "Adding Comment on issue $GIT_ISSUE_NUMBER"
gh repo clone https://github.com/opensearch-project/opensearch-build.git; cd opensearch-build
gh issue comment ${GIT_ISSUE_NUMBER} --body-file ../table.md --repo opensearch-project/opensearch-build
)
release-notes-check.postCleanup()
postCleanup.cleanWs({disableDeferredWipeout=true, deleteDirs=true})

0 comments on commit eb8024d

Please sign in to comment.