From 1e5f6d361bcdb544a4af28f238352d7805be928f Mon Sep 17 00:00:00 2001 From: Prudhvi Godithi Date: Wed, 16 Oct 2024 15:57:23 -0700 Subject: [PATCH] Integration test results Signed-off-by: Prudhvi Godithi --- build.gradle | 2 +- .../TestPublishIntegTestResults.groovy | 357 +++++++++++++++++- vars/publishIntegTestResults.groovy | 207 +++++++++- 3 files changed, 556 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 60d79815..de4be937 100644 --- a/build.gradle +++ b/build.gradle @@ -128,7 +128,7 @@ jacocoTestReport { } } -String version = '7.1.0' +String version = '7.2.0' task updateVersion { doLast { diff --git a/tests/jenkins/TestPublishIntegTestResults.groovy b/tests/jenkins/TestPublishIntegTestResults.groovy index 173bc9e7..446bbb9e 100644 --- a/tests/jenkins/TestPublishIntegTestResults.groovy +++ b/tests/jenkins/TestPublishIntegTestResults.groovy @@ -156,9 +156,6 @@ class TestPublishIntegTestResults extends BuildPipelineTest { "without_security_test_stderr": { "type": "keyword" } - }, - "aliases": { - "opensearch-integration-test-results": {} } } }' @@ -170,6 +167,22 @@ class TestPublishIntegTestResults extends BuildPipelineTest { create_index_response=$(curl -s -XPUT "METRICS_HOST_URL/test-index" --aws-sigv4 "aws:amz:us-east-1:es" --user "null:null" -H "x-amz-security-token:null" -H 'Content-Type: application/json' -d "${INDEX_MAPPING}") if [[ $create_index_response == *'"acknowledged":true'* ]]; then echo "Index created successfully." + echo "Updating alias..." + update_alias_response=\$(curl -s -XPOST "METRICS_HOST_URL/_aliases" --aws-sigv4 "aws:amz:us-east-1:es" --user "null:null" -H "x-amz-security-token:null" -H "Content-Type: application/json" -d '{ + "actions": [ + { + "add": { + "index": "test-index", + "alias": "opensearch-integration-test-results" + } + } + ] + }') + if [[ \$update_alias_response == *'"acknowledged":true'* ]]; then + echo "Alias updated successfully." + else + echo "Failed to update alias. Error message: \$update_alias_response" + fi else echo "Failed to create index. Error message: $create_index_response" exit 1 @@ -185,6 +198,132 @@ class TestPublishIntegTestResults extends BuildPipelineTest { assert normalizeString(calledCommands[0]) == normalizeString(expectedCommandBlock) } + @Test + void testIndexTestFailuresData() { + def indexName = 'opensearch-integration-test-failures-test-index' + def testRecordsFile = 'test-failures.json' + + def script = loadScript('vars/publishIntegTestResults.groovy') + + def calledCommands = new ArrayList() + script.metaClass.sh = { String command -> + calledCommands << command + if (command.contains("curl -I")) { + return "HTTP/1.1 200 OK" + } else if (command.contains("curl -s -XPUT") && command.contains(indexName)) { + return '{"acknowledged":true}' + } else if (command.contains("curl -XPOST") && command.contains(indexName)) { + return '{"took":10, "errors":false}' + } else { + throw new IllegalArgumentException("Unexpected command: $command") + } + } + + script.indexTestFailuresData(indexName, testRecordsFile) + + def expectedCommandBlock = '''set +e + set +x + echo "INDEX NAME IS opensearch-integration-test-failures-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" + }, + "test_type": { + "type": "keyword" + }, + "test_class": { + "type": "keyword" + }, + "test_name": { + "type": "keyword" + } + } + } + }' + curl -I "METRICS_HOST_URL/opensearch-integration-test-failures-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" + else + echo "Index does not exist. Creating..." + create_index_response=$(curl -s -XPUT "METRICS_HOST_URL/opensearch-integration-test-failures-test-index" --aws-sigv4 "aws:amz:us-east-1:es" --user "null:null" -H "x-amz-security-token:null" -H 'Content-Type: application/json' -d "${INDEX_MAPPING}") + if [[ $create_index_response == *'"acknowledged":true'* ]]; then + echo "Index created successfully." + echo "Updating alias..." + update_alias_response=$(curl -s -XPOST "METRICS_HOST_URL/_aliases" --aws-sigv4 "aws:amz:us-east-1:es" --user "null:null" -H "x-amz-security-token:null" -H "Content-Type: application/json" -d '{ + "actions": [ + { + "add": { + "index": "opensearch-integration-test-failures-test-index", + "alias": "opensearch-integration-test-failures" + } + } + ] + }') + if [[ $update_alias_response == *'"acknowledged":true'* ]]; then + echo "Alias updated successfully." + else + echo "Failed to update alias. Error message: $update_alias_response" + fi + else + echo "Failed to create index. Error message: $create_index_response" + exit 1 + fi + fi + if [ -s test-failures.json ]; then + echo "File Exists, indexing failed tests." + curl -XPOST "METRICS_HOST_URL/opensearch-integration-test-failures-test-index/_bulk" --aws-sigv4 "aws:amz:us-east-1:es" --user "null:null" -H "x-amz-security-token:null" -H "Content-Type: application/x-ndjson" --data-binary "@test-failures.json" + else + echo "File Does not exist. No tests records to process." + fi''' + + assert calledCommands.size() == 1 + assert normalizeString(calledCommands[0]) == normalizeString(expectedCommandBlock) + } @Test void testGenerateJson() { @@ -235,12 +374,219 @@ class TestPublishIntegTestResults extends BuildPipelineTest { assert parsedResult == expectedJson } + @Test + void testGenerateFailedTestJson() { + def script = loadScript('vars/publishIntegTestResults.groovy') + + def result = script.generateFailedTestJson( + 'component1', 'componentRepo', 'https://componentRepoUrl', '1.0', 123, + 'http://example.com/build/123', 456, 'http://example.com/distribution/456', + System.currentTimeMillis(), 'rc1', 1, 'linux', 'x64', 'tar', 'test_category', + 'test_type', 'test_class', 'test_name' + ) + + def parsedResult = new JsonSlurper().parseText(result) + def expectedJson = [ + component: 'component1', + component_repo: 'componentRepo', + component_repo_url: 'https://componentRepoUrl', + version: '1.0', + integ_test_build_number: 123, + integ_test_build_url: 'http://example.com/build/123', + distribution_build_number: 456, + distribution_build_url: 'http://example.com/distribution/456', + rc: 'rc1', + rc_number: 1, + platform: 'linux', + architecture: 'x64', + distribution: 'tar', + component_category: 'test_category', + test_type: 'test_type', + test_class: 'test_class', + test_name: 'test_name' + ] + + // Remove the dynamic field for comparison + parsedResult.remove('build_start_time') + assert parsedResult == expectedJson + } + + @Test + void testProcessFailedTestsWithEmptyList_withInputs() { + def failedTests = [] + def componentName = "MyComponent" + def componentRepo = "my-repo" + def componentRepoUrl = "https://example.com/my-repo" + def version = "1.0.0" + def integTestBuildNumber = 123 + def integTestBuildUrl = "https://example.com/builds/123" + def distributionBuildNumber = 456 + def distributionBuildUrl = "https://example.com/builds/456" + def buildStartTime = "2023-10-17T12:00:00Z" + def rc = "RC1" + def rcNumber = 1 + def platform = "Linux" + def architecture = "x86_64" + def distribution = "Ubuntu 22.04" + def componentCategory = "Backend" + def securityType = "Web Application" + def testFailuresindexName = "test-failures-index" + def script = loadScript('vars/publishIntegTestResults.groovy') + def result = script.processFailedTests(failedTests, componentName, componentRepo, componentRepoUrl, version, integTestBuildNumber, integTestBuildUrl, distributionBuildNumber, distributionBuildUrl, buildStartTime, rc, rcNumber, platform, architecture, distribution, componentCategory, securityType, testFailuresindexName) + assert result == "" + } + + @Test + void testProcessFailedTestsWithEmptyList() { + def script = loadScript('vars/publishIntegTestResults.groovy') + def result = script.processFailedTests([], 'component1', 'componentRepo', 'https://componentRepoUrl', '1.0', + 123, 'http://example.com/build/123', 456, 'http://example.com/distribution/456', + System.currentTimeMillis(), 'rc1', 1, 'linux', 'x64', 'tar', 'test_category', + 'test_type', 'test_failures_index') + assert result == "" + } + + @Test + void testProcessFailedTestsWithTestResultNotAvailable() { + def script = loadScript('vars/publishIntegTestResults.groovy') + def result = script.processFailedTests(['Test Result Not Available'], 'component1', 'componentRepo', + 'https://componentRepoUrl', '1.0', 123, 'http://example.com/build/123', 456, + 'http://example.com/distribution/456', System.currentTimeMillis(), 'rc1', 1, + 'linux', 'x64', 'tar', 'test_category', 'test_type', 'test_failures_index') + def expectedJson = [ + [ + index: [ + _index: 'test_failures_index' + ] + ], + [ + component: 'component1', + component_repo: 'componentRepo', + component_repo_url: 'https://componentRepoUrl', + version: '1.0', + integ_test_build_number: 123, + integ_test_build_url: 'http://example.com/build/123', + distribution_build_number: 456, + distribution_build_url: 'http://example.com/distribution/456', + rc: 'rc1', + rc_number: 1, + platform: 'linux', + architecture: 'x64', + distribution: 'tar', + component_category: 'test_category', + test_type: 'test_type', + test_class: 'Not Available', + test_name: 'Not Available' + ] + ] + def parsedResult = result.trim().split('\n').collect { new JsonSlurper().parseText(it) } + parsedResult.each { json -> + json.remove('build_start_time') + } + assert parsedResult == expectedJson + } + + + + @Test + void testProcessFailedTestsWithNoFailedTest() { + def script = loadScript('vars/publishIntegTestResults.groovy') + def result = script.processFailedTests(['No Failed Test'], 'component1', 'componentRepo', + 'https://componentRepoUrl', '1.0', 123, 'http://example.com/build/123', 456, + 'http://example.com/distribution/456', System.currentTimeMillis(), 'rc1', 1, + 'linux', 'x64', 'tar', 'test_category', 'test_type', 'test_failures_index') + + assert result == "" + } + + @Test + void testProcessFailedTestsSampleOpenSearchFailures() { + def script = loadScript('vars/publishIntegTestResults.groovy') + def result = script.processFailedTests(['org.opensearch.indexmanagement.rollup.runner.RollupRunnerIT#test search max buckets breaker'], 'os_component', + 'os_componentRepo', 'https://os_componentRepoUrl', '1.0', 123, 'http://example.com/os-build/123', 456, + 'http://example.com/os-distribution/456', System.currentTimeMillis(), 'rc1', 1, + 'linux', 'x64', 'tar', 'OpenSearch', 'test_type', 'test_failures_index') + def expectedJson = [ + [ + index: [ + _index: 'test_failures_index' + ] + ], + [ + component: 'os_component', + component_repo: 'os_componentRepo', + component_repo_url: 'https://os_componentRepoUrl', + version: '1.0', + integ_test_build_number: 123, + integ_test_build_url: 'http://example.com/os-build/123', + distribution_build_number: 456, + distribution_build_url: 'http://example.com/os-distribution/456', + rc: 'rc1', + rc_number: 1, + platform: 'linux', + architecture: 'x64', + distribution: 'tar', + component_category: 'OpenSearch', + test_type: 'test_type', + test_class: 'org.opensearch.indexmanagement.rollup.runner.RollupRunnerIT', + test_name: 'test search max buckets breaker' + ] + + ] + def parsedResult = result.trim().split('\n').collect { new JsonSlurper().parseText(it) } + parsedResult.each { json -> + json.remove('build_start_time') + } + assert parsedResult == expectedJson + } + + @Test + void testProcessFailedTestsSampleOpenSearchDashboardsFailures() { + def script = loadScript('vars/publishIntegTestResults.groovy') + def result = script.processFailedTests(['integration/plugins/security-analytics-dashboards-plugin/4_findings.spec#Findings \"before all\" hook for \"displays findings based on recently ingested data\"'], 'osd_component', + 'osd_componentRepo', 'https://osd_componentRepoUrl', '1.0', 123, 'http://example.com/osd-build/123', 456, + 'http://example.com/osd-distribution/456', System.currentTimeMillis(), 'rc1', 1, + 'linux', 'x64', 'tar', 'OpenSearch Dashboards', 'test_type', 'test_failures_index') + def expectedJson = [ + [ + index: [ + _index: 'test_failures_index' + ] + ], + [ + component: 'osd_component', + component_repo: 'osd_componentRepo', + component_repo_url: 'https://osd_componentRepoUrl', + version: '1.0', + integ_test_build_number: 123, + integ_test_build_url: 'http://example.com/osd-build/123', + distribution_build_number: 456, + distribution_build_url: 'http://example.com/osd-distribution/456', + rc: 'rc1', + rc_number: 1, + platform: 'linux', + architecture: 'x64', + distribution: 'tar', + component_category: 'OpenSearch Dashboards', + test_type: 'test_type', + test_class: 'integration/plugins/security-analytics-dashboards-plugin/4_findings.spec', + test_name: 'Findings \"before all\" hook for \"displays findings based on recently ingested data\"' + ] + + ] + def parsedResult = result.trim().split('\n').collect { new JsonSlurper().parseText(it) } + parsedResult.each { json -> + json.remove('build_start_time') + } + assert parsedResult == expectedJson + } + + @Test void testComponentResultWithSecurityFail() { def withSecurity = 'fail' def withoutSecurity = 'pass' def componentResult = (withSecurity == 'fail' || withoutSecurity == 'fail' || withSecurity == 'Not Available' || withoutSecurity == 'Not Available') ? 'failed' : 'passed' - assert componentResult == 'failed' } @@ -287,7 +633,6 @@ class TestPublishIntegTestResults extends BuildPipelineTest { def args = [ distributionBuildUrl: "http://example.com/distribution/456", testReportManifestYml: "path/to/testReportManifest.yml", - //jobName: "test-job" // Missing required argument ] def result = script.call(args) @@ -301,7 +646,7 @@ class TestPublishIntegTestResults extends BuildPipelineTest { def args = [ distributionBuildUrl: "http://example.com/distribution/456", testReportManifestYml: "path/to/testReportManifest.yml", - jobName: "" // Empty required argument + jobName: "" ] def result = script.call(args) diff --git a/vars/publishIntegTestResults.groovy b/vars/publishIntegTestResults.groovy index e3646cf2..8024034e 100644 --- a/vars/publishIntegTestResults.groovy +++ b/vars/publishIntegTestResults.groovy @@ -42,6 +42,7 @@ void call(Map args = [:]) { def manifestFile = readFile testReportManifestYml def manifest = readYaml text: manifestFile def indexName = "opensearch-integration-test-results-${formattedDate}" + def testFailuresindexName = "opensearch-integration-test-failures-${formattedDate}" def finalJsonDoc = "" def version = manifest.version.toString() def distributionBuildNumber = manifest.id @@ -70,6 +71,14 @@ void call(Map args = [:]) { def withoutSecurityClusterStderr = component.configs.find { it.name == 'without-security' }?.cluster_stderr ?: [] def withoutSecurityTestStdout = component.configs.find { it.name == 'without-security' }?.test_stdout ?: '' def withoutSecurityTestStderr = component.configs.find { it.name == 'without-security' }?.test_stderr ?: '' + def withSecurityFailedTests = component.configs.find { it.name == 'with-security' }?.failed_test ?: [] + processFailedTests(withSecurityFailedTests, componentName, componentRepo, componentRepoUrl, version, integTestBuildNumber, + integTestBuildUrl, distributionBuildNumber, distributionBuildUrl, buildStartTime, rc, rcNumber, + platform, architecture, distribution, componentCategory, "with-security", testFailuresindexName) + def withoutSecurityFailedTests = component.configs.find { it.name == 'without-security' }?.failed_test ?: [] + processFailedTests(withoutSecurityFailedTests, componentName, componentRepo, componentRepoUrl, version, integTestBuildNumber, + integTestBuildUrl, distributionBuildNumber, distributionBuildUrl, buildStartTime, rc, rcNumber, + platform, architecture, distribution, componentCategory, "without-security", testFailuresindexName) def jsonContent = generateJson( componentName, componentRepo, componentRepoUrl, version, integTestBuildNumber, integTestBuildUrl, distributionBuildNumber, distributionBuildUrl, @@ -88,8 +97,159 @@ void call(Map args = [:]) { indexFailedTestData(indexName, "test-records.json") } +def processFailedTests(failedTests, componentName, componentRepo, componentRepoUrl, version, integTestBuildNumber, + integTestBuildUrl, distributionBuildNumber, distributionBuildUrl, buildStartTime, + rc, rcNumber, platform, architecture, distribution, componentCategory, securityType, testFailuresindexName) { + + def finalFailedTestsJsonDoc = "" + switch (true) { + case failedTests.isEmpty(): + break + case failedTests.contains("Test Result Not Available"): + def testResultJsonContent = generateFailedTestJson(componentName, componentRepo, componentRepoUrl, version, integTestBuildNumber, + integTestBuildUrl, distributionBuildNumber, distributionBuildUrl, buildStartTime, rc, rcNumber, + platform, architecture, distribution, componentCategory, securityType, "Not Available", "Not Available") + finalFailedTestsJsonDoc += "{\"index\": {\"_index\": \"${testFailuresindexName}\"}}\n${testResultJsonContent}\n" + break + case failedTests.contains("No Failed Test"): + break + default: + failedTests.collect { failedTest -> + def match = failedTest.split("#") + if (match) { + def testResultJsonContent = generateFailedTestJson(componentName, componentRepo, componentRepoUrl, version, integTestBuildNumber, + integTestBuildUrl, distributionBuildNumber, distributionBuildUrl, buildStartTime, rc, rcNumber, + platform, architecture, distribution, componentCategory, securityType, match[0].trim(), match[1].trim()) + finalFailedTestsJsonDoc += "{\"index\": {\"_index\": \"${testFailuresindexName}\"}}\n${testResultJsonContent}\n" + } + } + break + } + if (!finalFailedTestsJsonDoc.isEmpty()) { + writeFile file: "test-failures.json", text: finalFailedTestsJsonDoc + def fileContents = readFile(file: "test-failures.json").trim() + indexTestFailuresData(testFailuresindexName, "test-failures.json") + } + return finalFailedTestsJsonDoc +} + + boolean argCheck(String str) { return (str == null || str.allWhitespace || str.isEmpty()) } +void indexTestFailuresData(testFailuresindexName, testFailuresFile) { + withCredentials([ + string(credentialsId: 'jenkins-health-metrics-account-number', variable: 'METRICS_HOST_ACCOUNT'), + string(credentialsId: 'jenkins-health-metrics-cluster-endpoint', variable: 'METRICS_HOST_URL') + ]) { + withAWS(role: 'OpenSearchJenkinsAccessRole', roleAccount: "${METRICS_HOST_ACCOUNT}", duration: 900, roleSessionName: 'jenkins-session') { + def awsAccessKey = env.AWS_ACCESS_KEY_ID + def awsSecretKey = env.AWS_SECRET_ACCESS_KEY + def awsSessionToken = env.AWS_SESSION_TOKEN + sh """ + set +e + set +x + echo "INDEX NAME IS ${testFailuresindexName}" + 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" + }, + "test_type": { + "type": "keyword" + }, + "test_class": { + "type": "keyword" + }, + "test_name": { + "type": "keyword" + } + } + } + }' + curl -I "${METRICS_HOST_URL}/${testFailuresindexName}" --aws-sigv4 \"aws:amz:us-east-1:es\" --user \"${awsAccessKey}:${awsSecretKey}\" -H \"x-amz-security-token:${awsSessionToken}\" | grep -E "HTTP\\/[0-9]+(\\.[0-9]+)? 200" + if [ \$? -eq 0 ]; then + echo "Index already exists. Indexing Results" + else + echo "Index does not exist. Creating..." + create_index_response=\$(curl -s -XPUT "${METRICS_HOST_URL}/${testFailuresindexName}" --aws-sigv4 \"aws:amz:us-east-1:es\" --user \"${awsAccessKey}:${awsSecretKey}\" -H \"x-amz-security-token:${awsSessionToken}\" -H 'Content-Type: application/json' -d "\${INDEX_MAPPING}") + if [[ \$create_index_response == *'"acknowledged":true'* ]]; then + echo "Index created successfully." + echo "Updating alias..." + update_alias_response=\$(curl -s -XPOST "${METRICS_HOST_URL}/_aliases" --aws-sigv4 "aws:amz:us-east-1:es" --user "${awsAccessKey}:${awsSecretKey}" -H "x-amz-security-token:${awsSessionToken}" -H "Content-Type: application/json" -d '{ + "actions": [ + { + "add": { + "index": "${testFailuresindexName}", + "alias": "opensearch-integration-test-failures" + } + } + ] + }') + if [[ \$update_alias_response == *'"acknowledged":true'* ]]; then + echo "Alias updated successfully." + else + echo "Failed to update alias. Error message: \$update_alias_response" + fi + else + echo "Failed to create index. Error message: \$create_index_response" + exit 1 + fi + fi + if [ -s ${testFailuresFile} ]; then + echo "File Exists, indexing failed tests." + curl -XPOST "${METRICS_HOST_URL}/$testFailuresindexName/_bulk" --aws-sigv4 \"aws:amz:us-east-1:es\" --user \"${awsAccessKey}:${awsSecretKey}\" -H \"x-amz-security-token:${awsSessionToken}\" -H "Content-Type: application/x-ndjson" --data-binary "@${testFailuresFile}" + else + echo "File Does not exist. No tests records to process." + fi + """ + } + } + } + void indexFailedTestData(indexName, testRecordsFile) { withCredentials([ string(credentialsId: 'jenkins-health-metrics-account-number', variable: 'METRICS_HOST_ACCOUNT'), @@ -194,9 +354,6 @@ void indexFailedTestData(indexName, testRecordsFile) { "without_security_test_stderr": { "type": "keyword" } - }, - "aliases": { - "opensearch-integration-test-results": {} } } }' @@ -208,6 +365,22 @@ void indexFailedTestData(indexName, testRecordsFile) { create_index_response=\$(curl -s -XPUT "${METRICS_HOST_URL}/${indexName}" --aws-sigv4 \"aws:amz:us-east-1:es\" --user \"${awsAccessKey}:${awsSecretKey}\" -H \"x-amz-security-token:${awsSessionToken}\" -H 'Content-Type: application/json' -d "\${INDEX_MAPPING}") if [[ \$create_index_response == *'"acknowledged":true'* ]]; then echo "Index created successfully." + echo "Updating alias..." + update_alias_response=\$(curl -s -XPOST "${METRICS_HOST_URL}/_aliases" --aws-sigv4 "aws:amz:us-east-1:es" --user "${awsAccessKey}:${awsSecretKey}" -H "x-amz-security-token:${awsSessionToken}" -H "Content-Type: application/json" -d '{ + "actions": [ + { + "add": { + "index": "${indexName}", + "alias": "opensearch-integration-test-results" + } + } + ] + }') + if [[ \$update_alias_response == *'"acknowledged":true'* ]]; then + echo "Alias updated successfully." + else + echo "Failed to update alias. Error message: \$update_alias_response" + fi else echo "Failed to create index. Error message: \$create_index_response" exit 1 @@ -224,6 +397,34 @@ void indexFailedTestData(indexName, testRecordsFile) { } } +def generateFailedTestJson(componentName, componentRepo, componentRepoUrl, version, + integTestBuildNumber, integTestBuildUrl, distributionBuildNumber, distributionBuildUrl, + buildStartTime, rc, rcNumber, platform, architecture, distribution, componentCategory, + testType, testClass, testName) { + def json = [ + component: componentName, + component_repo: componentRepo, + component_repo_url: componentRepoUrl, + version: version, + integ_test_build_number: integTestBuildNumber, + integ_test_build_url: integTestBuildUrl, + distribution_build_number: distributionBuildNumber, + distribution_build_url: distributionBuildUrl, + build_start_time: buildStartTime, + rc: rc, + rc_number: rcNumber, + platform: platform, + architecture: architecture, + distribution: distribution, + component_category: componentCategory, + test_type: testType, + test_class: testClass, + test_name: testName + ] + return JsonOutput.toJson(json) +} + + def generateJson(componentName, componentRepo, componentRepoUrl, version, integTestBuildNumber, integTestBuildUrl, distributionBuildNumber, distributionBuildUrl, buildStartTime, rc, rcNumber, platform, architecture, distribution, componentCategory,