-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TestReleaseNotesCheck.groovy (#2765)
* 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
Showing
2 changed files
with
92 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,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() | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...nkins/jenkinsjob-regression-files/release-notes-check/release-notes-check.jenkinsfile.txt
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,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}) |