Skip to content

Commit

Permalink
Fix several issues in /tests/discover/libraries
Browse files Browse the repository at this point in the history
* Add the missing `rlPhaseEnd` which masked a failing assert
* Simplify check for the `.git` suffix stripping
* Modify pattern check for `dnf5` commands

The `.git` suffix test case was exercising too much, including
handling recommends covered by `/tests/prepare/recommend`. Also
renamed to use dashes consistently.
  • Loading branch information
psss committed Nov 11, 2024
1 parent efb4663 commit 62cc781
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 45 deletions.
4 changes: 2 additions & 2 deletions tests/discover/libraries/data/plan.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ execute:
discover+:
test: file

/strip_git_suffix:
/strip-git-suffix:
summary: "Check libraries can end in '.git' suffix"
discover+:
test: strip_git_suffix
test: strip-git-suffix

/certificate:
/rpm:
Expand Down
29 changes: 29 additions & 0 deletions tests/discover/libraries/data/strip-git-suffix.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
summary: Check libraries can end in '.git' suffix
description:
User doesn't need to care/remember whether to use '.git'
suffix or not in the 'require' or 'recommend' section -
both are allowed.
framework: shell
test: rpm -q mariadb squid

/name:
summary: Require using the library name
require:
- library(database/mariadb)
- library(squid/squid)

/short:
summary: Use url without the '.git' suffix
require:
- url: https://github.com/beakerlib/database
name: /mariadb
- url: https://github.com/beakerlib/squid
name: /squid

/long:
summary: Use url without the '.git' suffix
require:
- url: https://github.com/beakerlib/database.git
name: /mariadb
- url: https://github.com/beakerlib/squid.git
name: /squid
32 changes: 0 additions & 32 deletions tests/discover/libraries/data/strip_git_suffix.fmf

This file was deleted.

19 changes: 8 additions & 11 deletions tests/discover/libraries/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ rlJournalStart
rlRun -s "$tmt missing/repository" 2
rlAssertGrep 'Authentication failed.*something' $rlRun_LOG
rlRun -s "$tmt missing/library" 2
rlAssertGrep 'dnf install.*openssl/wrong' $rlRun_LOG
rlAssertGrep 'dnf.*install.*openssl/wrong' $rlRun_LOG
rlRun -s "$tmt missing/metadata" 2
rlAssertGrep 'Repository .* does not contain fmf metadata.' $rlRun_LOG
rlRun -s "$tmt missing/reference" 2
Expand All @@ -50,14 +50,10 @@ rlJournalStart
rlPhaseEnd

rlPhaseStartTest "Strip git suffix"
rlRun -s "$tmt strip_git_suffix" 0
rlRun -s "$tmt strip-git-suffix" 0
rlAssertGrep "summary: 3 tests selected" $rlRun_LOG
rlAssertGrep "/strip_git_suffix/test2" $rlRun_LOG
rlAssertGrep \
"Detected library.*https://github.com/teemtee/fmf.git" \
"$rlRun_LOG"
rlAssertNotGrep 'Library.*conflicts with already fetched library' \
"$rlRun_LOG"
rlAssertGrep "Detected library.*beakerlib/database.git.*mariadb" "$rlRun_LOG"
rlAssertNotGrep "Library.*conflicts with already fetched library" "$rlRun_LOG"
rlPhaseEnd

rlPhaseStartTest "Attempt github/beakerlib lookup just once per repo"
Expand All @@ -66,12 +62,13 @@ rlJournalStart
rlAssertGrep "git clone .*beakerlib/FOOBAR" "$tmp/querying/log.txt"
# We know it doesn't exist
rlAssertGrep "Repository 'https://github.com/beakerlib/FOOBAR' not found." "$tmp/querying/log.txt"
# We do two attempts for clone (with --depth=1 and without it)
LINES=$(grep "git clone .*beakerlib/FOOBAR" "$tmp/querying/log.txt" | wc -l)
rlAssertEquals "Just two clone calls on non-existent repository" "2" "$LINES"
# We do two attempts for clone (with --depth=1 and three retries without it)
LINES=$(grep "Run command: git clone .*beakerlib/FOOBAR" "$tmp/querying/log.txt" | wc -l)
rlAssertEquals "Just four clone calls on non-existent repository" "4" "$LINES"
# However we do it all just once
LINES=$(grep "Repository 'https://github.com/beakerlib/FOOBAR' not found." "$tmp/querying/log.txt" | wc -l)
rlAssertEquals "Just one attempt on non-existent repository" "1" "$LINES"
rlPhaseEnd

rlPhaseStartCleanup
rlRun "popd"
Expand Down

0 comments on commit 62cc781

Please sign in to comment.