Repository: teemtee/tmt (language: python)

Issue:
Enable the full test suite for pull requests
We'd like to move the whole coverage of `/tests/full` into pull request testing. This issue will track the progress of the migration.

Related pull requests:

* #2558
* #2222 
* #2688 
* #2700 
* #2701 

Additional coverage which is run only with `how=full` follows:

### Tagged with `additional_coverage`

* [x] /tests/core/escaping
* [x] /tests/core/spaces
* [x] /tests/discover/distgit
* [x] /tests/discover/libraries
* [x] /tests/execute/duration
* [x] /tests/execute/nonroot
* [x] /tests/execute/reboot/reuse-provision
* [x] /tests/execute/reboot/shorten-timeout
* [x] /tests/execute/rsync
* [x] /tests/execute/tty
* [x] /tests/execute/upgrade/full
* [x] /tests/finish/ansible
* [x] /tests/login/ready
* [x] /tests/multihost/web
* [x] /tests/prepare/ansible
* [x] /tests/prepare/install
* [x] /tests/prepare/recommend
* [x] /tests/provision/reboot
* [x] /tests/provision/ssh-options
* [x] /tests/provision/virtual.testcloud
* [x] /tests/pull/results
* [x] /tests/pull/simple
* [x] /tests/run/shell
* [x] /tests/run/worktree
* [x] /tests/security/ansible
* [x] /tests/test/check/avc
* [x] /tests/test/check/dmesg
* [x] /tests/test/debug

### /plans/features/advanced
* [x] /tests/execute/reboot/reuse-provision
* [x] /tests/execute/reboot/shorten-timeout
* [x] /tests/execute/upgrade/full
* [x] /tests/multihost/web

### /plans/features/steps/discover
* [x] /tests/discover/libraries


### /plans/features/steps/execute
* [x] /tests/execute/nonroot
* [x] /tests/execute/rsync

### /plans/features/steps/the-rest
* [x] /tests/provision/ssh-options
* [x] /tests/provision/virtual.testcloud

### smoke test for provision connect
* [x]  /tests/execute/reboot/reuse-provision


Discussion / hints:

Fix patch:
diff --git a/plans/features/advanced.fmf b/plans/features/advanced.fmf
index 21b28641b9..a19feedabf 100644
--- a/plans/features/advanced.fmf
+++ b/plans/features/advanced.fmf
@@ -5,4 +5,4 @@ description:
     installation works as expected. These can take some time.
 discover:
     how: fmf
-    filter: 'tier: 4'
+    filter: 'tier: 4 & tag:-provision-only'
diff --git a/plans/features/basic.fmf b/plans/features/basic.fmf
index 280e08dc1b..21e0a088c7 100644
--- a/plans/features/basic.fmf
+++ b/plans/features/basic.fmf
@@ -5,4 +5,4 @@ description:
     their individual duration should not exceed 5 minutes.
 discover:
     how: fmf
-    filter: 'tier: 2'
+    filter: 'tier: 2 & tag:-provision-only'
diff --git a/plans/features/core.fmf b/plans/features/core.fmf
index 02b378d2e9..5ecd021e54 100644
--- a/plans/features/core.fmf
+++ b/plans/features/core.fmf
@@ -5,4 +5,4 @@ description:
     tests and plans, presence of documentation. Usually fast.
 discover:
     how: fmf
-    filter: 'tier: 0, 1'
+    filter: 'tier: 0, 1 & tag:-provision-only'


Test patch:
diff --git a/tests/discover/libraries/data/plan.fmf b/tests/discover/libraries/data/plan.fmf
index 3b82eb54dc..7e876c75d1 100644
--- a/tests/discover/libraries/data/plan.fmf
+++ b/tests/discover/libraries/data/plan.fmf
@@ -13,13 +13,6 @@ execute:
     discover+:
         test: file
 
-/apache:
-    summary: "Apache test (library requires another library)"
-    discover+:
-        test: apache
-    provision:
-        how: virtual
-
 /strip_git_suffix:
     summary: "Check libraries can end in '.git' suffix"
     discover+:
@@ -76,10 +69,3 @@ execute:
     summary: "Many tests requiring same rpm-only library"
     discover+:
         test: querying
