From d08c4db52f2845a98c1867554ca9023161b91e87 Mon Sep 17 00:00:00 2001 From: Therese Cornell Date: Thu, 18 Dec 2025 11:54:17 -0500 Subject: [PATCH 1/2] Do not require the project key in reportportal plugin schema since it can be specified in TMT_PLUGIN_REPORT_REPORTPORTAL_PROJECT environment var or on the commandline. The reportportal plugin code appears to alredy handle when the project key is not specified in any of the allowed forms. It throws an exception. The added test requires reportportal access and can be run locally. --- tests/report/reportportal/data/project.fmf | 25 ++++++++++ tests/report/reportportal/project.sh | 54 ++++++++++++++++++++++ tmt/schemas/report/reportportal.yaml | 1 - 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 tests/report/reportportal/data/project.fmf create mode 100755 tests/report/reportportal/project.sh diff --git a/tests/report/reportportal/data/project.fmf b/tests/report/reportportal/data/project.fmf new file mode 100644 index 0000000000..de433c5ade --- /dev/null +++ b/tests/report/reportportal/data/project.fmf @@ -0,0 +1,25 @@ +discover: + how: fmf +provision: + how: container +execute: + how: tmt + +enabled: false +adjust: + - enabled: true + when: project is defined + because: we do not want test.sh to use this plan file + +/missing-project: + summary: Test tmt linter + + report: + how: reportportal + +/has-project: + summary: Test tmt linter + + report: + how: reportportal + project: tcornell_personal diff --git a/tests/report/reportportal/project.sh b/tests/report/reportportal/project.sh new file mode 100755 index 0000000000..560d4a29b2 --- /dev/null +++ b/tests/report/reportportal/project.sh @@ -0,0 +1,54 @@ +#!/bin/bash +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +TOKEN=$TMT_PLUGIN_REPORT_REPORTPORTAL_TOKEN +URL=$TMT_PLUGIN_REPORT_REPORTPORTAL_URL +PROJECT="$(yq -r '."/has-project".report.project' 'data/project.fmf')" +ARTIFACTS=$TMT_REPORT_ARTIFACTS_URL + +rlJournalStart + rlPhaseStartSetup + rlRun "pushd data" + rlRun "run=$(mktemp -d)" 0 "Create run workdir" + rlRun "set -o pipefail" + if [[ -z "$TOKEN" || -z "$URL" || -z "$PROJECT" ]]; then + rlFail "URL, TOKEN and PROJECT must be defined properly" || rlDie + fi + rlPhaseEnd + + rlPhaseStartTest "Verify project key is required" + # Make sure the project key is not set in env var + TMT_PLUGIN_REPORT_REPORTPORTAL_PROJECT="" + + # Its not defined anywhere else and not defined in the this command + # An exception should occur + rlRun -s "tmt run --id $run --scratch --all provision --how container report --verbose --how reportportal plan --default" 2 "Command line without project arg" + rlAssertGrep "plan failed" $rlRun_LOG + rlAssertGrep "No ReportPortal project provided." $rlRun_LOG + + # Its not defined anywhere else and not defined in the this plan + rlRun -s "tmt -c project=1 run --id $run --scratch plan --name /project/missing-project" 2 "plan file without project key" + rlAssertGrep "plan failed" $rlRun_LOG + rlAssertGrep "No ReportPortal project provided." $rlRun_LOG + + # Its defined in the command line + rlRun -s "tmt run --id $run --scratch --all provision --how container report --verbose --how reportportal --project $PROJECT plan --default" 2 "Command line with project arg" + rlAssertGrep "url: https?://.*\.redhat\.com/ui/#${PROJECT}/launches/all/[0-9]+" $rlRun_LOG -Eq + + # Its defined in the plan file + rlRun -s "tmt -c project=1 run --id $run --scratch plan --name /project/has-project" 2 "plan file with project key" + rlAssertGrep "url: https?://.*\.redhat\.com/ui/#${PROJECT}/launches/all/[0-9]+" $rlRun_LOG -Eq + + # Its defined in the env var + TMT_PLUGIN_REPORT_REPORTPORTAL_PROJECT=$PROJECT + rlRun -s "tmt run --id $run --scratch --all provision --how container report --verbose --how reportportal plan --default" 2 "command line with project key in env var" + rlAssertGrep "url: https?://.*\.redhat\.com/ui/#${PROJECT}/launches/all/[0-9]+" $rlRun_LOG -Eq + + rlPhaseEnd + + + rlPhaseStartCleanup + rlRun "rm -rf $run" 0 "Remove run workdir" + rlRun "popd" + rlPhaseEnd +rlJournalEnd diff --git a/tmt/schemas/report/reportportal.yaml b/tmt/schemas/report/reportportal.yaml index a5850300ca..0b890c079a 100644 --- a/tmt/schemas/report/reportportal.yaml +++ b/tmt/schemas/report/reportportal.yaml @@ -94,4 +94,3 @@ properties: required: - how - - project From 11980254e7ff17386404496f645bc2ec25f2a470 Mon Sep 17 00:00:00 2001 From: Therese Cornell Date: Thu, 18 Dec 2025 11:59:41 -0500 Subject: [PATCH 2/2] Change the test reportportal project key back to the default test_tmt --- tests/report/reportportal/data/project.fmf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/report/reportportal/data/project.fmf b/tests/report/reportportal/data/project.fmf index de433c5ade..4c41f3a6a3 100644 --- a/tests/report/reportportal/data/project.fmf +++ b/tests/report/reportportal/data/project.fmf @@ -22,4 +22,4 @@ adjust: report: how: reportportal - project: tcornell_personal + project: test_tmt