Skip to content

Commit

Permalink
Add more details to integTest failure issues (opensearch-project#545)
Browse files Browse the repository at this point in the history
Signed-off-by: Sayali Gaikawad <[email protected]>
  • Loading branch information
gaiksaya authored Oct 25, 2024
1 parent 5c67543 commit c63a248
Show file tree
Hide file tree
Showing 11 changed files with 504 additions and 133 deletions.
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.2.1'
String version = '7.3.0'

task updateVersion {
doLast {
Expand Down
3 changes: 2 additions & 1 deletion src/jenkins/ComponentIntegTestStatus.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class ComponentIntegTestStatus {
"architecture",
"distribution",
"test_report_manifest_yml",
"integ_test_build_url"
"integ_test_build_url",
"rc_number"
],
query : [
bool: [
Expand Down
19 changes: 10 additions & 9 deletions src/jenkins/CreateIntegTestMarkDownTable.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,31 @@ package jenkins

class CreateIntegTestMarkDownTable {
String version
ArrayList<String> tableData

CreateIntegTestMarkDownTable(String version, List<Map<String, Object>> tableData) {
CreateIntegTestMarkDownTable(String version) {
this.version = version
this.tableData = tableData
}

def create() {
def create(List<Map<String, Object>> tableData, List releaseOwner) {

def tableHeader = """
### Integration Test Failed for version ${version}. See the specifications below:
#### Details
| Platform | Distribution | Architecture | Test Report Manifest | Workflow Run |
|----------|--------------|--------------|----------------------|--------------|
| Platform | Dist | Arch | Dist Build No. | RC | Test Report | Workflow Run | Failing tests |
|----------|------|------|----------------|----|-------------|--------------|---------------|
"""
def tableRows = this.tableData.collect { row ->
"| ${row.platform} | ${row.distribution} | ${row.architecture} | ${row.test_report_manifest_yml} | ${row.integ_test_build_url}"
}.join("\n")
def tableRows = tableData.collect { row ->
"| ${row.platform} | ${row.distribution} | ${row.architecture} | ${row.distribution_build_number} | ${row.rc_number} | ${row.test_report_manifest_yml} | ${row.integ_test_build_url} | [Check metrics](${row.metrics_visualization_url}) |"}.join("\n")

def additionalInformation = """
\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).
"""
if(!releaseOwner.isEmpty()) {
def tagReleaseOwner = releaseOwner.collect{ "@${it}"}.join(' ')
additionalInformation = additionalInformation + "\nTagging the release owners to take a look ${tagReleaseOwner}"
}
return tableHeader + tableRows + additionalInformation
}

Expand Down
74 changes: 74 additions & 0 deletions src/jenkins/ReleaseMetricsData.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* 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.
*/

package jenkins

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

class ReleaseMetricsData {
String metricsUrl
String awsAccessKey
String awsSecretKey
String awsSessionToken
String indexName
String version
def script
OpenSearchMetricsQuery openSearchMetricsQuery

ReleaseMetricsData(String metricsUrl, String awsAccessKey, String awsSecretKey, String awsSessionToken, String indexName, String version, def script) {
this.metricsUrl = metricsUrl
this.awsAccessKey = awsAccessKey
this.awsSecretKey = awsSecretKey
this.awsSessionToken = awsSessionToken
this.indexName = indexName
this.version = version
this.script = script
this.openSearchMetricsQuery = new OpenSearchMetricsQuery(metricsUrl, awsAccessKey, awsSecretKey, awsSessionToken, indexName, script)
}

String getReleaseOwnerQuery(String component) {
def queryMap = [
size : 1,
_source: "release_owners",
query : [
bool: [
filter: [
[
match_phrase: [
component: "${component}"
]
],
[
match_phrase: [
version: "${this.version}"
]
]
]
],
sort: [
[
current_date: [
order: "desc"
]
]
]
]
]
String query = JsonOutput.toJson(queryMap)
return query.replace('"', '\\"')
}

ArrayList getReleaseOwners(String component) {
def jsonResponse = this.openSearchMetricsQuery.fetchMetrics(getReleaseOwnerQuery(component))
def releaseOwners = jsonResponse.hits.hits._source.release_owners.flatten()
return releaseOwners
}
}
4 changes: 2 additions & 2 deletions tests/jenkins/TestComponentIntegTestStatus.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ package jenkins
import org.junit.*
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import groovy.mock.interceptor.MockFor

class TestComponentIntegTestStatus {

Expand Down Expand Up @@ -146,7 +145,8 @@ class TestComponentIntegTestStatus {
"architecture",
"distribution",
"test_report_manifest_yml",
"integ_test_build_url"
"integ_test_build_url",
"rc_number"
],
query: [
bool: [
Expand Down
31 changes: 19 additions & 12 deletions tests/jenkins/TestCreateIntegTestMarkDownTable.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,49 @@ package jenkins

import org.junit.*


class TestCreateIntegTestMarkDownTable {

@Test
void testCreateIntegTestMarkDownTableWithSampleData() {
def version = "2.18.0"
def releaseOwners = ['foo', 'bar']
def tableData = [
[
architecture:"x64",
distribution:"tar",
integ_test_build_url:"https://build.ci.opensearch.org/job/integ-test-opensearch-dashboards/6561/display/redirect",
integ_test_build_url:"some_integ_test_url",
platform:"linux",
test_report_manifest_yml:"https://ci.opensearch.org/ci/dbc/integ-test-opensearch-dashboards/2.18.0/7984/linux/x64/tar/test-results/6561/integ-test/test-report.yml"
test_report_manifest_yml:"test_report_dummy_url",
distribution_build_number: '1234',
rc_number: 1,
metrics_visualization_url: "some_url"
],
[
architecture:"arm64",
distribution:"tar",
integ_test_build_url:"https://build.ci.opensearch.org/job/integ-test-opensearch-dashboards/6560/display/redirect",
integ_test_build_url:"integ_test_dummy_url",
platform:"linux",
test_report_manifest_yml:"https://ci.opensearch.org/ci/dbc/integ-test-opensearch-dashboards/2.18.0/7984/linux/arm64/tar/test-results/6560/integ-test/test-report.yml"
test_report_manifest_yml:"test_report_2_dummy_url",
distribution_build_number: '1234',
rc_number: 1,
metrics_visualization_url: "some_other_url"
]
]
def createIntegTestMarkDownTable = new CreateIntegTestMarkDownTable(version, tableData)
def result = createIntegTestMarkDownTable.create()
def createIntegTestMarkDownTable = new CreateIntegTestMarkDownTable(version)
def result = createIntegTestMarkDownTable.create(tableData, releaseOwners)
def expectedOutput = """
### Integration Test Failed for version 2.18.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-opensearch-dashboards/2.18.0/7984/linux/x64/tar/test-results/6561/integ-test/test-report.yml | https://build.ci.opensearch.org/job/integ-test-opensearch-dashboards/6561/display/redirect
| linux | tar | arm64 | https://ci.opensearch.org/ci/dbc/integ-test-opensearch-dashboards/2.18.0/7984/linux/arm64/tar/test-results/6560/integ-test/test-report.yml | https://build.ci.opensearch.org/job/integ-test-opensearch-dashboards/6560/display/redirect
| Platform | Dist | Arch | Dist Build No. | RC | Test Report | Workflow Run | Failing tests |
|----------|------|------|----------------|----|-------------|--------------|---------------|
| linux | tar | x64 | 1234 | 1 | test_report_dummy_url | some_integ_test_url | [Check metrics](some_url) |
| linux | tar | arm64 | 1234 | 1 | test_report_2_dummy_url | integ_test_dummy_url | [Check metrics](some_other_url) |
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).
"""
Tagging the release owners to take a look @foo @bar"""
assert result == expectedOutput
}
}
111 changes: 111 additions & 0 deletions tests/jenkins/TestReleaseMetricsData.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* 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.
*/

package jenkins

import org.junit.*
import groovy.json.JsonOutput
import groovy.json.JsonSlurper

class TestReleaseMetricsData {
private ReleaseMetricsData releaseMetricsData
private final String metricsUrl = 'http://example.com'
private final String awsAccessKey = 'testAccessKey'
private final String awsSecretKey = 'testSecretKey'
private final String awsSessionToken = 'testSessionToken'
private final String version = "2.18.0"
private def script

@Before
void setUp() {
script = new Expando()
script.sh = { Map args ->
if (args.containsKey("script")) {
return """
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 31,
"relation": "eq"
},
"max_score": null,
"hits": [
{
"_index": "opensearch_release_metrics",
"_id": "9ee464d8-b47d-3f5e-aa8f-8768c98a8d69",
"_score": null,
"_source": {
"release_owners": [
"foo",
"bar"
]
},
"sort": [
1729707921551
]
}
]
}
}
"""
}
return ""
}
releaseMetricsData = new ReleaseMetricsData(metricsUrl, awsAccessKey, awsSecretKey, awsSessionToken, 'opensearch_release_metrics', version, script)
}

@Test
void testGetReleaseOwnerReturnQuery(){
String expectedOutput = JsonOutput.toJson([
size : 1,
_source: "release_owners",
query : [
bool: [
filter: [
[
match_phrase: [
component: "sql"
]
],
[
match_phrase: [
version: "2.18.0"
]
]
]
],
sort: [
[
current_date: [
order: "desc"
]
]
]
]
]).replace('"', '\\"')

def result = releaseMetricsData.getReleaseOwnerQuery('sql')
assert result == expectedOutput
}

@Test
void testGetReleaseOwners(){
def expectedOutput = ['foo', 'bar']
def result = releaseMetricsData.getReleaseOwners('sql')
assert result == expectedOutput
}
}
Loading

0 comments on commit c63a248

Please sign in to comment.