From de2cb784a655ab2b433e7c6f8bb3b2273caaa0b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Gull=C3=B3n?= Date: Fri, 26 Apr 2024 13:04:12 +0200 Subject: [PATCH 1/5] add keyword to skip RF test if bug is open --- scripts/jira/manage_ticket.py | 20 ++++++++++++++++++++ test/resources/common.resource | 18 ++++++++++++++++++ test/suites/standard1/networking-smoke.robot | 2 ++ 3 files changed, 40 insertions(+) diff --git a/scripts/jira/manage_ticket.py b/scripts/jira/manage_ticket.py index 6fef16e2b2..06fca4202a 100644 --- a/scripts/jira/manage_ticket.py +++ b/scripts/jira/manage_ticket.py @@ -309,6 +309,16 @@ def command_close(args): ) +def command_get_status(args): + """Implement 'get_status' command.""" + server = jira.JIRA( + server=SERVER_URL, + token_auth=os.environ.get("JIRA_API_TOKEN"), + ) + ticket = server.issue(args.ticket_id) + print(f"{ticket.fields.status}") + + def main(): """The main program.""" parser = argparse.ArgumentParser( @@ -378,12 +388,22 @@ def main(): help='report but make no changes', ) + get_status_parser = subparsers.add_parser( + "get_status", + help="Find tickets status from ticket id", + ) + get_status_parser.add_argument( + "--ticket-id", dest="ticket_id", default=None, help="the ticket id", type=str + ) + args = parser.parse_args() if args.command == 'start': command_start(args) elif args.command == 'close': command_close(args) + elif args.command == "get_status": + command_get_status(args) else: parser.print_help() diff --git a/test/resources/common.resource b/test/resources/common.resource index b2a6763517..3068fdd12d 100644 --- a/test/resources/common.resource +++ b/test/resources/common.resource @@ -3,10 +3,15 @@ Documentation Keywords common to many test suites Library OperatingSystem Library String +Library Process Library SSHLibrary Resource ../resources/kubeconfig.resource +*** Variables *** +${JIRA_API_TOKEN} ${EMPTY} + + *** Keywords *** Setup Suite [Documentation] Setup a namespace-less test suite by configuring Kubeconfig @@ -113,3 +118,16 @@ Create Random Temp Directory ${path}= Join Path ${root_path} ${rand} Create Directory ${path} RETURN ${path} + +QE Team Skip Test If Bug Is Open + [Documentation] Skip jira bug is not in Closed or Done state + [Arguments] ${ticket_id} + + IF '${JIRA_API_TOKEN}' == '${EMPTY}' + Log Variable 'JIRA_API_TOKEN' does not exist. Test is NOT skipped + ELSE + ${result}= Run Process ./scripts/jira/manage_ticket.sh get_status --ticket-id ${ticket_id} | tail -n1 + ... shell=True env:JIRA_API_TOKEN=${JIRA_API_TOKEN} cwd=/Users/agullon/workspace/microshift/ + Should Be Equal As Integers 0 ${result.rc} + Skip If "${result.stdout} != Closed and ${result.stdout} != Done" + END diff --git a/test/suites/standard1/networking-smoke.robot b/test/suites/standard1/networking-smoke.robot index e52546357a..eebf756049 100644 --- a/test/suites/standard1/networking-smoke.robot +++ b/test/suites/standard1/networking-smoke.robot @@ -25,6 +25,8 @@ Router Smoke Test ... Expose Hello MicroShift Service Via Route ... Restart Router + QE Team Skip Test If Bug Is Open USHIFT-2349 + Wait Until Keyword Succeeds 10x 6s ... Access Hello Microshift Success ${HTTP_PORT} From 0cbf9f4194061ce5dfcc186707ad4bc30a32922e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Gull=C3=B3n?= Date: Fri, 26 Apr 2024 13:20:57 +0200 Subject: [PATCH 2/5] fix path to manage_ticket.sh --- test/resources/common.resource | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/resources/common.resource b/test/resources/common.resource index 3068fdd12d..2f3e9ddb19 100644 --- a/test/resources/common.resource +++ b/test/resources/common.resource @@ -126,8 +126,8 @@ QE Team Skip Test If Bug Is Open IF '${JIRA_API_TOKEN}' == '${EMPTY}' Log Variable 'JIRA_API_TOKEN' does not exist. Test is NOT skipped ELSE - ${result}= Run Process ./scripts/jira/manage_ticket.sh get_status --ticket-id ${ticket_id} | tail -n1 - ... shell=True env:JIRA_API_TOKEN=${JIRA_API_TOKEN} cwd=/Users/agullon/workspace/microshift/ + ${result}= Run Process ../scripts/jira/manage_ticket.sh get_status --ticket-id ${ticket_id} | tail -n1 + ... shell=True env:JIRA_API_TOKEN=${JIRA_API_TOKEN} Should Be Equal As Integers 0 ${result.rc} Skip If "${result.stdout} != Closed and ${result.stdout} != Done" END From 7bf0fadcf35e7e0276b446bf98ffeb3b82b3173d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Gull=C3=B3n?= Date: Fri, 26 Apr 2024 14:56:20 +0200 Subject: [PATCH 3/5] change keyword name --- test/resources/common.resource | 2 +- test/suites/standard1/networking-smoke.robot | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/resources/common.resource b/test/resources/common.resource index 2f3e9ddb19..cc47fcc782 100644 --- a/test/resources/common.resource +++ b/test/resources/common.resource @@ -119,7 +119,7 @@ Create Random Temp Directory Create Directory ${path} RETURN ${path} -QE Team Skip Test If Bug Is Open +Skip Test If Bug Is Open [Documentation] Skip jira bug is not in Closed or Done state [Arguments] ${ticket_id} diff --git a/test/suites/standard1/networking-smoke.robot b/test/suites/standard1/networking-smoke.robot index eebf756049..743f0ae871 100644 --- a/test/suites/standard1/networking-smoke.robot +++ b/test/suites/standard1/networking-smoke.robot @@ -25,7 +25,7 @@ Router Smoke Test ... Expose Hello MicroShift Service Via Route ... Restart Router - QE Team Skip Test If Bug Is Open USHIFT-2349 + Skip Test If Bug Is Open USHIFT-2349 Wait Until Keyword Succeeds 10x 6s ... Access Hello Microshift Success ${HTTP_PORT} From 1568a870ed72ec74739b4bbe67d61fe8012ec9c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Gull=C3=B3n?= Date: Tue, 30 Apr 2024 12:38:20 +0200 Subject: [PATCH 4/5] remove check Done status --- test/resources/common.resource | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/resources/common.resource b/test/resources/common.resource index cc47fcc782..3c7c530e3a 100644 --- a/test/resources/common.resource +++ b/test/resources/common.resource @@ -129,5 +129,5 @@ Skip Test If Bug Is Open ${result}= Run Process ../scripts/jira/manage_ticket.sh get_status --ticket-id ${ticket_id} | tail -n1 ... shell=True env:JIRA_API_TOKEN=${JIRA_API_TOKEN} Should Be Equal As Integers 0 ${result.rc} - Skip If "${result.stdout} != Closed and ${result.stdout} != Done" + Skip If '${result.stdout}' != 'Closed' END From 793490852483a07aed558a9a94454ebdb91f7fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Gull=C3=B3n?= Date: Fri, 3 May 2024 10:58:24 +0200 Subject: [PATCH 5/5] change condition to not skip if manage_ticket.sh script fails --- test/resources/common.resource | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/resources/common.resource b/test/resources/common.resource index 3c7c530e3a..c2e3edad7d 100644 --- a/test/resources/common.resource +++ b/test/resources/common.resource @@ -128,6 +128,5 @@ Skip Test If Bug Is Open ELSE ${result}= Run Process ../scripts/jira/manage_ticket.sh get_status --ticket-id ${ticket_id} | tail -n1 ... shell=True env:JIRA_API_TOKEN=${JIRA_API_TOKEN} - Should Be Equal As Integers 0 ${result.rc} - Skip If '${result.stdout}' != 'Closed' + Skip If '${result.stdout}' == 'To Do' or '${result.stdout}' == 'In Progress' or '${result.stdout}' == 'Code Review' or '${result.stdout}' == 'Review' END