From b4dd1fabf0e0eea17bdb94618bb415f731aa117a Mon Sep 17 00:00:00 2001
From: Jana Cupova <root@localhost>
Date: Jan 29 2024 19:47:23 +0000
Subject: Remove rpm-py-installer, update test docs and update Dockerfiles


Remove rpm-py-installer from requirements
Check duplicite and unused packages in Dockerfiles and test-requirements
Update docs about unit tests.

Fixes: https://pagure.io/koji/issue/3868

---

diff --git a/devtools/containers/Dockerfile.centos7 b/devtools/containers/Dockerfile.centos7
index c81323a..b43a13d 100644
--- a/devtools/containers/Dockerfile.centos7
+++ b/devtools/containers/Dockerfile.centos7
@@ -5,29 +5,16 @@ RUN \
     dnf \
     dnf-plugins-core \
     gcc \
-    git \
-    make \
     krb5-devel \
     libffi-devel \
-    openssl-devel \
-    pyOpenSSL \
-    python-cheetah \
     python-devel \
     python-librepo \
     python-requests \
-    redhat-rpm-config \
-    rpm-build \
-    rpm-python \
-    yum-utils && \
+    rpm-build  && \
   yum install -y epel-release && \
   yum install -y \
-    python-flake8 \
-    python-multilib \
     python-pip \
-    python-psycopg2 \
-    python-qpid-proton \
-    python-requests-kerberos \
-    yumdownloader && \
+    python-psycopg2 && \
   yum clean all && \
   pip install -U 'pip==9.0.1' && \
   pip install -U tox
diff --git a/devtools/containers/Dockerfile.centos8 b/devtools/containers/Dockerfile.centos8
index aafdab3..8e8b16e 100644
--- a/devtools/containers/Dockerfile.centos8
+++ b/devtools/containers/Dockerfile.centos8
@@ -4,25 +4,11 @@ RUN \
   dnf -y update --nodocs --setopt=install_weak_deps=False && \
   dnf install -y --nodocs --setopt=install_weak_deps=False epel-release && \
   dnf install -y --nodocs --setopt=install_weak_deps=False \
-  'dnf-command(download)' \
   gcc \
-  git \
-  glib2-devel \
   glibc-langpack-en \
   krb5-devel \
-  libffi-devel \
-  libxml2-devel \
-  make \
-  openssl-devel \
   python3-devel \
   python3-librepo \
-  python3-pip \
-  python3-pytest \
-  python3-rpm \
   python3-tox \
-  redhat-rpm-config \
-  rpm-build \
-  rpm-devel \
-  sqlite-devel \
-  yum-utils && \
+  rpm-build && \
   dnf clean all
diff --git a/devtools/containers/Dockerfile.centos9 b/devtools/containers/Dockerfile.centos9
index 790fec6..380f476 100644
--- a/devtools/containers/Dockerfile.centos9
+++ b/devtools/containers/Dockerfile.centos9
@@ -4,25 +4,11 @@ RUN \
   dnf -y update --nodocs --setopt=install_weak_deps=False && \
   dnf install -y --nodocs --setopt=install_weak_deps=False epel-release && \
   dnf install -y --nodocs --setopt=install_weak_deps=False --enablerepo crb \
-  'dnf-command(download)' \
   gcc \
-  git \
-  glib2-devel \
   glibc-langpack-en \
   krb5-devel \
-  libffi-devel \
-  libxml2-devel \
-  make \
-  openssl-devel \
   python3-devel \
   python3-librepo \
-  python3-pip \
-  python3-pytest \
-  python3-rpm \
   python3-tox \
-  redhat-rpm-config \
-  rpm-build \
-  rpm-devel \
-  sqlite-devel \
-  yum-utils && \
+  rpm-build && \
   dnf clean all
diff --git a/devtools/containers/Dockerfile.f34 b/devtools/containers/Dockerfile.f34
index 93991bc..7559904 100644
--- a/devtools/containers/Dockerfile.f34
+++ b/devtools/containers/Dockerfile.f34
@@ -2,25 +2,11 @@ FROM registry.fedoraproject.org/fedora:34
 RUN \
   dnf -y update --nodocs --setopt=install_weak_deps=False && \
   dnf install -y --nodocs --setopt=install_weak_deps=False \
-  'dnf-command(download)' \
   gcc \
-  git \
-  glib2-devel \
   glibc-langpack-en \
   krb5-devel \
-  libffi-devel \
-  python3-librepo \
-  libxml2-devel \
-  make \
-  openssl-devel \
   python3-devel \
-  python3-pip \
-  python3-pytest \
-  python3-rpm \
+  python3-librepo \
   python3-tox \
