Skip to content

Commit

Permalink
Close the created autocut issues
Browse files Browse the repository at this point in the history
Signed-off-by: Prudhvi Godithi <[email protected]>
  • Loading branch information
prudhvigodithi committed Jul 28, 2023
1 parent b422ae0 commit 0f18a24
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 38 deletions.
12 changes: 8 additions & 4 deletions jenkins/opensearch-dashboards/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
lib = library(identifier: 'jenkins@1.5.6', retriever: modernSCM([
lib = library(identifier: 'jenkins@5.4.0', retriever: modernSCM([
$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
]))
Expand Down Expand Up @@ -863,6 +863,7 @@ pipeline {
}
success {
node(AGENT_X64) {
checkout scm
script {
List<String> stages = []
if (params.BUILD_PLATFORM.contains('linux')) {
Expand Down Expand Up @@ -897,7 +898,10 @@ pipeline {
manifest: "${INPUT_MANIFEST}"
)
}

closeBuildSuccessGithubIssue(
message: buildMessage(search: 'Successfully built'),
inputManifestPath: "manifests/$INPUT_MANIFEST"
)
postCleanup()
}
}
Expand All @@ -909,14 +913,14 @@ pipeline {
if (params.PUBLISH_NOTIFICATION) {
publishNotification(
icon: ':warning:',
message: buildFailureMessage(),
message: buildMessage(search: 'Error building'),
credentialsId: 'jenkins-build-notice-webhook',
manifest: "${INPUT_MANIFEST}"
)
}
if (params.CREATE_GITHUB_ISSUE) {
createGithubIssue(
message: buildFailureMessage()
message: buildMessage(search: 'Error building'),
)
}

Expand Down
11 changes: 9 additions & 2 deletions jenkins/opensearch-dashboards/integ-test.jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
lib = library(identifier: 'jenkins@4.2.2', retriever: modernSCM([
lib = library(identifier: 'jenkins@5.4.0', retriever: modernSCM([
$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
]))
Expand Down Expand Up @@ -196,7 +196,14 @@ pipeline {
testManifest: "manifests/${TEST_MANIFEST}",
localPath: "${WORKSPACE}/${distribution}",
switchUserNonRoot: "${switch_user_non_root}"
)
)
String closeCommentMessage = "Closing the issue as the Integration Test passed for ${local_component}<br>Version: ${version}<br>Distribution: ${distribution}<br>Architecture: ${architecture}<br>Platform: ${platform}<br><br>Please check the logs: ${RUN_DISPLAY_URL}<br><br> *"
closeGithubIssue(
repoUrl: buildManifestObj.getRepo("${local_component}"),
issueTitle: "[AUTOCUT] Integration Test failed for ${local_component}: ${version} ${distribution} distribution",
closeComment: closeCommentMessage,
label: "autocut,v${version},integ-test-failure"
)
}
} catch (e) {
echo "Error running integtest for component ${local_component}, creating Github issue"
Expand Down
11 changes: 8 additions & 3 deletions jenkins/opensearch/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
lib = library(identifier: 'jenkins@4.3.0', retriever: modernSCM([
lib = library(identifier: 'jenkins@5.4.0', retriever: modernSCM([
$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
]))
Expand Down Expand Up @@ -915,6 +915,7 @@ pipeline {
}
success {
node(AGENT_X64) {
checkout scm
script {
List<String> stages = []
if (params.BUILD_PLATFORM.contains('linux')) {
Expand Down Expand Up @@ -942,6 +943,10 @@ pipeline {
manifest: "${INPUT_MANIFEST}"
)
}
closeBuildSuccessGithubIssue(
message: buildMessage(search: 'Successfully built'),
inputManifestPath: "manifests/$INPUT_MANIFEST"
)

postCleanup()
}
Expand All @@ -954,14 +959,14 @@ pipeline {
if (params.PUBLISH_NOTIFICATION) {
publishNotification(
icon: ':warning:',
message: buildFailureMessage(),
message: buildMessage(search: 'Error building'),
credentialsId: 'jenkins-build-notice-webhook',
manifest: "${INPUT_MANIFEST}"
)
}
if (params.CREATE_GITHUB_ISSUE) {
createBuildFailureGithubIssue(
message: buildFailureMessage(),
message: buildMessage(search: 'Error building'),
inputManifestPath: "manifests/$INPUT_MANIFEST"
)
}
Expand Down
9 changes: 8 additions & 1 deletion jenkins/opensearch/integ-test.jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
lib = library(identifier: 'jenkins@4.2.2', retriever: modernSCM([
lib = library(identifier: 'jenkins@5.4.0', retriever: modernSCM([
$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
]))
Expand Down Expand Up @@ -161,6 +161,13 @@ pipeline {
localPath: "${WORKSPACE}/${distribution}",
switchUserNonRoot: "${switch_user_non_root}"
)
String closeCommentMessage = "Closing the issue as the Integration Test passed for ${local_component}<br>Version: ${version}<br>Distribution: ${distribution}<br>Architecture: ${architecture}<br>Platform: ${platform}<br><br>Please check the logs: ${RUN_DISPLAY_URL}<br><br> *"
closeGithubIssue(
repoUrl: buildManifestObj.getRepo("${local_component}"),
issueTitle: "[AUTOCUT] Integration Test failed for ${local_component}: ${version} ${distribution} distribution",
closeComment: closeCommentMessage,
label: "autocut,v${version},integ-test-failure"
)
}
} catch (e) {
echo "Error running integtest for component ${local_component}, creating Github issue"
Expand Down
1 change: 1 addition & 0 deletions src/run_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def main() -> int:
builder.checkout(work_dir.name)
builder.build(build_recorder)
builder.export_artifacts(build_recorder)
logging.info(f"Successfully built {component.name}")
except:
logging.error(f"Error building {component.name}, retry with: {args.component_command(component.name)}")
raise
Expand Down
19 changes: 17 additions & 2 deletions tests/jenkins/TestOpenSearchDashboardsIntegTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TestOpenSearchDashboardsIntegTest extends BuildPipelineTest {

helper.registerSharedLibrary(
library().name('jenkins')
.defaultVersion('4.2.2')
.defaultVersion('5.4.0')
.allowOverride(true)
.implicit(true)
.targetPath('vars')
Expand Down Expand Up @@ -136,14 +136,29 @@ class TestOpenSearchDashboardsIntegTest extends BuildPipelineTest {
assertThat(getCommandExecutions('sh', 'create'), hasItem('{script=gh issue create --title \"[AUTOCUT] Integration Test failed for observabilityDashboards: 3.0.0 tar distribution\" --body \"The integration test failed at distribution level for component observabilityDashboards<br>Version: 3.0.0<br>Distribution: tar<br>Architecture: x64<br>Platform: linux<br><br>Please check the logs: https://some/url/redirect<br><br> * Steps to reproduce: See https://github.com/opensearch-project/opensearch-build/tree/main/src/test_workflow#integration-tests<br>* See all log files:<br> - [With security](https://ci.opensearch.org/ci/dbc/dummy_job/3.0.0/215/linux/x64/tar/test-results/215/integ-test/observabilityDashboards/with-security/observabilityDashboards.yml) (if applicable)<br> - [Without security](https://ci.opensearch.org/ci/dbc/dummy_job/3.0.0/215/linux/x64/tar/test-results/215/integ-test/observabilityDashboards/without-security/observabilityDashboards.yml) (if applicable)<br><br>\" --label autocut,v3.0.0,integ-test-failure --label \"untriaged\" --repo https://github.com/opensearch-project/dashboards-observability.git, returnStdout=true}'))
}

@Test
void CheckCloseGHissue() {
helper.addShMock('env PATH=$PATH ./test.sh integ-test manifests/tests/jenkins/data/opensearch-dashboards-3.0.0-test.yml --component observabilityDashboards --test-run-id 215 --paths opensearch=/tmp/workspace/tar opensearch-dashboards=/tmp/workspace/tar --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_job/3.0.0/215/linux/x64/tar ', '', 1)
helper.addShMock('gh issue list --repo https://github.com/opensearch-project/dashboards-visualization.git -S "[AUTOCUT] Integration Test failed for ganttChartDashboards: 3.0.0 tar distribution in:title" --label autocut,v3.0.0,integ-test-failure', '', 0)
assertThrows(Exception) {
runScript('jenkins/opensearch-dashboards/integ-test.jenkinsfile')
}
assertJobStatusFailure()
runScript('jenkins/opensearch-dashboards/integ-test.jenkinsfile')
assertThat(getCommandExecutions('sh', 'script'), hasItem("{script=gh issue list --repo https://github.com/opensearch-project/dashboards-visualizations.git -S \"[AUTOCUT] Integration Test failed for ganttChartDashboards: 3.0.0 tar distribution in:title\" --label autocut,v3.0.0,integ-test-failure --json number --jq '.[0].number', returnStdout=true}"))
assertThat(getCommandExecutions('sh', 'script'), hasItem("{script=gh issue close bbb\nccc -R opensearch-project/dashboards-visualizations --comment \"Closing the issue as the Integration Test passed for ganttChartDashboards<br>Version: 3.0.0<br>Distribution: tar<br>Architecture: x64<br>Platform: linux<br><br>Please check the logs: https://some/url/redirect<br><br> *\", returnStdout=true}"))
}

@Test
void checkGHexistingIssue() {
helper.addShMock('env PATH=$PATH ./test.sh integ-test manifests/tests/jenkins/data/opensearch-dashboards-3.0.0-test.yml --component observabilityDashboards --test-run-id 215 --paths opensearch=/tmp/workspace/tar opensearch-dashboards=/tmp/workspace/tar --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_job/3.0.0/215/linux/x64/tar ', '', 1)
assertThrows(Exception) {
runScript('jenkins/opensearch-dashboards/integ-test.jenkinsfile')
}
assertJobStatusFailure()
assertThat(getCommandExecutions('println', 'Issue'), hasItem('Issue already exists in the repository, skipping.'))
assertThat(getCommandExecutions('println', 'Issue'), hasItem('Issue already exists, adding a comment.'))
assertThat(getCommandExecutions('sh', 'script'), hasItem("{script=gh issue list --repo https://github.com/opensearch-project/dashboards-visualizations.git -S \"[AUTOCUT] Integration Test failed for ganttChartDashboards: 3.0.0 tar distribution in:title\" --label autocut,v3.0.0,integ-test-failure --json number --jq '.[0].number', returnStdout=true}"))
assertThat(getCommandExecutions('sh', 'script'), hasItem("{script=gh issue comment bbb\nccc --repo https://github.com/opensearch-project/dashboards-observability.git --body \"The integration test failed at distribution level for component observabilityDashboards<br>Version: 3.0.0<br>Distribution: tar<br>Architecture: x64<br>Platform: linux<br><br>Please check the logs: https://some/url/redirect<br><br> * Steps to reproduce: See https://github.com/opensearch-project/opensearch-build/tree/main/src/test_workflow#integration-tests<br>* See all log files:<br> - [With security](https://ci.opensearch.org/ci/dbc/dummy_job/3.0.0/215/linux/x64/tar/test-results/215/integ-test/observabilityDashboards/with-security/observabilityDashboards.yml) (if applicable)<br> - [Without security](https://ci.opensearch.org/ci/dbc/dummy_job/3.0.0/215/linux/x64/tar/test-results/215/integ-test/observabilityDashboards/without-security/observabilityDashboards.yml) (if applicable)<br><br>\", returnStdout=true}"))
}

def getCommandExecutions(methodName, command) {
Expand Down
15 changes: 13 additions & 2 deletions tests/jenkins/TestOpenSearchIntegTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TestOpenSearchIntegTest extends BuildPipelineTest {

helper.registerSharedLibrary(
library().name('jenkins')
.defaultVersion('4.2.2')
.defaultVersion('5.4.0')
.allowOverride(true)
.implicit(true)
.targetPath('vars')
Expand Down Expand Up @@ -112,6 +112,14 @@ class TestOpenSearchIntegTest extends BuildPipelineTest {
assertThat(getCommandExecutions('sh', 'create'), hasItem('{script=gh issue create --title \"[AUTOCUT] Integration Test failed for OpenSearch: 1.3.0 tar distribution\" --body \"The integration test failed at distribution level for component OpenSearch<br>Version: 1.3.0<br>Distribution: tar<br>Architecture: x64<br>Platform: linux<br><br>Please check the logs: https://some/url/redirect<br><br> * Steps to reproduce: See https://github.com/opensearch-project/opensearch-build/tree/main/src/test_workflow#integration-tests<br>* Access components yml file:<br> - [With security](https://ci.opensearch.org/ci/dbc/dummy_job/1.3.0/717/linux/x64/tar/test-results/234/integ-test/OpenSearch/with-security/OpenSearch.yml) (if applicable)<br> - [Without security](https://ci.opensearch.org/ci/dbc/dummy_job/1.3.0/717/linux/x64/tar/test-results/234/integ-test/OpenSearch/without-security/OpenSearch.yml) (if applicable)<br><br> _Note: All in one test report manifest with all the details coming soon. See https://github.com/opensearch-project/opensearch-build/issues/1274_\" --label autocut,v1.3.0,integ-test-failure --label \"untriaged\" --repo https://github.com/opensearch-project/OpenSearch.git, returnStdout=true}'))
}

@Test
void CheckCloseGHissue() {
helper.addShMock('env PATH=$PATH JAVA_HOME=/opt/java/openjdk-17 ./test.sh integ-test manifests/tests/jenkins/data/opensearch-1.3.0-test.yml --component OpenSearch --test-run-id 234 --paths opensearch=/tmp/workspace/tar --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_job/1.3.0/717/linux/x64/tar', '', 1)
runScript('jenkins/opensearch/integ-test.jenkinsfile')
assertThat(getCommandExecutions('sh', 'script'), hasItem("{script=gh issue list --repo https://github.com/opensearch-project/OpenSearch.git -S \"[AUTOCUT] Integration Test failed for OpenSearch: 1.3.0 tar distribution in:title\" --label autocut,v1.3.0,integ-test-failure --json number --jq '.[0].number', returnStdout=true}"))
assertThat(getCommandExecutions('sh', 'script'), hasItem("{script=gh issue close bbb\nccc -R opensearch-project/OpenSearch --comment \"Closing the issue as the Integration Test passed for OpenSearch<br>Version: 1.3.0<br>Distribution: tar<br>Architecture: x64<br>Platform: linux<br><br>Please check the logs: https://some/url/redirect<br><br> *\", returnStdout=true}"))
}

@Test
void checkGHexistingIssue() {
super.setUp()
Expand All @@ -120,7 +128,10 @@ class TestOpenSearchIntegTest extends BuildPipelineTest {
runScript('jenkins/opensearch/integ-test.jenkinsfile')
}
assertJobStatusFailure()
assertThat(getCommandExecutions('println', 'Issue'), hasItem('Issue already exists in the repository, skipping.'))
assertThat(getCommandExecutions('println', 'Issue'), hasItem('Issue already exists, adding a comment.'))
assertThat(getCommandExecutions('sh', 'script'), hasItem("{script=gh issue list --repo https://github.com/opensearch-project/OpenSearch.git -S \"[AUTOCUT] Integration Test failed for OpenSearch: 1.3.0 tar distribution in:title\" --label autocut,v1.3.0,integ-test-failure, returnStdout=true}"))
assertThat(getCommandExecutions('sh', 'script'), hasItem("{script=gh issue list --repo https://github.com/opensearch-project/OpenSearch.git -S \"[AUTOCUT] Integration Test failed for OpenSearch: 1.3.0 tar distribution in:title\" --label autocut,v1.3.0,integ-test-failure --json number --jq '.[0].number', returnStdout=true}"))
assertThat(getCommandExecutions('sh', 'script'), hasItem("{script=gh issue comment bbb\nccc --repo https://github.com/opensearch-project/OpenSearch.git --body \"The integration test failed at distribution level for component OpenSearch<br>Version: 1.3.0<br>Distribution: tar<br>Architecture: x64<br>Platform: linux<br><br>Please check the logs: https://some/url/redirect<br><br> * Steps to reproduce: See https://github.com/opensearch-project/opensearch-build/tree/main/src/test_workflow#integration-tests<br>* Access components yml file:<br> - [With security](https://ci.opensearch.org/ci/dbc/dummy_job/1.3.0/717/linux/x64/tar/test-results/234/integ-test/OpenSearch/with-security/OpenSearch.yml) (if applicable)<br> - [Without security](https://ci.opensearch.org/ci/dbc/dummy_job/1.3.0/717/linux/x64/tar/test-results/234/integ-test/OpenSearch/without-security/OpenSearch.yml) (if applicable)<br><br> _Note: All in one test report manifest with all the details coming soon. See https://github.com/opensearch-project/opensearch-build/issues/1274_\", returnStdout=true}"))
}

def getCommandExecutions(methodName, command) {
Expand Down
Loading

0 comments on commit 0f18a24

Please sign in to comment.