From 455e9ef54b9e40ecc0ba567aa51be5310f33ede7 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:19:54 -0700 Subject: [PATCH] [Backport 6.x] Update the `component_build_result` field for `Not Available` scenario. (#466) Signed-off-by: Prudhvi Godithi Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] --- build.gradle | 2 +- .../TestPublishIntegTestResults.groovy | 46 +++++++++++++++++++ vars/publishIntegTestResults.groovy | 2 +- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 7d3fb6a0..237c7a37 100644 --- a/build.gradle +++ b/build.gradle @@ -127,7 +127,7 @@ jacocoTestReport { } } -String version = '6.7.1' +String version = '6.7.2' task updateVersion { doLast { diff --git a/tests/jenkins/TestPublishIntegTestResults.groovy b/tests/jenkins/TestPublishIntegTestResults.groovy index a21ac6df..afd713ed 100644 --- a/tests/jenkins/TestPublishIntegTestResults.groovy +++ b/tests/jenkins/TestPublishIntegTestResults.groovy @@ -208,6 +208,52 @@ class TestPublishIntegTestResults extends BuildPipelineTest { 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' + } + + @Test + void testComponentResultWithoutSecurityFail() { + def withSecurity = 'pass' + def withoutSecurity = 'fail' + def componentResult = (withSecurity == 'fail' || withoutSecurity == 'fail' || withSecurity == 'Not Available' || withoutSecurity == 'Not Available') ? 'failed' : 'passed' + + assert componentResult == 'failed' + } + + @Test + void testComponentResultWithSecurityNotAvailable() { + def withSecurity = 'Not Available' + def withoutSecurity = 'pass' + def componentResult = (withSecurity == 'fail' || withoutSecurity == 'fail' || withSecurity == 'Not Available' || withoutSecurity == 'Not Available') ? 'failed' : 'passed' + + assert componentResult == 'failed' + } + + @Test + void testComponentResultWithoutSecurityNotAvailable() { + def withSecurity = 'pass' + def withoutSecurity = 'Not Available' + def componentResult = (withSecurity == 'fail' || withoutSecurity == 'fail' || withSecurity == 'Not Available' || withoutSecurity == 'Not Available') ? 'failed' : 'passed' + + assert componentResult == 'failed' + } + + @Test + void testComponentResultBothPass() { + def withSecurity = 'pass' + def withoutSecurity = 'pass' + def componentResult = (withSecurity == 'fail' || withoutSecurity == 'fail' || withSecurity == 'Not Available' || withoutSecurity == 'Not Available') ? 'failed' : 'passed' + + assert componentResult == 'passed' + } + + @Test void testCallWithMissingArgs() { def script = loadScript('vars/publishIntegTestResults.groovy') diff --git a/vars/publishIntegTestResults.groovy b/vars/publishIntegTestResults.groovy index 290f95f8..55884682 100644 --- a/vars/publishIntegTestResults.groovy +++ b/vars/publishIntegTestResults.groovy @@ -64,7 +64,7 @@ void call(Map args = [:]) { def componentCategory = manifest.name def withSecurity = component.configs.find { it.name == 'with-security' }?.status?.toLowerCase() ?: 'unknown' def withoutSecurity = component.configs.find { it.name == 'without-security' }?.status?.toLowerCase() ?: 'unknown' - def componentResult = (withSecurity == 'fail' || withoutSecurity == 'fail') ? 'failed' : 'passed' + def componentResult = (withSecurity == 'fail' || withoutSecurity == 'fail' || withSecurity == 'Not Available' || withoutSecurity == 'Not Available') ? 'failed' : 'passed' def withSecurityYml = component.configs.find { it.name == 'with-security' }?.yml ?: '' def withSecurityStdout = component.configs.find { it.name == 'with-security' }?.cluster_stdout ?: [] def withSecurityStderr = component.configs.find { it.name == 'with-security' }?.cluster_stderr ?: []