-  redhat-rpm-config \
-  rpm-build \
-  rpm-devel \
-  sqlite-devel \
-  yum-utils && \
-  dnf clean all\
+  rpm-build && \
+  dnf clean all
diff --git a/devtools/containers/Dockerfile.f35 b/devtools/containers/Dockerfile.f35
index a7e7894..d6e5cd5 100644
--- a/devtools/containers/Dockerfile.f35
+++ b/devtools/containers/Dockerfile.f35
@@ -2,25 +2,11 @@ FROM registry.fedoraproject.org/fedora:35
 RUN \
   dnf -y update --nodocs --setopt=install_weak_deps=False && \
   dnf install -y --nodocs --setopt=install_weak_deps=False \
-  'dnf-command(download)' \
   gcc \
-  git \
-  glib2-devel \
   glibc-langpack-en \
   krb5-devel \
-  libffi-devel \
-  python3-librepo \
-  libxml2-devel \
-  make \
-  openssl-devel \
   python3-devel \
-  python3-pip \
-  python3-pytest \
-  python3-rpm \
+  python3-librepo \
   python3-tox \
-  redhat-rpm-config \
-  rpm-build \
-  rpm-devel \
-  sqlite-devel \
-  yum-utils && \
-  dnf clean all\
+  rpm-build && \
+  dnf clean all
diff --git a/devtools/containers/Dockerfile.f36 b/devtools/containers/Dockerfile.f36
index 434e729..2756812 100644
--- a/devtools/containers/Dockerfile.f36
+++ b/devtools/containers/Dockerfile.f36
@@ -2,25 +2,11 @@ FROM registry.fedoraproject.org/fedora:36
 RUN \
   dnf -y update --nodocs --setopt=install_weak_deps=False && \
   dnf install -y --nodocs --setopt=install_weak_deps=False \
-  'dnf-command(download)' \
   gcc \
-  git \
-  glib2-devel \
   glibc-langpack-en \
   krb5-devel \
-  libffi-devel \
-  python3-librepo \
-  libxml2-devel \
-  make \
-  openssl-devel \
   python3-devel \
-  python3-pip \
-  python3-pytest \
-  python3-rpm \
+  python3-librepo \
   python3-tox \
-  redhat-rpm-config \
-  rpm-build \
-  rpm-devel \
-  sqlite-devel \
-  yum-utils && \
-  dnf clean all\
+  rpm-build && \
+  dnf clean all
diff --git a/devtools/containers/Dockerfile.f37 b/devtools/containers/Dockerfile.f37
index de75eea..d7b4cab 100644
--- a/devtools/containers/Dockerfile.f37
+++ b/devtools/containers/Dockerfile.f37
@@ -2,25 +2,11 @@ FROM registry.fedoraproject.org/fedora:37
 RUN \
   dnf -y update --nodocs --setopt=install_weak_deps=False && \
   dnf install -y --nodocs --setopt=install_weak_deps=False \
-  'dnf-command(download)' \
   gcc \
-  git \
-  glib2-devel \
   glibc-langpack-en \
   krb5-devel \
-  libffi-devel \
-  python3-librepo \
-  libxml2-devel \
-  make \
-  openssl-devel \
   python3-devel \
-  python3-pip \
-  python3-pytest \
-  python3-rpm \
+  python3-librepo \
   python3-tox \
-  redhat-rpm-config \
-  rpm-build \
-  rpm-devel \
-  sqlite-devel \
-  yum-utils && \
-  dnf clean all\
+  rpm-build && \
+  dnf clean all
diff --git a/devtools/containers/Dockerfile.f38 b/devtools/containers/Dockerfile.f38
index 3253131..bc5e9dd 100644
--- a/devtools/containers/Dockerfile.f38
+++ b/devtools/containers/Dockerfile.f38
@@ -2,25 +2,11 @@ FROM registry.fedoraproject.org/fedora:38
 RUN \
   dnf -y update --nodocs --setopt=install_weak_deps=False && \
   dnf install -y --nodocs --setopt=install_weak_deps=False \
-  'dnf-command(download)' \
   gcc \
-  git \
-  glib2-devel \
   glibc-langpack-en \
   krb5-devel \
-  libffi-devel \
-  python3-librepo \
-  libxml2-devel \
-  make \
-  openssl-devel \
   python3-devel \
-  python3-pip \
-  python3-pytest \
-  python3-rpm \
+  python3-librepo \
   python3-tox \
-  redhat-rpm-config \
-  rpm-build \
-  rpm-devel \
-  sqlite-devel \
-  yum-utils && \
-  dnf clean all\
+  rpm-build && \
+  dnf clean all
diff --git a/devtools/containers/Dockerfile.f39 b/devtools/containers/Dockerfile.f39
index 0bb35ef..71fed27 100644
--- a/devtools/containers/Dockerfile.f39
+++ b/devtools/containers/Dockerfile.f39
@@ -2,25 +2,11 @@ FROM registry.fedoraproject.org/fedora:39
 RUN \
   dnf -y update --nodocs --setopt=install_weak_deps=False && \
   dnf install -y --nodocs --setopt=install_weak_deps=False \
