From 2be83dcaa8819da948b99de14a001bb1ae3ba7d5 Mon Sep 17 00:00:00 2001
From: Martin Hoyer <mhoyer@redhat.com>
Date: Mon, 12 Jun 2023 16:17:20 +0200
Subject: [PATCH] Move to tmt test framework

---
 .fmf/version                                  |  1 +
 plans/sanity.fmf                              |  5 +++
 plans/sts.fmf                                 | 21 +++++++++++
 .../iscsi-target-initiator-restraint/main.fmf | 13 +++++++
 .../runtest.sh                                |  1 -
 tests/tests.yml                               | 37 -------------------
 6 files changed, 40 insertions(+), 38 deletions(-)
 create mode 100644 .fmf/version
 create mode 100644 plans/sanity.fmf
 create mode 100644 plans/sts.fmf
 create mode 100644 tests/iscsi-target-initiator-restraint/main.fmf
 delete mode 100644 tests/tests.yml

diff --git a/.fmf/version b/.fmf/version
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/.fmf/version
@@ -0,0 +1 @@
+1
diff --git a/plans/sanity.fmf b/plans/sanity.fmf
new file mode 100644
index 0000000..3c6a820
--- /dev/null
+++ b/plans/sanity.fmf
@@ -0,0 +1,5 @@
+summary: Run relevant tests from the tests directory
+discover:
+  how: fmf
+execute:
+  how: tmt
diff --git a/plans/sts.fmf b/plans/sts.fmf
new file mode 100644
index 0000000..685ef9b
--- /dev/null
+++ b/plans/sts.fmf
@@ -0,0 +1,21 @@
+summary: Tier 0 iSCSI initiator tests
+discover:
+  how: fmf
+  url: https://gitlab.com/rh-kernel-stqe/sts
+  ref: fedora
+  filter:
+    - tier:0
+    - tag:iscsi
+    - tag:local
+context:
+  component: iscsi-initiator-utils
+execute:
+  how: tmt
+environment:
+  STS_VENV_PATH: /opt/sts-venv
+prepare:
+  - name: install-sts-libs
+    how: shell
+    script: >
+        curl --retry 3 --retry-delay 5 --connect-timeout 10 --max-time 30 -s
+        https://gitlab.com/rh-kernel-stqe/sts/-/raw/fedora/scripts/install-sts-libs.sh | bash
diff --git a/tests/iscsi-target-initiator-restraint/main.fmf b/tests/iscsi-target-initiator-restraint/main.fmf
new file mode 100644
index 0000000..aefdac9
--- /dev/null
+++ b/tests/iscsi-target-initiator-restraint/main.fmf
@@ -0,0 +1,13 @@
+summary: Creates iSCSI target/initiator, and logs it in locally
+description: ''
+contact: Andy Walsh <awalsh@redhat.com>
+component:
+  - iscsi-initiator-utils 
+test: ./runtest.sh
+framework: beakerlib
+recommend:
+  - test_beakertask
+duration: 5m
+extra-summary: /beaker_nvr_test
+extra-task: /beaker_nvr_test
+tier: 0
diff --git a/tests/iscsi-target-initiator-restraint/runtest.sh b/tests/iscsi-target-initiator-restraint/runtest.sh
index 6087421..2db03c4 100755
--- a/tests/iscsi-target-initiator-restraint/runtest.sh
+++ b/tests/iscsi-target-initiator-restraint/runtest.sh
@@ -26,7 +26,6 @@
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 # Include Beaker environment
-. /usr/bin/rhts-environment.sh || exit 1
 . /usr/share/beakerlib/beakerlib.sh || exit 1
 
 # Set up a target IQN to use through the test.
diff --git a/tests/tests.yml b/tests/tests.yml
deleted file mode 100644
index 9c6bdce..0000000
--- a/tests/tests.yml
+++ /dev/null
@@ -1,37 +0,0 @@
----
-# Tests suitable to run in classic environment
-- hosts: localhost
-  roles:
-  - role: standard-test-beakerlib
-    tags:
-    - classic
-    tests:
-    - iscsi-target-initiator-restraint
-    required_packages:
-    - targetcli
-
-- hosts: localhost
-  roles:
-  - role: standard-test-basic
-    # python-stqe cannot be installed on 'atomic', no need to run on 'container'
-    tags:
-    - classic
-    repositories:
-    - repo: "https://gitlab.com/rh-kernel-stqe/python-stqe.git"
-      dest: "python-stqe"
-      version: 535ecebf5611e158079d806b6232e3d2c68f0d93
-    tests:
-    # Install python-stqe first
-    # make sure we use same version of libsan
-    - install_stqe:
-        dir: python-stqe
-        run: pip3 install libsan==0.3.0 && python3 setup.py install --prefix=
-    - iscsi-initiator-utils:
-        dir: ./
-        run: stqe-test run -t iscsi/iscsi_params.py
-    required_packages:
-    # required for python-stqe
-    - python3-pyyaml
-    - python3-netifaces
-    - python3-augeas
-    - python3-pip