Skip to content
Open
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
25 changes: 25 additions & 0 deletions tests/report/reportportal/data/project.fmf
Original file line number Diff line number Diff line change
@@ -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: test_tmt
54 changes: 54 additions & 0 deletions tests/report/reportportal/project.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion tmt/schemas/report/reportportal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,3 @@ properties:

required:
- how
- project
Loading