From 62cc781b161a4ccd5d4096e0fb92b80562fd6ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pl=C3=ADchal?= Date: Mon, 11 Nov 2024 19:03:19 +0100 Subject: [PATCH] Fix several issues in `/tests/discover/libraries` * 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. --- tests/discover/libraries/data/plan.fmf | 4 +-- .../libraries/data/strip-git-suffix.fmf | 29 +++++++++++++++++ .../libraries/data/strip_git_suffix.fmf | 32 ------------------- tests/discover/libraries/test.sh | 19 +++++------ 4 files changed, 39 insertions(+), 45 deletions(-) create mode 100644 tests/discover/libraries/data/strip-git-suffix.fmf delete mode 100644 tests/discover/libraries/data/strip_git_suffix.fmf diff --git a/tests/discover/libraries/data/plan.fmf b/tests/discover/libraries/data/plan.fmf index 3f44500087..0bf5dec3e0 100644 --- a/tests/discover/libraries/data/plan.fmf +++ b/tests/discover/libraries/data/plan.fmf @@ -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: diff --git a/tests/discover/libraries/data/strip-git-suffix.fmf b/tests/discover/libraries/data/strip-git-suffix.fmf new file mode 100644 index 0000000000..d0020a4f19 --- /dev/null +++ b/tests/discover/libraries/data/strip-git-suffix.fmf @@ -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 diff --git a/tests/discover/libraries/data/strip_git_suffix.fmf b/tests/discover/libraries/data/strip_git_suffix.fmf deleted file mode 100644 index 9cdda33f36..0000000000 --- a/tests/discover/libraries/data/strip_git_suffix.fmf +++ /dev/null @@ -1,32 +0,0 @@ -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. -test: ./file.sh - -/test1: - recommend: - - url: https://github.com/beakerlib/database.git - name: /mysql - - library(database/postgresql) - require: - - library(database/mariadb) - - url: https://github.com/beakerlib/test - name: /very/deep/file - type: library -/test2: - require: - - library(database/mariadb) - - url: https://github.com/beakerlib/squid.git - name: /squid - type: library - recommend: - - url: https://github.com/beakerlib/database - name: /postgresql - - library(database/postgresql) - - url: https://github.com/teemtee/fmf.git -/test3: - recommend: - - url: https://github.com/beakerlib/database.git - name: /postgresql diff --git a/tests/discover/libraries/test.sh b/tests/discover/libraries/test.sh index d59ee48cd9..d20d2a944b 100755 --- a/tests/discover/libraries/test.sh +++ b/tests/discover/libraries/test.sh @@ -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 @@ -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" @@ -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"