-
-/pruning:
-    summary: "Simple test for library pruning"
-    discover+:
-        test: pruning
-    provision:
-        how: virtual
diff --git a/tests/discover/libraries/data/pruning.fmf b/tests/discover/libraries/data/pruning.fmf
deleted file mode 100644
index ab9e910dd7..0000000000
--- a/tests/discover/libraries/data/pruning.fmf
+++ /dev/null
@@ -1,9 +0,0 @@
-summary: A simple test for libraries pruning
-description:
-    Checks that pruning is executed on libraries
-test: ./pruning.sh
-path: /
-require:
-  - url: https://github.com/beakerlib/database
-    name: /mariadb
-    type: library
diff --git a/tests/discover/libraries/main.fmf b/tests/discover/libraries/main.fmf
index 91633c2931..42b1552bd7 100644
--- a/tests/discover/libraries/main.fmf
+++ b/tests/discover/libraries/main.fmf
@@ -8,13 +8,5 @@ description:
 tier: 3
 duration: 25m
 tag-: [virtual, container]
-enabled: False
 require+:
   - tmt+provision-container
-  - tmt+provision-virtual
-
-adjust+:
-  - enabled: True
-    when: how == full
-    because: this can be run only with a full virtualization
-    tag+: [additional_coverage]
diff --git a/tests/discover/libraries/test.sh b/tests/discover/libraries/test.sh
index 36cb2c19e5..f0edd1b528 100755
--- a/tests/discover/libraries/test.sh
+++ b/tests/discover/libraries/test.sh
@@ -15,12 +15,6 @@ rlJournalStart
         rlAssertGrep "Fetch library 'openssl/certgen'" $rlRun_LOG
     rlPhaseEnd
 
-    rlPhaseStartTest "Apache"
-        rlRun -s "$tmt apache"
-        rlAssertGrep "Fetch library 'httpd/http'" $rlRun_LOG
-        rlAssertGrep "Fetch library 'openssl/certgen'" $rlRun_LOG
-    rlPhaseEnd
-
     rlPhaseStartTest "Recommend"
         rlRun -s "$tmt recommend" 0
         rlAssertGrep "Fetch library 'openssl/certgen'" $rlRun_LOG
@@ -76,13 +70,6 @@ rlJournalStart
         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"
 
-    rlPhaseStartTest "Pruning"
-        rlRun -s "tmt run -vv --debug plan --name pruning"
-        lib_path=$(grep 'Library database/mariadb is copied into' "$rlRun_LOG"|rev|cut -d' ' -f1|rev)
-        rlAssertNotExists "${lib_path}/postgresql"
-        rlAssertNotExists "${lib_path}/mysql"
-    rlPhaseEnd
-
     rlPhaseStartCleanup
         rlRun "popd"
         rlRun "rm -r $tmp" 0 "Removing tmp directory"
diff --git a/tests/libraries/apache/data/.fmf/version b/tests/libraries/apache/data/.fmf/version
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/tests/libraries/apache/data/.fmf/version
@@ -0,0 +1,1 @@
+1
diff --git a/tests/libraries/apache/data/main.fmf b/tests/libraries/apache/data/main.fmf
new file mode 100644
index 0000000000..c1b54eacac
--- /dev/null
+++ b/tests/libraries/apache/data/main.fmf
@@ -0,0 +1,12 @@
+/plan:
+    discover:
+        how: fmf
+    provision:
+        how: virtual
+    execute:
+        how: tmt
+
+/test:
+    test: ./test.sh
+    require:
+      - library(httpd/http)
diff --git a/tests/discover/libraries/data/apache.sh b/tests/libraries/apache/data/test.sh
similarity index 100%
rename from tests/discover/libraries/data/apache.sh
rename to tests/libraries/apache/data/test.sh
diff --git a/tests/discover/libraries/data/apache.fmf b/tests/libraries/apache/main.fmf
similarity index 66%
rename from tests/discover/libraries/data/apache.fmf
rename to tests/libraries/apache/main.fmf
index 6a18067910..8af3bd6592 100644
--- a/tests/discover/libraries/data/apache.fmf
+++ b/tests/libraries/apache/main.fmf
@@ -1,7 +1,6 @@
 summary: A simple test for the Apache web server
 description:
     Requires a library which requires another library.