-  'dnf-command(download)' \
   gcc \
-  git \
-  glib2-devel \
   glibc-langpack-en \
   krb5-devel \
-  libffi-devel \
-  python3-librepo \
-  libxml2-devel \
-  make \
-  openssl-devel \
   python3-devel \
-  python3-pip \
-  python3-pytest \
-  python3-rpm \
+  python3-librepo \
   python3-tox \
-  redhat-rpm-config \
-  rpm-build \
-  rpm-devel \
-  sqlite-devel \
-  yum-utils && \
-  dnf clean all\
+  rpm-build && \
+  dnf clean all
diff --git a/devtools/containers/Dockerfile.rawhide b/devtools/containers/Dockerfile.rawhide
index 7a1f153..cfaa511 100644
--- a/devtools/containers/Dockerfile.rawhide
+++ b/devtools/containers/Dockerfile.rawhide
@@ -2,25 +2,11 @@ FROM registry.fedoraproject.org/fedora:rawhide
 RUN \
   dnf -y update --nodocs --setopt=install_weak_deps=False && \
   dnf install -y --nodocs --setopt=install_weak_deps=False \
-  'dnf-command(download)' \
   gcc \
-  git \
-  glib2-devel \
   glibc-langpack-en \
   krb5-devel \
-  libffi-devel \
-  python3-librepo \
-  libxml2-devel \
-  make \
-  openssl-devel \
   python3-devel \
-  python3-pip \
-  python3-pytest \
-  python3-rpm \
+  python3-librepo \
   python3-tox \
-  redhat-rpm-config \
-  rpm-build \
-  rpm-devel \
-  sqlite-devel \
-  yum-utils && \
+  rpm-build && \
   dnf clean all
diff --git a/devtools/containers/README.md b/devtools/containers/README.md
index 2982851..dabb0d0 100644
--- a/devtools/containers/README.md
+++ b/devtools/containers/README.md
@@ -6,21 +6,31 @@ provided:
 
 * [`./Dockerfile.centos7`](./Dockerfile.centos7) CentOS 7, for testing with python2.7
 * [`./Dockerfile.centos8`](./Dockerfile.centos8) CentOS 8, for testing with python3.6
-* [`./Dockerfile.f32`](./Dockerfile.f32) Fedora 32, for testing with python3.8
-* [`./Dockerfile.f33`](./Dockerfile.f33) Fedora 33, for testing with python3.9
+* [`./Dockerfile.centos9`](./Dockerfile.centos8) CentOS 9, for testing with python3.9
+* [`./Dockerfile.f34`](...) Fedora 34, for testing with python3.9
+* [`./Dockerfile.f35`](./Dockerfile.f32) Fedora 35, for testing with python3.10
+* [`./Dockerfile.f36`](./Dockerfile.f32) Fedora 36, for testing with python3.10
+* [`./Dockerfile.f37`](./Dockerfile.f32) Fedora 37, for testing with python3.11
+* [`./Dockerfile.f38`](./Dockerfile.f32) Fedora 38, for testing with python3.11
+* [`./Dockerfile.f39`](./Dockerfile.f32) Fedora 39, for testing with python3.12
 * [`./Dockerfile.rawhide`](./Dockerfile.rawhie) Fedora Rawhide, for testing with python3.?
 
 To use them, taking fedora as an example:
 
-    docker build -t koji_test_fedora:32 --no-cache -f Dockerfile.f32
-    docker run --rm -v $PWD:/koji --name koji_test koji_test_fedora:32 bash -c "cd /koji && tox -e flake8,py3"
+    docker build -t koji_test_fedora:39 --no-cache -f Dockerfile.f39
+    docker run --rm -v $PWD:/koji --name koji_test koji_test_fedora:39 bash -c "cd /koji && tox -e flake8,py3,bandit"
 
-Or CentOS as an example:
+Or CentOS with py3 as an example:
 
     docker build -t koji_test_centos:8 --no-cache -f Dockerfile.centos8
-    docker run --rm -v $PWD:/koji --name koji_test koji_test_centos:8 bash -c "cd /koji && tox -e py2"
+    docker run --rm -v $PWD:/koji --name koji_test koji_test_centos:8 bash -c "cd /koji && tox -e flake8,py3,bandit"
+
+Or CentOS with py2 as an example:
+
+    docker build -t koji_test_centos:7 --no-cache -f Dockerfile.centos8
+    docker run --rm -v $PWD:/koji --name koji_test koji_test_centos:7 bash -c "cd /koji && tox -e py2"
 
 When running with Podman and SELinux enabled, use the "--security-opt
 label=disable" option:
 
