Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix several issues in /tests/discover/libraries #3352

Merged
merged 1 commit into from
Nov 12, 2024
Merged
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
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
Loading