Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
prudhvigodithi committed Jun 12, 2024
2 parents 2fd7f35 + cfba629 commit c944df0
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 77 deletions.
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ configurations.all {
force group: 'com.google.code.gson', name: 'gson', version: '2.8.9'
force group: 'commons-codec', name: 'commons-codec', version: '1.15'
force group: 'com.google.protobuf', name: 'protobuf-java', version: '3.21.7'
force group: 'com.google.errorprone', name: 'error_prone_annotations', version: '2.18.0'
force group: 'org.checkerframework', name: 'checker-qual', version: '3.33.0'
force group: 'com.google.j2objc', name: 'j2objc-annotations', version: '2.8'
force group: 'org.jenkins-ci.plugins', name: 'durable-task', version: '547.vd1ea_007d100c'
}
}

Expand Down Expand Up @@ -63,7 +67,7 @@ sourceSets {
}

sharedLibrary {
coreVersion = '2.387.1' // https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-core/
coreVersion = '2.426.3' // https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-core/
testHarnessVersion = '2085.va_c531db_287b_d' // https://mvnrepository.com/artifact/org.jenkins-ci.main/jenkins-test-harness?repo=jenkins-releases
pluginDependencies {
workflowCpsGlobalLibraryPluginVersion = '570.v21311f4951f8' // https://repo.jenkins-ci.org/public/org/jenkins-ci/plugins/workflow/workflow-cps-global-lib/
Expand Down
2 changes: 1 addition & 1 deletion src/gradlecheck/FetchPostMergeFailedTestName.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,6 @@ class FetchPostMergeFailedTestName {

}
def getPostMergeFailedTestName(testName, gitReference) {
return new OpenSearchMetricsQuery(metricsUrl,awsAccessKey, awsSecretKey, awsSessionToken, script).fetchMetrics(getQuery(testName, gitReference))
return new OpenSearchMetricsQuery(metricsUrl, awsAccessKey, awsSecretKey, awsSessionToken, script).fetchMetrics(getQuery(testName, gitReference))
}
}
31 changes: 8 additions & 23 deletions tests/jenkins/TestCreateBuildFailureGithubIssue.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package jenkins.tests

import jenkins.tests.BuildPipelineTest
Expand All @@ -26,35 +27,19 @@ class TestCreateBuildFailureGithubIssue extends BuildPipelineTest {

@Test
public void testCreateGithubIssue() {

helper.addShMock("date -d \"3 days ago\" +'%Y-%m-%d'") { script ->
return [stdout: "2023-10-24", exitValue: 0]
}

helper.addShMock("""gh issue list --repo https://github.com/opensearch-project/performance-analyzer.git -S "[AUTOCUT] Distribution Build Failed for performance-analyzer-2.0.0 in:title" --label autocut,v2.0.0 --json number --jq '.[0].number'""") { script ->
return [stdout: "", exitValue: 0]
}
helper.addShMock("""gh issue list --repo https://github.com/opensearch-project/performance-analyzer.git -S "[AUTOCUT] Distribution Build Failed for performance-analyzer-2.0.0 in:title is:closed closed:>=2023-10-24" --label autocut,v2.0.0 --json number --jq '.[0].number'""") { script ->
return [stdout: "", exitValue: 0]
}
super.testPipeline('tests/jenkins/jobs/CreateBuildFailureGithubIssue_Jenkinsfile')
assertThat(getCommands('sh', 'create'), hasItem('{script=gh issue create --title \"[AUTOCUT] Distribution Build Failed for performance-analyzer-2.0.0\" --body \"***Received Error***: **Error building performance-analyzer, retry with: ./build.sh manifests/2.2.0/opensearch-2.2.0ed in the next build. This might have performance impact if it keeps failing. Run the javaToolchains task for more det.yml --component performance-analyzer**.\n The distribution build for performance-analyzer has failed for version: 2.0.0.\n Please see build log at www.example.com/job/build_url/32/display/redirect.\n The failed build stage will be marked as unstable(!). Please see ./build.sh step for more details\" --label autocut,v2.0.0 --label \"untriaged\" --repo https://github.com/opensearch-project/performance-analyzer.git, returnStdout=true}'))
assertThat(getCommands('sh', 'script'), hasItem('{script=gh issue comment bbb\n' +
'ccc --repo https://github.com/opensearch-project/performance-analyzer.git --body "***Received Error***: **Error building performance-analyzer, retry with: ./build.sh manifests/2.2.0/opensearch-2.2.0ed in the next build. This might have performance impact if it keeps failing. Run the javaToolchains task for more det.yml --component performance-analyzer**.\n' +
' The distribution build for performance-analyzer has failed for version: 2.0.0.\n' +
' Please see build log at www.example.com/job/build_url/32/display/redirect.\n' +
' The failed build stage will be marked as unstable(!). Please see ./build.sh step for more details", returnStdout=true}'))
}

@Test
public void testExistingGithubIssue() {
helper.addShMock("date -d \"3 days ago\" +'%Y-%m-%d'") { script ->
return [stdout: "2023-10-24", exitValue: 0]
}
helper.addShMock("""gh issue list --repo https://github.com/opensearch-project/OpenSearch.git -S "[AUTOCUT] Distribution Build Failed for performance-analyzer-2.0.0 in:title" --label autocut,v2.0.0 --json number --jq '.[0].number'""") { script ->
return [stdout: "22", exitValue: 0]
}
helper.addShMock("""gh issue list --repo https://github.com/opensearch-project/OpenSearch.git -S "[AUTOCUT] Distribution Build Failed for performance-analyzer-2.0.0 in:title is:closed closed:>=2023-10-24" --label autocut,v2.0.0 --json number --jq '.[0].number'""") { script ->
return [stdout: "", exitValue: 0]
}
public void testExistingGithubIssue_TestCreateBuildFailureGithubIssue() {
super.testPipeline('tests/jenkins/jobs/CreateBuildFailureGithubIssue_Jenkinsfile', 'tests/jenkins/jobs/CreateBuildFailureGithubExistingIssueCheck_Jenkinsfile')
assertThat(getCommands('println', ''), hasItem('Issue already exists, adding a comment'))
assertThat(getCommands('sh', 'script'), hasItem("{script=gh issue comment bbb\nccc --repo https://github.com/opensearch-project/OpenSearch.git --body \"***Received Error***: **Error building OpenSearch, retry with: ./build.sh manifests/2.2.0/opensearch-2.2.0.yml --component OpenSearch --snapshot**.\n The distribution build for OpenSearch has failed for version: 2.0.0.\n Please see build log at www.example.com/job/build_url/32/display/redirect.\n The failed build stage will be marked as unstable(!). Please see ./build.sh step for more details\", returnStdout=true}"))
assertThat(getCommands('sh', 'script'), hasItem("""{script=gh issue comment bbb\nccc --repo https://github.com/opensearch-project/OpenSearch.git --body \"***Received Error***: **Error building OpenSearch, retry with: ./build.sh manifests/2.2.0/opensearch-2.2.0.yml --component OpenSearch --snapshot**.\n The distribution build for OpenSearch has failed for version: 2.0.0.\n Please see build log at www.example.com/job/build_url/32/display/redirect.\n The failed build stage will be marked as unstable(!). Please see ./build.sh step for more details\", returnStdout=true}"""))
}

def getCommands(method, text) {
Expand Down
5 changes: 2 additions & 3 deletions tests/jenkins/TestCreateGithubIssue.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class TestCreateGithubIssue extends BuildPipelineTest {
}
super.testPipeline('tests/jenkins/jobs/CreateGithubIssue_Jenkinsfile')
assertThat(getCommands('println', ''), hasItem("Issue already exists, adding a comment"))
assertThat(getCommands('sh', 'script'), hasItem("{script=gh issue comment bbb\nccc --repo https://github.com/opensearch-project/opensearch-build --body \"Test GH issue body\", returnStdout=true}"))
assertThat(getCommands('sh', 'script'), hasItem("""{script=gh issue comment bbb\nccc --repo https://github.com/opensearch-project/opensearch-build --body \"Test GH issue body\", returnStdout=true}"""))
}

void testCreateGithubIssueCreate() {
Expand Down Expand Up @@ -116,10 +116,9 @@ class TestCreateGithubIssue extends BuildPipelineTest {
}
super.testPipeline('tests/jenkins/jobs/EditGithubIssue_Jenkinsfile', 'tests/jenkins/jobs/EditGithubIssue_Jenkinsfile_IssueBody')
assertThat(getCommands('println', ''), hasItem("Issue already exists, editing the issue body"))
assertThat(getCommands('sh', 'script'), hasItem("{script=gh issue edit bbb\nccc --repo https://github.com/opensearch-project/opensearch-build --body-file issueBody.md, returnStdout=true}"))
assertThat(getCommands('sh', 'script'), hasItem("""{script=gh issue edit bbb\nccc --repo https://github.com/opensearch-project/opensearch-build --body-file issueBody.md, returnStdout=true}"""))
}


def getCommands(method, text) {
def shCommands = helper.callStack.findAll { call ->
call.methodName == method
Expand Down
22 changes: 3 additions & 19 deletions tests/jenkins/TestUpdateBuildFailuresIssues.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,6 @@ class TestUpdateBuildFailuresIssues extends BuildPipelineTest {
super.setUp()
}

@Test
public void testCreateGithubIssue() {
helper.addShMock("date -d \"3 days ago\" +'%Y-%m-%d'") { script ->
return [stdout: "2023-10-24", exitValue: 0]
}

helper.addShMock("""gh issue list --repo https://github.com/opensearch-project/asynchronous-search.git -S "[AUTOCUT] Distribution Build Failed for asynchronous-search-2.2.0 in:title" --label autocut,v2.2.0 --json number --jq '.[0].number'""") { script ->
return [stdout: "", exitValue: 0]
}
helper.addShMock("""gh issue list --repo https://github.com/opensearch-project/asynchronous-search.git -S "[AUTOCUT] Distribution Build Failed for asynchronous-search-2.2.0 in:title is:closed closed:>=2023-10-24" --label autocut,v2.2.0 --json number --jq '.[0].number'""") { script ->
return [stdout: "", exitValue: 0]
}
super.testPipeline('tests/jenkins/jobs/UpdateBuildFailureIssue_Jenkinsfile')
assertThat(getCommands('sh', 'create'), hasItem('{script=gh issue create --title \"[AUTOCUT] Distribution Build Failed for asynchronous-search-2.2.0\" --body \"***Received Error***: **Error building asynchronous-search, retry with: ./build.sh manifests/2.2.0/opensearch-2.2.0.yml --component asynchronous-search**.\n asynchronous-search failed during the distribution build for version: 2.2.0.\n Please see build log at www.example.com/job/build_url/32/display/redirect.\n The failed build stage will be marked as unstable(!). Please see ./build.sh step for more details\" --label autocut,v2.2.0 --label \"untriaged\" --repo https://github.com/opensearch-project/asynchronous-search.git, returnStdout=true}'))
}

@Test
public void testCommentOnExistingGithubIssue() {
helper.addShMock("date -d \"3 days ago\" +'%Y-%m-%d'") { script ->
Expand All @@ -54,7 +38,7 @@ class TestUpdateBuildFailuresIssues extends BuildPipelineTest {
}
runScript('tests/jenkins/jobs/UpdateBuildFailureIssue_Jenkinsfile')
assertThat(getCommands('println', ''), hasItem('Issue already exists, adding a comment'))
assertThat(getCommands('sh', 'script'), hasItem("{script=gh issue comment 22 --repo https://github.com/opensearch-project/asynchronous-search.git --body \"***Received Error***: **Error building asynchronous-search, retry with: ./build.sh manifests/2.2.0/opensearch-2.2.0.yml --component asynchronous-search**.\n asynchronous-search failed during the distribution build for version: 2.2.0.\n Please see build log at www.example.com/job/build_url/32/display/redirect.\n The failed build stage will be marked as unstable(!). Please see ./build.sh step for more details\", returnStdout=true}"))
assertThat(getCommands('sh', 'script'), hasItem("{script=gh issue comment bbb\nccc --repo https://github.com/opensearch-project/asynchronous-search.git --body \"***Received Error***: **Error building asynchronous-search, retry with: ./build.sh manifests/2.2.0/opensearch-2.2.0.yml --component asynchronous-search**.\n asynchronous-search failed during the distribution build for version: 2.2.0.\n Please see build log at www.example.com/job/build_url/32/display/redirect.\n The failed build stage will be marked as unstable(!). Please see ./build.sh step for more details\", returnStdout=true}"))
}

@Test
Expand All @@ -79,8 +63,8 @@ class TestUpdateBuildFailuresIssues extends BuildPipelineTest {
return [stdout: "20", exitValue: 0]
}
runScript('tests/jenkins/jobs/UpdateBuildFailureIssue_Jenkinsfile')
assertThat(getCommands('sh', 'notifications'), not(hasItem("{script=gh issue close 20 -R opensearch-project/notifications --comment \"Closing the issue as the distribution build for notifications has passed for version: **2.2.0**.\n Please see build log at www.example.com/job/build_url/32/display/redirect\", returnStdout=true}")))
assertThat(getCommands('sh', 'script'), hasItem("{script=gh issue comment 20 --repo https://github.com/opensearch-project/notifications.git --body \"***Received Error***: **Error building notifications, retry with: ./build.sh manifests/2.2.0/opensearch-2.2.0.yml --component notifications**.\n notifications failed during the distribution build for version: 2.2.0.\n Please see build log at www.example.com/job/build_url/32/display/redirect.\n The failed build stage will be marked as unstable(!). Please see ./build.sh step for more details\", returnStdout=true}"))
assertThat(getCommands('sh', 'notifications'), not(hasItem("{script=gh issue close bbb\nccc -R opensearch-project/notifications --comment \"Closing the issue as the distribution build for notifications has passed for version: **2.2.0**.\n Please see build log at www.example.com/job/build_url/32/display/redirect\", returnStdout=true}")))
assertThat(getCommands('sh', 'script'), hasItem("{script=gh issue comment bbb\nccc --repo https://github.com/opensearch-project/notifications.git --body \"***Received Error***: **Error building notifications, retry with: ./build.sh manifests/2.2.0/opensearch-2.2.0.yml --component notifications**.\n notifications failed during the distribution build for version: 2.2.0.\n Please see build log at www.example.com/job/build_url/32/display/redirect.\n The failed build stage will be marked as unstable(!). Please see ./build.sh step for more details\", returnStdout=true}"))
}

def getCommands(method, text) {
Expand Down
Loading

0 comments on commit c944df0

Please sign in to comment.