-test: ./apache.sh
-require:
-  - wget
-  - library(httpd/http)
+tag+:
+  - provision-virtual
+  - provision-only
diff --git a/tests/libraries/apache/test.sh b/tests/libraries/apache/test.sh
new file mode 100755
index 0000000000..14b5d0a53d
--- /dev/null
+++ b/tests/libraries/apache/test.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+rlJournalStart
+    rlPhaseStartSetup
+        rlRun "run=\$(mktemp -d)" 0 "Create run directory"
+        rlRun "pushd data"
+    rlPhaseEnd
+
+    rlPhaseStartTest
+        rlRun -s "tmt run -vvv -d --id $run"
+        rlAssertGrep "Fetch library 'httpd/http'" "$run/log.txt"
+        rlAssertGrep "Fetch library 'openssl/certgen'" "$run/log.txt"
+    rlPhaseEnd
+
+    rlPhaseStartCleanup
+        rlRun "popd"
+        rlRun "rm -r $run" 0 "Remove run directory"
+    rlPhaseEnd
+rlJournalEnd
diff --git a/tests/libraries/pruning/data/.fmf/version b/tests/libraries/pruning/data/.fmf/version
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/tests/libraries/pruning/data/.fmf/version
@@ -0,0 +1,1 @@
+1
diff --git a/tests/libraries/pruning/data/main.fmf b/tests/libraries/pruning/data/main.fmf
new file mode 100644
index 0000000000..a506f5a218
--- /dev/null
+++ b/tests/libraries/pruning/data/main.fmf
@@ -0,0 +1,15 @@
+/plan:
+    discover:
+        how: fmf
+    provision:
+        how: virtual
+    execute:
+        how: tmt
+
+/test:
+    test: ./test.sh
+    framework: beakerlib
+    require:
+      - url: https://github.com/beakerlib/database
+        name: /mariadb
+        type: library
diff --git a/tests/discover/libraries/data/pruning.sh b/tests/libraries/pruning/data/test.sh
similarity index 79%
rename from tests/discover/libraries/data/pruning.sh
rename to tests/libraries/pruning/data/test.sh
index ae0a4179fd..218059f88f 100755
--- a/tests/discover/libraries/data/pruning.sh
+++ b/tests/libraries/pruning/data/test.sh
@@ -1,5 +1,4 @@
 #!/bin/bash
-# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
 . /usr/share/beakerlib/beakerlib.sh || exit 1
 
 rlJournalStart
diff --git a/tests/libraries/pruning/main.fmf b/tests/libraries/pruning/main.fmf
new file mode 100644
index 0000000000..292f329f70
--- /dev/null
+++ b/tests/libraries/pruning/main.fmf
@@ -0,0 +1,6 @@
+summary: Check that pruning is executed on libraries
+description:
+    Verify that only libraries which are used are copied.
+tag+:
+  - provision-virtual
+  - provision-only
diff --git a/tests/libraries/pruning/test.sh b/tests/libraries/pruning/test.sh
new file mode 100755
index 0000000000..9ff1b740c0
--- /dev/null
+++ b/tests/libraries/pruning/test.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+rlJournalStart
+    rlPhaseStartSetup
+        rlRun "run=\$(mktemp -d)" 0 "Create run directory"
+        rlRun "pushd data"
+        rlRun "set -o pipefail"
+    rlPhaseEnd
+
+    rlPhaseStartTest "Pruning"
+        rlRun -s "tmt run --id $run -vvv --debug --until report"
+        lib_path=$(grep 'Library database/mariadb is copied into' "$rlRun_LOG"|rev|cut -d' ' -f1|rev)
+        rlAssertExists "${lib_path}/mariadb"
+        rlAssertNotExists "${lib_path}/postgresql"
+        rlAssertNotExists "${lib_path}/mysql"
+        rlRun "tmt run --id $run finish"
+    rlPhaseEnd
+
+    rlPhaseStartCleanup
+        rlRun "popd"
+        rlRun "rm -r $run" 0 "Remove run directory"
+    rlPhaseEnd
+rlJournalEnd