Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix release metrics query to retrieve release owners #553

Merged
merged 4 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ jacocoTestReport {
}
}

String version = '7.3.0'
String version = '7.3.1'

task updateVersion {
doLast {
Expand Down
17 changes: 8 additions & 9 deletions src/jenkins/ReleaseMetricsData.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
package jenkins

import groovy.json.JsonOutput
import groovyjarjarantlr.collections.List
import utils.OpenSearchMetricsQuery

class ReleaseMetricsData {
Expand Down Expand Up @@ -43,21 +42,21 @@ class ReleaseMetricsData {
filter: [
[
match_phrase: [
component: "${component}"
version: "${this.version}"
]
],
[
match_phrase: [
version: "${this.version}"
"component": "${component}"
]
]
]
],
sort: [
[
current_date: [
order: "desc"
]
]
],
sort : [
[
current_date: [
order: "desc"
]
]
]
Expand Down
1 change: 1 addition & 0 deletions src/utils/OpenSearchMetricsQuery.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class OpenSearchMetricsQuery {
}

def fetchMetrics(String query) {
this.script.println('Running query: '+ query)
def response = script.sh(
script: """
set -e
Expand Down
16 changes: 8 additions & 8 deletions tests/jenkins/TestReleaseMetricsData.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,21 @@ class TestReleaseMetricsData {
filter: [
[
match_phrase: [
component: "sql"
version: "2.18.0"
]
],
[
match_phrase: [
version: "2.18.0"
"component": "sql"
]
]
]
],
sort: [
[
current_date: [
order: "desc"
]
]
],
sort : [
[
current_date: [
order: "desc"
]
]
]
Expand Down
4 changes: 2 additions & 2 deletions tests/jenkins/TestUpdateIntegTestFailureIssues.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,10 @@ class TestUpdateIntegTestFailureIssues extends BuildPipelineTest {
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: latestDistributionBuildNumberResponse, exitValue: 0]
}
helper.addShMock("""\n set -e\n set +x\n curl -s -XGET \"sample.url/opensearch_release_metrics/_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\\":\\"release_owners\\",\\"query\\":{\\"bool\\":{\\"filter\\":[{\\"match_phrase\\":{\\"component\\":\\"k-NN\\"}},{\\"match_phrase\\":{\\"version\\":\\"2.2.0\\"}}]},\\"sort\\":[{\\"current_date\\":{\\"order\\":\\"desc\\"}}]}}\" | jq '.'\n """) { script ->
helper.addShMock("""\n set -e\n set +x\n curl -s -XGET \"sample.url/opensearch_release_metrics/_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\\":\\"release_owners\\",\\"query\\":{\\"bool\\":{\\"filter\\":[{\\"match_phrase\\":{\\"version\\":\\"2.2.0\\"}},{\\"match_phrase\\":{\\"component\\":\\"k-NN\\"}}]}},\\"sort\\":[{\\"current_date\\":{\\"order\\":\\"desc\\"}}]}\" | jq '.'\n """) { script ->
return [stdout: unformattedResponseForReleaseOwners, exitValue: 0]
}
helper.addShMock("""\n set -e\n set +x\n curl -s -XGET \"sample.url/opensearch_release_metrics/_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\\":\\"release_owners\\",\\"query\\":{\\"bool\\":{\\"filter\\":[{\\"match_phrase\\":{\\"component\\":\\"geospatial\\"}},{\\"match_phrase\\":{\\"version\\":\\"2.2.0\\"}}]},\\"sort\\":[{\\"current_date\\":{\\"order\\":\\"desc\\"}}]}}\" | jq '.'\n """) { script ->
helper.addShMock("""\n set -e\n set +x\n curl -s -XGET \"sample.url/opensearch_release_metrics/_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\\":\\"release_owners\\",\\"query\\":{\\"bool\\":{\\"filter\\":[{\\"match_phrase\\":{\\"version\\":\\"2.2.0\\"}},{\\"match_phrase\\":{\\"component\\":\\"geospatial\\"}}]}},\\"sort\\":[{\\"current_date\\":{\\"order\\":\\"desc\\"}}]}\" | jq '.'\n """) { script ->
return [stdout: unformattedResponseForReleaseOwnersGeo, exitValue: 0]
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/jenkins/jobs/UpdateBuildFailureIssue_Jenkinsfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
updateBuildFailureIssues.withAWS({role=OpenSearchJenkinsAccessRole, roleAccount=METRICS_HOST_ACCOUNT, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure)
ComponentBuildStatus.getComponents(passed)
OpenSearchMetricsQuery.fetchMetrics({\"_source\":[\"component\"],\"query\":{\"bool\":{\"filter\":[{\"match_phrase\":{\"component_category\":\"OpenSearch\"}},{\"match_phrase\":{\"component_build_result\":\"passed\"}},{\"match_phrase\":{\"version\":\"2.2.0\"}},{\"match_phrase\":{\"distribution_build_number\":\"32\"}},{\"range\":{\"build_start_time\":{\"from\":\"now-6h\",\"to\":\"now\"}}}]}}})
updateBuildFailureIssues.println(Running query: {\"_source\":[\"component\"],\"query\":{\"bool\":{\"filter\":[{\"match_phrase\":{\"component_category\":\"OpenSearch\"}},{\"match_phrase\":{\"component_build_result\":\"passed\"}},{\"match_phrase\":{\"version\":\"2.2.0\"}},{\"match_phrase\":{\"distribution_build_number\":\"32\"}},{\"range\":{\"build_start_time\":{\"from\":\"now-6h\",\"to\":\"now\"}}}]}}})
updateBuildFailureIssues.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 "{\"_source\":[\"component\"],\"query\":{\"bool\":{\"filter\":[{\"match_phrase\":{\"component_category\":\"OpenSearch\"}},{\"match_phrase\":{\"component_build_result\":\"passed\"}},{\"match_phrase\":{\"version\":\"2.2.0\"}},{\"match_phrase\":{\"distribution_build_number\":\"32\"}},{\"range\":{\"build_start_time\":{\"from\":\"now-6h\",\"to\":\"now\"}}}]}}}" | jq '.'
, returnStdout=true})
ComponentBuildStatus.getComponents(failed)
OpenSearchMetricsQuery.fetchMetrics({\"_source\":[\"component\"],\"query\":{\"bool\":{\"filter\":[{\"match_phrase\":{\"component_category\":\"OpenSearch\"}},{\"match_phrase\":{\"component_build_result\":\"failed\"}},{\"match_phrase\":{\"version\":\"2.2.0\"}},{\"match_phrase\":{\"distribution_build_number\":\"32\"}},{\"range\":{\"build_start_time\":{\"from\":\"now-6h\",\"to\":\"now\"}}}]}}})
updateBuildFailureIssues.println(Running query: {\"_source\":[\"component\"],\"query\":{\"bool\":{\"filter\":[{\"match_phrase\":{\"component_category\":\"OpenSearch\"}},{\"match_phrase\":{\"component_build_result\":\"failed\"}},{\"match_phrase\":{\"version\":\"2.2.0\"}},{\"match_phrase\":{\"distribution_build_number\":\"32\"}},{\"range\":{\"build_start_time\":{\"from\":\"now-6h\",\"to\":\"now\"}}}]}}})
updateBuildFailureIssues.sh({script=
set -e
set +x
Expand Down
Loading
Loading