-    podman run --rm -v $PWD:/koji --security-opt label=disable --name koji_test koji_test_fedora:32 bash -c "cd /koji && ls -l /koji && tox -e flake8,py3"
+    podman run --rm -v $PWD:/koji --security-opt label=disable --name koji_test koji_test_fedora:39 bash -c "cd /koji && ls -l /koji && tox -e flake8,py3,bandit"
diff --git a/docs/source/writing_koji_code.rst b/docs/source/writing_koji_code.rst
index d668a74..6fd0d09 100644
--- a/docs/source/writing_koji_code.rst
+++ b/docs/source/writing_koji_code.rst
@@ -706,21 +706,47 @@ Unit Tests
 Koji comes with a small test suite, that you should always run when making
 changes to the code. To do so, just run ``make test`` in your terminal.
 
-You will need to install the following packages to actually run the tests.
+You can run the tests from your local and you will need to install the following packages to actually run the tests.
 
+For py3 instances:
+ * ``gcc``
  * ``glibc-langpack-en``
- * ``make``
- * ``python3-cheetah``
- * ``python3-coverage``
- * ``python3-dateutil``
- * ``python3-mock``
- * ``python3-multilib``
- * ``python3-pytest``
- * ``python3-psycopg2``
- * ``python3-qpid-proton``
- * ``python3-requests``
- * ``python3-requests-kerberos``
- * ``python3-requests-mock``
+ * ``krb5-devel``
+ * ``python3-devel``
+ * ``python3-librepo``
+ * ``python3-tox``
+ * ``rpm-build``
+ * ``Other packages are installed by test-requirements.txt.``
+
+For py2 instances:
+ * ``dnf``
+ * ``dnf-plugins-core``
+ * ``gcc``
+ * ``krb5-devel``
+ * ``libffi-devel``
+ * ``python-devel``
+ * ``python-librepo``
+ * ``python-requests``
+ * ``rpm-build``
+ * ``epel-release``
+ * ``python-pip``
+ * ``python-psycopg2``
+ * ``tox``
+ * ``pip==9.0.1``
+ * ``Other packages are installed by test-requirements-py2.txt.``
+
+You can use containers for the tests. Dockerfiles are placed in `devtools/containers` directory.
+Supported Dockerfiles:
+ * ``Dockerfile.centos7``
+ * ``Dockerfile.centos8``
+ * ``Dockerfile.centos9``
+ * ``Dockerfile.f34``
+ * ``Dockerfile.f35``
+ * ``Dockerfile.f36``
+ * ``Dockerfile.f37``
+ * ``Dockerfile.f38``
+ * ``Dockerfile.f39``
+ * ``Dockerfile.rawhide``
 
 Please note that it is currently not supported to use *virtualenv* when hacking
 on Koji.
diff --git a/requirements.txt b/requirements.txt
index af34dc6..3d8b263 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,4 +5,3 @@ psycopg2-binary;python_version >= '3.0'
 python-multilib
 python-qpid-proton<0.38.0;python_version < '3.0'
 python-qpid-proton;python_version >= '3.0'
-rpm-py-installer
diff --git a/setup.py b/setup.py
index 80790ef..cb7db87 100755
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,6 @@ def get_install_requires():
         'requests-gssapi',
         'six',
         # 'libcomps',
-        # 'rpm-py-installer', # it is optional feature
         # 'rpm',
     ]
     return requires
diff --git a/test-requirements-py2.txt b/test-requirements-py2.txt
index 4a90729..d10c071 100644
--- a/test-requirements-py2.txt
+++ b/test-requirements-py2.txt
@@ -5,3 +5,6 @@ mock<=2.0.0
 requests-mock<1.11.0
 coverage
 pytest
+Cheetah
+python-multilib
+python-qpid-proton<0.38.0
\ No newline at end of file
diff --git a/test-requirements.txt b/test-requirements.txt
index 71780e9..af32d0a 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -5,3 +5,7 @@ mock<=2.0.0
 requests-mock
 coverage
 pytest
+Cheetah3
+psycopg2-binary
+python-multilib
+python-qpid-proton
diff --git a/tox.ini b/tox.ini
index 34b990c..d4776b7 100644
--- a/tox.ini
+++ b/tox.ini
@@ -21,11 +21,9 @@ deps =
     -r{toxinidir}/requirements.txt
 # We need to access python-rpm, at least, and potentially more on EL6
 sitepackages = true
-# Tell the rpm-py-installer package to download binaries instead of building
-# from source
 setenv =
-    RPM_PY_INSTALL_BIN=true
     COLUMNS=80
+# Expected that python-rpm is installed on the host
 # If rpm's python bindings are missing, don't continue
 # Also, because coverage might be installed system-wide and it serves as our
 # entry point, let's make sure it's installed in the virtualenv.

