From 47af6f122d5cc4316ba71a79e85e378e867bcdbc Mon Sep 17 00:00:00 2001 From: Sayali Gaikawad Date: Sun, 6 Oct 2024 13:23:34 -0700 Subject: [PATCH] Add more tests Signed-off-by: Sayali Gaikawad --- src/jenkins/ComponentBuildStatus.groovy | 5 +- src/utils/OpenSearchMetricsQuery.groovy | 4 +- .../TestPublishIntegTestResults.groovy | 189 +++++++++--------- .../TestUpdateIntegTestFailureIssues.groovy | 75 ++++++- ...reIssue_without_distributionID_Jenkinsfile | 23 +++ ...sue_without_distributionID_Jenkinsfile.txt | 147 ++++++++++++++ ...dateIntegTestFailureIssuesLibTester.groovy | 23 +-- vars/updateIntegTestFailureIssues.groovy | 3 +- 8 files changed, 346 insertions(+), 123 deletions(-) create mode 100644 tests/jenkins/jobs/UpdateBuildFailureIssue_without_distributionID_Jenkinsfile create mode 100644 tests/jenkins/jobs/UpdateBuildFailureIssue_without_distributionID_Jenkinsfile.txt diff --git a/src/jenkins/ComponentBuildStatus.groovy b/src/jenkins/ComponentBuildStatus.groovy index 45e3669f..776445c8 100644 --- a/src/jenkins/ComponentBuildStatus.groovy +++ b/src/jenkins/ComponentBuildStatus.groovy @@ -128,6 +128,7 @@ class ComponentBuildStatus { ] ] def query = JsonOutput.toJson(queryMap) + this.script.println(query.replace('"', '\\"')) return query.replace('"', '\\"') } @@ -137,8 +138,8 @@ class ComponentBuildStatus { return components } - def getLatestDistributionBuildNumber(String version) { - def jsonResponse = this.openSearchMetricsQuery.fetchMetrics(getQuery(getLatestDistributionBuildNumberQuery)) + def getLatestDistributionBuildNumber() { + def jsonResponse = this.openSearchMetricsQuery.fetchMetrics(getLatestDistributionBuildNumberQuery()) def latestDistributionBuildNumber = jsonResponse.hits.hits[0]._source.distribution_build_number return latestDistributionBuildNumber } diff --git a/src/utils/OpenSearchMetricsQuery.groovy b/src/utils/OpenSearchMetricsQuery.groovy index dde4bc54..9ee6172c 100644 --- a/src/utils/OpenSearchMetricsQuery.groovy +++ b/src/utils/OpenSearchMetricsQuery.groovy @@ -9,7 +9,7 @@ package utils -import groovy.json.JsonSlurper +import groovy.json.JsonSlurperClassic class OpenSearchMetricsQuery { String metricsUrl @@ -37,6 +37,6 @@ class OpenSearchMetricsQuery { """, returnStdout: true ).trim() - return new JsonSlurper().parseText(response) + return new JsonSlurperClassic().parseText(response) } } diff --git a/tests/jenkins/TestPublishIntegTestResults.groovy b/tests/jenkins/TestPublishIntegTestResults.groovy index 4f875b4c..173bc9e7 100644 --- a/tests/jenkins/TestPublishIntegTestResults.groovy +++ b/tests/jenkins/TestPublishIntegTestResults.groovy @@ -65,100 +65,103 @@ class TestPublishIntegTestResults extends BuildPipelineTest { def expectedCommandBlock = '''set +e set +x echo "INDEX NAME IS test-index" - INDEX_MAPPING='{ - "mappings": { - "properties": { - "component": { - "type": "keyword" - }, - "component_repo": { - "type": "keyword" - }, - "component_repo_url": { - "type": "keyword" - }, - "version": { - "type": "keyword" - }, - "integ_test_build_number": { - "type": "integer" - }, - "integ_test_build_url": { - "type": "keyword" - }, - "distribution_build_number": { - "type": "integer" - }, - "distribution_build_url": { - "type": "keyword" - }, - "build_start_time": { - "type": "date", - "format": "epoch_millis" - }, - "rc": { - "type": "keyword" - }, - "rc_number": { - "type": "integer" - }, - "platform": { - "type": "keyword" - }, - "architecture": { - "type": "keyword" - }, - "distribution": { - "type": "keyword" - }, - "component_category": { - "type": "keyword" - }, - "component_build_result": { - "type": "keyword" - }, - "test_report_manifest_yml": { - "type": "keyword" - }, - "with_security": { - "type": "keyword" - }, - "with_security_build_yml": { - "type": "keyword" - }, - "with_security_cluster_stdout": { - "type": "keyword" - }, - "with_security_test_stdout": { - "type": "keyword" - }, - "with_security_cluster_stderr": { - "type": "keyword" - }, - "with_security_test_stderr": { - "type": "keyword" - }, - "without_security": { - "type": "keyword" - }, - "without_security_build_yml": { - "type": "keyword" - }, - "without_security_cluster_stdout": { - "type": "keyword" - }, - "without_security_test_stdout": { - "type": "keyword" - }, - "without_security_cluster_stderr": { - "type": "keyword" - }, - "without_security_test_stderr": { - "type": "keyword" + INDEX_MAPPING='{ + "mappings": { + "properties": { + "component": { + "type": "keyword" + }, + "component_repo": { + "type": "keyword" + }, + "component_repo_url": { + "type": "keyword" + }, + "version": { + "type": "keyword" + }, + "integ_test_build_number": { + "type": "integer" + }, + "integ_test_build_url": { + "type": "keyword" + }, + "distribution_build_number": { + "type": "integer" + }, + "distribution_build_url": { + "type": "keyword" + }, + "build_start_time": { + "type": "date", + "format": "epoch_millis" + }, + "rc": { + "type": "keyword" + }, + "rc_number": { + "type": "integer" + }, + "platform": { + "type": "keyword" + }, + "architecture": { + "type": "keyword" + }, + "distribution": { + "type": "keyword" + }, + "component_category": { + "type": "keyword" + }, + "component_build_result": { + "type": "keyword" + }, + "test_report_manifest_yml": { + "type": "keyword" + }, + "with_security": { + "type": "keyword" + }, + "with_security_build_yml": { + "type": "keyword" + }, + "with_security_cluster_stdout": { + "type": "keyword" + }, + "with_security_test_stdout": { + "type": "keyword" + }, + "with_security_cluster_stderr": { + "type": "keyword" + }, + "with_security_test_stderr": { + "type": "keyword" + }, + "without_security": { + "type": "keyword" + }, + "without_security_build_yml": { + "type": "keyword" + }, + "without_security_cluster_stdout": { + "type": "keyword" + }, + "without_security_test_stdout": { + "type": "keyword" + }, + "without_security_cluster_stderr": { + "type": "keyword" + }, + "without_security_test_stderr": { + "type": "keyword" + } + }, + "aliases": { + "opensearch-integration-test-results": {} + } } - } - } - }' + }' curl -I "METRICS_HOST_URL/test-index" --aws-sigv4 "aws:amz:us-east-1:es" --user "null:null" -H "x-amz-security-token:null" | grep -E "HTTP\\/[0-9]+(\\.[0-9]+)? 200" if [ $? -eq 0 ]; then echo "Index already exists. Indexing Results" diff --git a/tests/jenkins/TestUpdateIntegTestFailureIssues.groovy b/tests/jenkins/TestUpdateIntegTestFailureIssues.groovy index 0b7d8674..2b37a13f 100644 --- a/tests/jenkins/TestUpdateIntegTestFailureIssues.groovy +++ b/tests/jenkins/TestUpdateIntegTestFailureIssues.groovy @@ -23,8 +23,23 @@ class TestUpdateIntegTestFailureIssues extends BuildPipelineTest { @Override @Before void setUp() { - this.registerLibTester(new UpdateIntegTestFailureIssuesLibTester('tests/data/opensearch-2.2.0.yml', '4891')) super.setUp() + helper.registerAllowedMethod('withCredentials', [Map]) + helper.registerAllowedMethod('sleep', [Map]) + binding.setVariable('env', [ + 'METRICS_HOST_URL': 'sample.url', + 'AWS_ACCESS_KEY_ID': 'abc', + 'AWS_SECRET_ACCESS_KEY':'xyz', + 'AWS_SESSION_TOKEN': 'sampleToken' + ]) + helper.registerAllowedMethod('withCredentials', [Map, Closure], { args, closure -> + closure.delegate = delegate + return helper.callClosure(closure) + }) + helper.registerAllowedMethod('withAWS', [Map, Closure], { args, closure -> + closure.delegate = delegate + return helper.callClosure(closure) + }) def unformattedResponseForPass = ''' { "took": 10, @@ -168,6 +183,39 @@ class TestUpdateIntegTestFailureIssues extends BuildPipelineTest { } } ''' + + def latestDistributionBuildNumberReponse = ''' + { + "took": 9, + "timed_out": false, + "_shards": { + "total": 20, + "successful": 20, + "skipped": 0, + "failed": 0 + }, + "hits": { + "total": { + "value": 245, + "relation": "eq" + }, + "max_score": null, + "hits": [ + { + "_index": "opensearch-distribution-build-results-10-2024", + "_id": "mYJqVZIB2pK3vw3OS9GJ", + "_score": null, + "_source": { + "distribution_build_number": 4891 + }, + "sort": [ + 1728006178106 + ] + } + ] + } + } + ''' helper.addShMock("""\n set -e\n set +x\n curl -s -XGET \"sample.url/opensearch-integration-test-results/_search\" --aws-sigv4 \"aws:amz:us-east-1:es\" --user \"abc:xyz\" -H \"x-amz-security-token:sampleToken\" -H 'Content-Type: application/json' -d \"{\\"size\\":50,\\"_source\\":[\\"component\\"],\\"query\\":{\\"bool\\":{\\"filter\\":[{\\"match_phrase\\":{\\"version\\":\\"2.2.0\\"}},{\\"match_phrase\\":{\\"component_category\\":\\"OpenSearch\\"}},{\\"match_phrase\\":{\\"distribution_build_number\\":\\"4891\\"}},{\\"match_phrase\\":{\\"component_build_result\\":\\"passed\\"}}]}}}\" | jq '.'\n """) { script -> return [stdout: unformattedResponseForPass, exitValue: 0] } @@ -180,14 +228,18 @@ class TestUpdateIntegTestFailureIssues extends BuildPipelineTest { helper.addShMock("""\n set -e\n set +x\n curl -s -XGET \"sample.url/opensearch-integration-test-results/_search\" --aws-sigv4 \"aws:amz:us-east-1:es\" --user \"abc:xyz\" -H \"x-amz-security-token:sampleToken\" -H 'Content-Type: application/json' -d \"{\\"_source\\":[\\"platform\\",\\"architecture\\",\\"distribution\\",\\"test_report_manifest_yml\\",\\"integ_test_build_url\\"],\\"query\\":{\\"bool\\":{\\"filter\\":[{\\"match_phrase\\":{\\"component\\":\\"k-NN\\"}},{\\"match_phrase\\":{\\"version\\":\\"2.2.0\\"}},{\\"match_phrase\\":{\\"distribution_build_number\\":\\"4891\\"}}]}}}\" | jq '.'\n """) { script -> return [stdout: failedTestDataResponse, exitValue: 0] } + helper.addShMock("""\n set -e\n set +x\n curl -s -XGET \"sample.url/opensearch-distribution-build-results/_search\" --aws-sigv4 \"aws:amz:us-east-1:es\" --user \"abc:xyz\" -H \"x-amz-security-token:sampleToken\" -H 'Content-Type: application/json' -d \"{\\"size\\":1,\\"_source\\":[\\"distribution_build_number\\"],\\"query\\":{\\"bool\\":{\\"filter\\":[{\\"match_phrase\\":{\\"component_category\\":\\"OpenSearch\\"}},{\\"match_phrase\\":{\\"version\\":\\"2.2.0\\"}}]}},\\"sort\\":[{\\"build_start_time\\":{\\"order\\":\\"desc\\"}}]}\" | jq '.'\n """) { script -> + return [stdout: latestDistributionBuildNumberReponse, exitValue: 0] + } } @Test public void testIssueCreation() { - helper.addShMock("""gh issue list --repo https://github.com/opensearch-project/k-NN.git -S "[AUTOCUT] Integration Test Failed for geospatial-2.2.0 in:title" --label autocut,v2.2.0 --json number --jq '.[0].number'""") { script -> + this.registerLibTester(new UpdateIntegTestFailureIssuesLibTester('tests/data/opensearch-2.2.0.yml', '4891')) + helper.addShMock("""gh issue list --repo https://github.com/opensearch-project/k-NN.git -S "[AUTOCUT] Integration Test Failed for k-NN-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/k-NN.git -S "[AUTOCUT] Integration Test Failed for geospatial-2.2.0 in:title is:closed closed:>=2023-10-24" --label autocut,v2.2.0 --json number --jq '.[0].number'""") { script -> + helper.addShMock("""gh issue list --repo https://github.com/opensearch-project/k-NN.git -S "[AUTOCUT] Integration Test Failed for k-NN-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/UpdateIntegTestFailureIssues_Jenkinsfile') @@ -197,6 +249,7 @@ class TestUpdateIntegTestFailureIssues extends BuildPipelineTest { @Test public void testGithubIssueEdit() { + this.registerLibTester(new UpdateIntegTestFailureIssuesLibTester('tests/data/opensearch-2.2.0.yml', '4891')) helper.addShMock("""gh issue list --repo https://github.com/opensearch-project/geospatial.git -S "[AUTOCUT] Integration Test Failed for geospatial-2.2.0 in:title" --label autocut,v2.2.0 --json number --jq '.[0].number'""") { script -> return [stdout: "22", exitValue: 0] } @@ -210,6 +263,7 @@ class TestUpdateIntegTestFailureIssues extends BuildPipelineTest { @Test public void testClosingGithubIssueOnSuccess() { + this.registerLibTester(new UpdateIntegTestFailureIssuesLibTester('tests/data/opensearch-2.2.0.yml', '4891')) helper.addShMock("date -d \"3 days ago\" +'%Y-%m-%d'") { script -> return [stdout: "2023-10-24", exitValue: 0] } @@ -223,6 +277,7 @@ class TestUpdateIntegTestFailureIssues extends BuildPipelineTest { @Test public void testNotClosingGithubIssueOnOneFailure() { + this.registerLibTester(new UpdateIntegTestFailureIssuesLibTester('tests/data/opensearch-2.2.0.yml', '4891')) helper.addShMock("date -d \"3 days ago\" +'%Y-%m-%d'") { script -> return [stdout: "2023-10-24", exitValue: 0] } @@ -234,6 +289,20 @@ class TestUpdateIntegTestFailureIssues extends BuildPipelineTest { assertThat(getCommands('sh', 'script'), hasItem("{script=gh issue edit bbb\nccc --repo https://github.com/opensearch-project/geospatial.git --body \"\n### Integration Test Failed for version 2.2.0. See the specifications below:\n\n#### Details\n\n| Platform | Distribution | Architecture | Test Report Manifest | Workflow Run |\n|----------|--------------|--------------|----------------------|--------------|\n| linux | tar | x64 | https://ci.opensearch.org/ci/dbc/integ-test/2.2.0/7984/linux/x64/tar/test-results/6561/integ-test/test-report.yml | https://build.ci.opensearch.org/job/integ-test/6561/display/redirect\n| linux | tar | arm64 | https://ci.opensearch.org/ci/dbc/integ-test/2.2.0/7984/linux/arm64/tar/test-results/6560/integ-test/test-report.yml | https://build.ci.opensearch.org/job/integ-test/6560/display/redirect\n\nCheck out test report manifest linked above for steps to reproduce, cluster and integration test failure logs. For additional information checkout the [wiki](https://github.com/opensearch-project/opensearch-build/wiki/Testing-the-Distribution) and [OpenSearch Metrics Dashboard](https://metrics.opensearch.org/_dashboards/app/dashboards#/view/21aad140-49f6-11ef-bbdd-39a9b324a5aa).\n\", returnStdout=true}")) } + @Test + public void testIssueCreationWithoutDistributionID() { + this.registerLibTester(new UpdateIntegTestFailureIssuesLibTester('tests/data/opensearch-2.2.0.yml')) + helper.addShMock("""gh issue list --repo https://github.com/opensearch-project/k-NN.git -S "[AUTOCUT] Integration Test Failed for k-NN-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/k-NN.git -S "[AUTOCUT] Integration Test Failed for k-NN-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_without_distributionID_Jenkinsfile') + assertThat(getCommands('println', ''), hasItem('Integration test failed for k-NN, creating github issue')) + assertThat(getCommands('sh', 'script'), hasItem("{script=gh issue edit bbb\nccc --repo https://github.com/opensearch-project/k-NN.git --body \"\n### Integration Test Failed for version 2.2.0. See the specifications below:\n\n#### Details\n\n| Platform | Distribution | Architecture | Test Report Manifest | Workflow Run |\n|----------|--------------|--------------|----------------------|--------------|\n| linux | tar | x64 | https://ci.opensearch.org/ci/dbc/integ-test/2.2.0/7984/linux/x64/tar/test-results/6561/integ-test/test-report.yml | https://build.ci.opensearch.org/job/integ-test/6561/display/redirect\n| linux | tar | arm64 | https://ci.opensearch.org/ci/dbc/integ-test/2.2.0/7984/linux/arm64/tar/test-results/6560/integ-test/test-report.yml | https://build.ci.opensearch.org/job/integ-test/6560/display/redirect\n\nCheck out test report manifest linked above for steps to reproduce, cluster and integration test failure logs. For additional information checkout the [wiki](https://github.com/opensearch-project/opensearch-build/wiki/Testing-the-Distribution) and [OpenSearch Metrics Dashboard](https://metrics.opensearch.org/_dashboards/app/dashboards#/view/21aad140-49f6-11ef-bbdd-39a9b324a5aa).\n\", returnStdout=true}")) + } + def getCommands(method, text) { def shCommands = helper.callStack.findAll { call -> call.methodName == method diff --git a/tests/jenkins/jobs/UpdateBuildFailureIssue_without_distributionID_Jenkinsfile b/tests/jenkins/jobs/UpdateBuildFailureIssue_without_distributionID_Jenkinsfile new file mode 100644 index 00000000..c7d530cc --- /dev/null +++ b/tests/jenkins/jobs/UpdateBuildFailureIssue_without_distributionID_Jenkinsfile @@ -0,0 +1,23 @@ +/* + * 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. + */ + +pipeline { + agent none + stages { + stage('updateIntegTestFailureIssuesWithoutDistId') { + steps { + script { + updateIntegTestFailureIssues( + inputManifestPath: 'tests/data/opensearch-2.2.0.yml' + ) + } + } + } + } +} diff --git a/tests/jenkins/jobs/UpdateBuildFailureIssue_without_distributionID_Jenkinsfile.txt b/tests/jenkins/jobs/UpdateBuildFailureIssue_without_distributionID_Jenkinsfile.txt new file mode 100644 index 00000000..884b7830 --- /dev/null +++ b/tests/jenkins/jobs/UpdateBuildFailureIssue_without_distributionID_Jenkinsfile.txt @@ -0,0 +1,147 @@ + UpdateBuildFailureIssue_without_distributionID_Jenkinsfile.run() + UpdateBuildFailureIssue_without_distributionID_Jenkinsfile.pipeline(groovy.lang.Closure) + UpdateBuildFailureIssue_without_distributionID_Jenkinsfile.echo(Executing on agent [label:none]) + UpdateBuildFailureIssue_without_distributionID_Jenkinsfile.stage(updateIntegTestFailureIssuesWithoutDistId, groovy.lang.Closure) + UpdateBuildFailureIssue_without_distributionID_Jenkinsfile.script(groovy.lang.Closure) + UpdateBuildFailureIssue_without_distributionID_Jenkinsfile.updateIntegTestFailureIssues({inputManifestPath=tests/data/opensearch-2.2.0.yml}) + updateIntegTestFailureIssues.readYaml({file=tests/data/opensearch-2.2.0.yml}) + updateIntegTestFailureIssues.string({credentialsId=jenkins-health-metrics-account-number, variable=METRICS_HOST_ACCOUNT}) + updateIntegTestFailureIssues.string({credentialsId=jenkins-health-metrics-cluster-endpoint, variable=METRICS_HOST_URL}) + updateIntegTestFailureIssues.withCredentials([METRICS_HOST_ACCOUNT, METRICS_HOST_URL], groovy.lang.Closure) + updateIntegTestFailureIssues.withAWS({role=OpenSearchJenkinsAccessRole, roleAccount=METRICS_HOST_ACCOUNT, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) + ComponentBuildStatus.getLatestDistributionBuildNumber() + updateIntegTestFailureIssues.println({\"size\":1,\"_source\":[\"distribution_build_number\"],\"query\":{\"bool\":{\"filter\":[{\"match_phrase\":{\"component_category\":\"OpenSearch\"}},{\"match_phrase\":{\"version\":\"2.2.0\"}}]}},\"sort\":[{\"build_start_time\":{\"order\":\"desc\"}}]}) + OpenSearchMetricsQuery.fetchMetrics({\"size\":1,\"_source\":[\"distribution_build_number\"],\"query\":{\"bool\":{\"filter\":[{\"match_phrase\":{\"component_category\":\"OpenSearch\"}},{\"match_phrase\":{\"version\":\"2.2.0\"}}]}},\"sort\":[{\"build_start_time\":{\"order\":\"desc\"}}]}) + updateIntegTestFailureIssues.sh({script= + set -e + set +x + curl -s -XGET "sample.url/opensearch-distribution-build-results/_search" --aws-sigv4 "aws:amz:us-east-1:es" --user "abc:xyz" -H "x-amz-security-token:sampleToken" -H 'Content-Type: application/json' -d "{\"size\":1,\"_source\":[\"distribution_build_number\"],\"query\":{\"bool\":{\"filter\":[{\"match_phrase\":{\"component_category\":\"OpenSearch\"}},{\"match_phrase\":{\"version\":\"2.2.0\"}}]}},\"sort\":[{\"build_start_time\":{\"order\":\"desc\"}}]}" | jq '.' + , returnStdout=true}) + ComponentIntegTestStatus.getComponents(passed) + OpenSearchMetricsQuery.fetchMetrics({\"size\":50,\"_source\":[\"component\"],\"query\":{\"bool\":{\"filter\":[{\"match_phrase\":{\"version\":\"2.2.0\"}},{\"match_phrase\":{\"component_category\":\"OpenSearch\"}},{\"match_phrase\":{\"distribution_build_number\":\"4891\"}},{\"match_phrase\":{\"component_build_result\":\"passed\"}}]}}}) + updateIntegTestFailureIssues.sh({script= + set -e + set +x + curl -s -XGET "sample.url/opensearch-integration-test-results/_search" --aws-sigv4 "aws:amz:us-east-1:es" --user "abc:xyz" -H "x-amz-security-token:sampleToken" -H 'Content-Type: application/json' -d "{\"size\":50,\"_source\":[\"component\"],\"query\":{\"bool\":{\"filter\":[{\"match_phrase\":{\"version\":\"2.2.0\"}},{\"match_phrase\":{\"component_category\":\"OpenSearch\"}},{\"match_phrase\":{\"distribution_build_number\":\"4891\"}},{\"match_phrase\":{\"component_build_result\":\"passed\"}}]}}}" | jq '.' + , returnStdout=true}) + ComponentIntegTestStatus.getComponents(failed) + OpenSearchMetricsQuery.fetchMetrics({\"size\":50,\"_source\":[\"component\"],\"query\":{\"bool\":{\"filter\":[{\"match_phrase\":{\"version\":\"2.2.0\"}},{\"match_phrase\":{\"component_category\":\"OpenSearch\"}},{\"match_phrase\":{\"distribution_build_number\":\"4891\"}},{\"match_phrase\":{\"component_build_result\":\"failed\"}}]}}}) + updateIntegTestFailureIssues.sh({script= + set -e + set +x + curl -s -XGET "sample.url/opensearch-integration-test-results/_search" --aws-sigv4 "aws:amz:us-east-1:es" --user "abc:xyz" -H "x-amz-security-token:sampleToken" -H 'Content-Type: application/json' -d "{\"size\":50,\"_source\":[\"component\"],\"query\":{\"bool\":{\"filter\":[{\"match_phrase\":{\"version\":\"2.2.0\"}},{\"match_phrase\":{\"component_category\":\"OpenSearch\"}},{\"match_phrase\":{\"distribution_build_number\":\"4891\"}},{\"match_phrase\":{\"component_build_result\":\"failed\"}}]}}}" | jq '.' + , returnStdout=true}) + updateIntegTestFailureIssues.sleep({time=3, unit=SECONDS}) + updateIntegTestFailureIssues.sleep({time=3, unit=SECONDS}) + updateIntegTestFailureIssues.sleep({time=3, unit=SECONDS}) + updateIntegTestFailureIssues.sleep({time=3, unit=SECONDS}) + updateIntegTestFailureIssues.sleep({time=3, unit=SECONDS}) + updateIntegTestFailureIssues.sleep({time=3, unit=SECONDS}) + updateIntegTestFailureIssues.println(Integration test failed for geospatial, creating github issue) + ComponentIntegTestStatus.getComponentIntegTestFailedData(geospatial) + OpenSearchMetricsQuery.fetchMetrics({\"_source\":[\"platform\",\"architecture\",\"distribution\",\"test_report_manifest_yml\",\"integ_test_build_url\"],\"query\":{\"bool\":{\"filter\":[{\"match_phrase\":{\"component\":\"geospatial\"}},{\"match_phrase\":{\"version\":\"2.2.0\"}},{\"match_phrase\":{\"distribution_build_number\":\"4891\"}}]}}}) + updateIntegTestFailureIssues.sh({script= + set -e + set +x + curl -s -XGET "sample.url/opensearch-integration-test-results/_search" --aws-sigv4 "aws:amz:us-east-1:es" --user "abc:xyz" -H "x-amz-security-token:sampleToken" -H 'Content-Type: application/json' -d "{\"_source\":[\"platform\",\"architecture\",\"distribution\",\"test_report_manifest_yml\",\"integ_test_build_url\"],\"query\":{\"bool\":{\"filter\":[{\"match_phrase\":{\"component\":\"geospatial\"}},{\"match_phrase\":{\"version\":\"2.2.0\"}},{\"match_phrase\":{\"distribution_build_number\":\"4891\"}}]}}}" | jq '.' + , returnStdout=true}) + CreateIntegTestMarkDownTable.create() + updateIntegTestFailureIssues.createGithubIssue({repoUrl=https://github.com/opensearch-project/geospatial.git, issueTitle=[AUTOCUT] Integration Test Failed for geospatial-2.2.0, issueBody= +### Integration Test Failed for version 2.2.0. See the specifications below: + +#### Details + +| Platform | Distribution | Architecture | Test Report Manifest | Workflow Run | +|----------|--------------|--------------|----------------------|--------------| +| linux | tar | x64 | https://ci.opensearch.org/ci/dbc/integ-test/2.2.0/7984/linux/x64/tar/test-results/6561/integ-test/test-report.yml | https://build.ci.opensearch.org/job/integ-test/6561/display/redirect +| linux | tar | arm64 | https://ci.opensearch.org/ci/dbc/integ-test/2.2.0/7984/linux/arm64/tar/test-results/6560/integ-test/test-report.yml | https://build.ci.opensearch.org/job/integ-test/6560/display/redirect + +Check out test report manifest linked above for steps to reproduce, cluster and integration test failure logs. For additional information checkout the [wiki](https://github.com/opensearch-project/opensearch-build/wiki/Testing-the-Distribution) and [OpenSearch Metrics Dashboard](https://metrics.opensearch.org/_dashboards/app/dashboards#/view/21aad140-49f6-11ef-bbdd-39a9b324a5aa). +, label=autocut,v2.2.0, issueEdit=true}) + createGithubIssue.usernamePassword({credentialsId=jenkins-github-bot-token, passwordVariable=GITHUB_TOKEN, usernameVariable=GITHUB_USER}) + createGithubIssue.withCredentials([[GITHUB_USER, GITHUB_TOKEN]], groovy.lang.Closure) + createGithubIssue.sh({script=gh issue list --repo https://github.com/opensearch-project/geospatial.git -S "[AUTOCUT] Integration Test Failed for geospatial-2.2.0 in:title" --json number --jq '.[0].number', returnStdout=true}) + createGithubIssue.sh({script=date -d "3 days ago" +'%Y-%m-%d', returnStdout=true}) + createGithubIssue.sh({script=gh issue list --repo https://github.com/opensearch-project/geospatial.git -S "[AUTOCUT] Integration Test Failed for geospatial-2.2.0 in:title is:closed closed:>=bbb +ccc" --json number --jq '.[0].number', returnStdout=true}) + createGithubIssue.println(Issue already exists, editing the issue body) + createGithubIssue.sh({script=gh issue edit bbb +ccc --repo https://github.com/opensearch-project/geospatial.git --body " +### Integration Test Failed for version 2.2.0. See the specifications below: + +#### Details + +| Platform | Distribution | Architecture | Test Report Manifest | Workflow Run | +|----------|--------------|--------------|----------------------|--------------| +| linux | tar | x64 | https://ci.opensearch.org/ci/dbc/integ-test/2.2.0/7984/linux/x64/tar/test-results/6561/integ-test/test-report.yml | https://build.ci.opensearch.org/job/integ-test/6561/display/redirect +| linux | tar | arm64 | https://ci.opensearch.org/ci/dbc/integ-test/2.2.0/7984/linux/arm64/tar/test-results/6560/integ-test/test-report.yml | https://build.ci.opensearch.org/job/integ-test/6560/display/redirect + +Check out test report manifest linked above for steps to reproduce, cluster and integration test failure logs. For additional information checkout the [wiki](https://github.com/opensearch-project/opensearch-build/wiki/Testing-the-Distribution) and [OpenSearch Metrics Dashboard](https://metrics.opensearch.org/_dashboards/app/dashboards#/view/21aad140-49f6-11ef-bbdd-39a9b324a5aa). +", returnStdout=true}) + updateIntegTestFailureIssues.sleep({time=3, unit=SECONDS}) + updateIntegTestFailureIssues.println(Integration test failed for k-NN, creating github issue) + ComponentIntegTestStatus.getComponentIntegTestFailedData(k-NN) + OpenSearchMetricsQuery.fetchMetrics({\"_source\":[\"platform\",\"architecture\",\"distribution\",\"test_report_manifest_yml\",\"integ_test_build_url\"],\"query\":{\"bool\":{\"filter\":[{\"match_phrase\":{\"component\":\"k-NN\"}},{\"match_phrase\":{\"version\":\"2.2.0\"}},{\"match_phrase\":{\"distribution_build_number\":\"4891\"}}]}}}) + updateIntegTestFailureIssues.sh({script= + set -e + set +x + curl -s -XGET "sample.url/opensearch-integration-test-results/_search" --aws-sigv4 "aws:amz:us-east-1:es" --user "abc:xyz" -H "x-amz-security-token:sampleToken" -H 'Content-Type: application/json' -d "{\"_source\":[\"platform\",\"architecture\",\"distribution\",\"test_report_manifest_yml\",\"integ_test_build_url\"],\"query\":{\"bool\":{\"filter\":[{\"match_phrase\":{\"component\":\"k-NN\"}},{\"match_phrase\":{\"version\":\"2.2.0\"}},{\"match_phrase\":{\"distribution_build_number\":\"4891\"}}]}}}" | jq '.' + , returnStdout=true}) + CreateIntegTestMarkDownTable.create() + updateIntegTestFailureIssues.createGithubIssue({repoUrl=https://github.com/opensearch-project/k-NN.git, issueTitle=[AUTOCUT] Integration Test Failed for k-NN-2.2.0, issueBody= +### Integration Test Failed for version 2.2.0. See the specifications below: + +#### Details + +| Platform | Distribution | Architecture | Test Report Manifest | Workflow Run | +|----------|--------------|--------------|----------------------|--------------| +| linux | tar | x64 | https://ci.opensearch.org/ci/dbc/integ-test/2.2.0/7984/linux/x64/tar/test-results/6561/integ-test/test-report.yml | https://build.ci.opensearch.org/job/integ-test/6561/display/redirect +| linux | tar | arm64 | https://ci.opensearch.org/ci/dbc/integ-test/2.2.0/7984/linux/arm64/tar/test-results/6560/integ-test/test-report.yml | https://build.ci.opensearch.org/job/integ-test/6560/display/redirect + +Check out test report manifest linked above for steps to reproduce, cluster and integration test failure logs. For additional information checkout the [wiki](https://github.com/opensearch-project/opensearch-build/wiki/Testing-the-Distribution) and [OpenSearch Metrics Dashboard](https://metrics.opensearch.org/_dashboards/app/dashboards#/view/21aad140-49f6-11ef-bbdd-39a9b324a5aa). +, label=autocut,v2.2.0, issueEdit=true}) + createGithubIssue.usernamePassword({credentialsId=jenkins-github-bot-token, passwordVariable=GITHUB_TOKEN, usernameVariable=GITHUB_USER}) + createGithubIssue.withCredentials([[GITHUB_USER, GITHUB_TOKEN]], groovy.lang.Closure) + createGithubIssue.sh({script=gh issue list --repo https://github.com/opensearch-project/k-NN.git -S "[AUTOCUT] Integration Test Failed for k-NN-2.2.0 in:title" --json number --jq '.[0].number', returnStdout=true}) + createGithubIssue.sh({script=date -d "3 days ago" +'%Y-%m-%d', returnStdout=true}) + createGithubIssue.sh({script=gh issue list --repo https://github.com/opensearch-project/k-NN.git -S "[AUTOCUT] Integration Test Failed for k-NN-2.2.0 in:title is:closed closed:>=bbb +ccc" --json number --jq '.[0].number', returnStdout=true}) + createGithubIssue.println(Issue already exists, editing the issue body) + createGithubIssue.sh({script=gh issue edit bbb +ccc --repo https://github.com/opensearch-project/k-NN.git --body " +### Integration Test Failed for version 2.2.0. See the specifications below: + +#### Details + +| Platform | Distribution | Architecture | Test Report Manifest | Workflow Run | +|----------|--------------|--------------|----------------------|--------------| +| linux | tar | x64 | https://ci.opensearch.org/ci/dbc/integ-test/2.2.0/7984/linux/x64/tar/test-results/6561/integ-test/test-report.yml | https://build.ci.opensearch.org/job/integ-test/6561/display/redirect +| linux | tar | arm64 | https://ci.opensearch.org/ci/dbc/integ-test/2.2.0/7984/linux/arm64/tar/test-results/6560/integ-test/test-report.yml | https://build.ci.opensearch.org/job/integ-test/6560/display/redirect + +Check out test report manifest linked above for steps to reproduce, cluster and integration test failure logs. For additional information checkout the [wiki](https://github.com/opensearch-project/opensearch-build/wiki/Testing-the-Distribution) and [OpenSearch Metrics Dashboard](https://metrics.opensearch.org/_dashboards/app/dashboards#/view/21aad140-49f6-11ef-bbdd-39a9b324a5aa). +", returnStdout=true}) + updateIntegTestFailureIssues.sleep({time=3, unit=SECONDS}) + updateIntegTestFailureIssues.println(Integration tests passed for cross-cluster-replication, closing github issue) + updateIntegTestFailureIssues.closeGithubIssue({repoUrl=https://github.com/opensearch-project/cross-cluster-replication.git, issueTitle=[AUTOCUT] Integration Test Failed for cross-cluster-replication-2.2.0, closeComment=Closing the issue as the integration tests for cross-cluster-replication passed for version: **2.2.0**.}) + closeGithubIssue.usernamePassword({credentialsId=jenkins-github-bot-token, passwordVariable=GITHUB_TOKEN, usernameVariable=GITHUB_USER}) + closeGithubIssue.withCredentials([[GITHUB_USER, GITHUB_TOKEN]], groovy.lang.Closure) + closeGithubIssue.sh({script=gh issue list --repo https://github.com/opensearch-project/cross-cluster-replication.git -S "[AUTOCUT] Integration Test Failed for cross-cluster-replication-2.2.0 in:title" --json number --jq '.[0].number', returnStdout=true}) + closeGithubIssue.sh({script=gh issue close bbb +ccc -R opensearch-project/cross-cluster-replication --comment "Closing the issue as the integration tests for cross-cluster-replication passed for version: **2.2.0**.", returnStdout=true}) + updateIntegTestFailureIssues.sleep({time=3, unit=SECONDS}) + updateIntegTestFailureIssues.sleep({time=3, unit=SECONDS}) + updateIntegTestFailureIssues.sleep({time=3, unit=SECONDS}) + updateIntegTestFailureIssues.sleep({time=3, unit=SECONDS}) + updateIntegTestFailureIssues.sleep({time=3, unit=SECONDS}) + updateIntegTestFailureIssues.sleep({time=3, unit=SECONDS}) + updateIntegTestFailureIssues.println(Integration tests passed for index-management, closing github issue) + updateIntegTestFailureIssues.closeGithubIssue({repoUrl=https://github.com/opensearch-project/index-management.git, issueTitle=[AUTOCUT] Integration Test Failed for index-management-2.2.0, closeComment=Closing the issue as the integration tests for index-management passed for version: **2.2.0**.}) + closeGithubIssue.usernamePassword({credentialsId=jenkins-github-bot-token, passwordVariable=GITHUB_TOKEN, usernameVariable=GITHUB_USER}) + closeGithubIssue.withCredentials([[GITHUB_USER, GITHUB_TOKEN]], groovy.lang.Closure) + closeGithubIssue.sh({script=gh issue list --repo https://github.com/opensearch-project/index-management.git -S "[AUTOCUT] Integration Test Failed for index-management-2.2.0 in:title" --json number --jq '.[0].number', returnStdout=true}) + closeGithubIssue.sh({script=gh issue close bbb +ccc -R opensearch-project/index-management --comment "Closing the issue as the integration tests for index-management passed for version: **2.2.0**.", returnStdout=true}) + updateIntegTestFailureIssues.sleep({time=3, unit=SECONDS}) + updateIntegTestFailureIssues.sleep({time=3, unit=SECONDS}) + updateIntegTestFailureIssues.sleep({time=3, unit=SECONDS}) + updateIntegTestFailureIssues.sleep({time=3, unit=SECONDS}) diff --git a/tests/jenkins/lib-testers/UpdateIntegTestFailureIssuesLibTester.groovy b/tests/jenkins/lib-testers/UpdateIntegTestFailureIssuesLibTester.groovy index a041e8de..8bc57cb3 100644 --- a/tests/jenkins/lib-testers/UpdateIntegTestFailureIssuesLibTester.groovy +++ b/tests/jenkins/lib-testers/UpdateIntegTestFailureIssuesLibTester.groovy @@ -31,32 +31,13 @@ class UpdateIntegTestFailureIssuesLibTester extends LibFunctionTester{ @Override void parameterInvariantsAssertions(Object call) { assertThat(call.args.inputManifestPath.first(), notNullValue()) - assertThat(call.args.distributionBuildNumber.first(), notNullValue()) } @Override boolean expectedParametersMatcher(Object call) { - return call.args.distributionBuildNumber.first().equals(this.distributionBuildNumber) - && call.args.inputManifestPath.first().equals(this.inputManifestPath) + return call.args.inputManifestPath.first().equals(this.inputManifestPath) } @Override - void configure(Object helper, Object binding) { - helper.registerAllowedMethod('withCredentials', [Map]) - helper.registerAllowedMethod('sleep', [Map]) - binding.setVariable('env', [ - 'METRICS_HOST_URL': 'sample.url', - 'AWS_ACCESS_KEY_ID': 'abc', - 'AWS_SECRET_ACCESS_KEY':'xyz', - 'AWS_SESSION_TOKEN': 'sampleToken' - ]) - helper.registerAllowedMethod('withCredentials', [Map, Closure], { args, closure -> - closure.delegate = delegate - return helper.callClosure(closure) - }) - helper.registerAllowedMethod('withAWS', [Map, Closure], { args, closure -> - closure.delegate = delegate - return helper.callClosure(closure) - }) - } + void configure(Object helper, Object binding) {} } diff --git a/vars/updateIntegTestFailureIssues.groovy b/vars/updateIntegTestFailureIssues.groovy index cb32d476..e55fbe9c 100644 --- a/vars/updateIntegTestFailureIssues.groovy +++ b/vars/updateIntegTestFailureIssues.groovy @@ -34,8 +34,7 @@ void call(Map args = [:]) { def awsSessionToken = env.AWS_SESSION_TOKEN def integTestIndexName = 'opensearch-integration-test-results' def buildIndexName = 'opensearch-distribution-build-results' - - def distributionBuildNumber = args.distributionBuildNumber ?: new ComponentBuildStatus(metricsUrl, awsAccessKey, awsSecretKey, awsSessionToken, buildIndexName, product, version, this).getLatestDistributionBuildNumber() + def distributionBuildNumber = args.distributionBuildNumber ?: new ComponentBuildStatus(metricsUrl, awsAccessKey, awsSecretKey, awsSessionToken, buildIndexName, product, version, this).getLatestDistributionBuildNumber().toString() ComponentIntegTestStatus componentIntegTestStatus = new ComponentIntegTestStatus(metricsUrl, awsAccessKey, awsSecretKey, awsSessionToken, integTestIndexName, product, version, distributionBuildNumber, this) passedComponents = componentIntegTestStatus.getComponents('passed')