Skip to content

Commit

Permalink
Integration test results
Browse files Browse the repository at this point in the history
Signed-off-by: Prudhvi Godithi <[email protected]>
  • Loading branch information
prudhvigodithi committed Oct 16, 2024
1 parent 4e94ed7 commit f11f855
Showing 1 changed file with 69 additions and 1 deletion.
70 changes: 69 additions & 1 deletion vars/publishIntegTestResults.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@ 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")


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")


def jsonContent = generateJson(
componentName, componentRepo, componentRepoUrl, version, integTestBuildNumber,
integTestBuildUrl, distributionBuildNumber, distributionBuildUrl,
Expand All @@ -85,9 +98,37 @@ void call(Map args = [:]) {
}
writeFile file: "test-records.json", text: finalJsonDoc
def fileContents = readFile(file: "test-records.json").trim()
indexFailedTestData(indexName, "test-records.json")
// indexFailedTestData(indexName, "test-records.json")
}

def processFailedTests(failedTests, componentName, componentRepo, componentRepoUrl, version, integTestBuildNumber,
integTestBuildUrl, distributionBuildNumber, distributionBuildUrl, buildStartTime,
rc, rcNumber, platform, architecture, distribution, componentCategory, securityType) {

if (failedTests.isEmpty()) {
println("Empty Results")
} else if (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")
println("The ${securityType} testResultJsonContent is: " + testResultJsonContent)

} else if (failedTests.contains("No Failed Test")) {
println("Tests Passed")
} else {
failedTests.collect { failedTest ->
def match = failedTest =~ /([^#]+)#(.*)/
if (match) {
def testResultJsonContent = generatefailedTestJson(componentName, componentRepo, componentRepoUrl, version, integTestBuildNumber,
integTestBuildUrl, distributionBuildNumber, distributionBuildUrl, buildStartTime, rc, rcNumber,
platform, architecture, distribution, componentCategory, securityType, match[0][1].tokenize('.').last(), match[0][2].trim())
println("The ${securityType} testResultJsonContent is: " + testResultJsonContent)
}
}
}
}


boolean argCheck(String str) { return (str == null || str.allWhitespace || str.isEmpty()) }

void indexFailedTestData(indexName, testRecordsFile) {
Expand Down Expand Up @@ -224,6 +265,33 @@ 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
]
}


def generateJson(componentName, componentRepo, componentRepoUrl, version,
integTestBuildNumber, integTestBuildUrl, distributionBuildNumber, distributionBuildUrl,
buildStartTime, rc, rcNumber, platform, architecture, distribution, componentCategory,
Expand Down

0 comments on commit f11f855

Please sign in to comment.