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

[Backport 7.x] Handle publishIntegTestResults lib when test reports are not available. #548

Merged
merged 1 commit into from
Oct 25, 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
43 changes: 41 additions & 2 deletions tests/jenkins/TestPublishIntegTestResults.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,8 @@ class TestPublishIntegTestResults extends BuildPipelineTest {
distribution: 'tar',
component_category: 'test_category',
test_type: 'test_type',
test_class: 'Not Available',
test_name: 'Not Available'
test_class: 'Result Not Available',
test_name: 'Result Not Available'
]
]
def parsedResult = result.trim().split('\n').collect { new JsonSlurper().parseText(it) }
Expand All @@ -486,6 +486,45 @@ class TestPublishIntegTestResults extends BuildPipelineTest {
assert parsedResult == expectedJson
}

@Test
void testProcessFailedTestsWithTestResultFilesListNotAvailable() {
def script = loadScript('vars/publishIntegTestResults.groovy')
def result = script.processFailedTests(['Test Result Files List 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: 'Report Not Available',
test_name: 'Report 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
Expand Down
8 changes: 7 additions & 1 deletion vars/publishIntegTestResults.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,13 @@ def processFailedTests(failedTests, componentName, componentRepo, componentRepoU
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")
platform, architecture, distribution, componentCategory, securityType, "Result Not Available", "Result Not Available")
finalFailedTestsJsonDoc += "{\"index\": {\"_index\": \"${testFailuresindexName}\"}}\n${testResultJsonContent}\n"
break
case failedTests.contains("Test Result Files List Not Available"):
def testResultJsonContent = generateFailedTestJson(componentName, componentRepo, componentRepoUrl, version, integTestBuildNumber,
integTestBuildUrl, distributionBuildNumber, distributionBuildUrl, buildStartTime, rc, rcNumber,
platform, architecture, distribution, componentCategory, securityType, "Report Not Available", "Report Not Available")
finalFailedTestsJsonDoc += "{\"index\": {\"_index\": \"${testFailuresindexName}\"}}\n${testResultJsonContent}\n"
break
case failedTests.contains("No Failed Test"):
Expand Down
Loading