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

Add CentOS 10, Debian 11 and openSUSE 15 tests #162

Merged
merged 13 commits into from
Jul 16, 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
5 changes: 4 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ jobs:
containers:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
fail-fast: false
matrix:
dockerfile:
- images/Dockerfile.debian11
- images/Dockerfile.el10
- images/Dockerfile.el9
- images/Dockerfile.el8
- images/Dockerfile.el7
- images/Dockerfile.f34
- images/Dockerfile.f33
- images/Dockerfile.suseLeap42
- images/Dockerfile.suseLeap15
steps:
- uses: actions/checkout@v2
- name: ${{ matrix.dockerfile }}
Expand Down
8 changes: 8 additions & 0 deletions images/Dockerfile.debian11
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM debian:11

RUN apt-get update && apt-get install --yes --no-install-recommends curl make python3 python3-pip python3-setuptools && apt-get clean
RUN curl -o /etc/apt/trusted.gpg.d/atix.asc https://oss.atix.de/atix_gpg.pub
RUN echo 'deb https://oss.atix.de/Debian11/ stable main' >> /etc/apt/sources.list
RUN apt-get update && apt-get install --yes --no-install-recommends python3-subscription-manager && apt-get clean

WORKDIR /app
4 changes: 4 additions & 0 deletions images/Dockerfile.el10
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM quay.io/centos/centos:stream10-development

RUN dnf install make python3 python3-pip python3-setuptools python3-dnf-plugins-core subscription-manager -y && dnf clean all
WORKDIR /app
2 changes: 1 addition & 1 deletion images/Dockerfile.el7
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ FROM quay.io/centos/centos:7

RUN sed -i -e 's/^mirrorlist/#mirrorlist/g; /^#baseurl/ s/^#//; /baseurl/ s/mirror/vault/g' /etc/yum.repos.d/CentOS-Base.repo
RUN yum install -y epel-release https://yum.theforeman.org/client/nightly/el7/x86_64/foreman-client-release.rpm && yum clean all
RUN yum install make python-setuptools python-tracer subscription-manager python-pip python2-mock python-unittest2 -y && yum clean all
RUN yum install make python-setuptools python-tracer subscription-manager python-pip python2-mock -y && yum clean all
WORKDIR /app
8 changes: 8 additions & 0 deletions images/Dockerfile.suseLeap15
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM opensuse/leap:15

RUN zypper addrepo -c --no-gpgcheck https://oss.atix.de/SLES15SP5/ subscription-manager
RUN zypper removerepo 'OSS Update'
RUN zypper clean --all
RUN zypper install -y make python3-pip subscription-manager python3-zypp-plugin which python3-setuptools lsof

WORKDIR /app
2 changes: 1 addition & 1 deletion images/Dockerfile.suseLeap42
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM opensuse/leap:42

RUN zypper addrepo -c --no-gpgcheck http://download.opensuse.org/repositories/home:/kahowell/openSUSE_Leap_42.2/ subscription-manager
RUN zypper addrepo -c --no-gpgcheck https://oss.atix.de/SLES12SP5/ subscription-manager
RUN zypper removerepo 'OSS Update'
RUN zypper clean --all
RUN zypper install -y make python-pip subscription-manager zypp-plugin-python which python-setuptools lsof
Expand Down
6 changes: 2 additions & 4 deletions src/katello/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import imp

ENABLED_REPOS_CACHE_FILE = '/var/cache/katello-agent/enabled_repos.json'
PACKAGE_CACHE_FILE = '/var/lib/rhsm/packages/packages.json'
REPOSITORY_PATH = '/etc/yum.repos.d/redhat.repo'
Expand All @@ -13,13 +11,13 @@
PROFILE_CACHE_FILE = '/var/lib/rhsm/cache/profile.json'

try:
imp.find_module('zypp_plugin')
import zypp_plugin
ZYPPER = True
except ImportError:
ZYPPER = False

try:
imp.find_module('yum')
import yum
YUM = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you change it to this, then this part becomes redundant:

if YUM:
import yum

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how so? it would then need to from katello.constants import yum instead…

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, Ruby has created some brain damage where I assumed it was present in a global namespace.

except ImportError:
YUM = False
9 changes: 4 additions & 5 deletions src/katello/tracer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
from __future__ import absolute_import
from katello.uep import get_uep, lookup_consumer_id
import sys
import imp

def collect_apps():
raise NotImplementedError("Couldn't detect package manager. Failed to query affected apps!")

# RHEL based systems
try:
imp.find_module('dnf')
import dnf
from katello.tracer.dnf import collect_apps
except ImportError:
try:
imp.find_module('yum')
import yum
from tracer.query import Query
def collect_apps():
query = Query()
Expand All @@ -22,14 +21,14 @@ def collect_apps():

# debian based systems
try:
imp.find_module('apt')
import apt
from katello.tracer.deb import collect_apps
except ImportError:
pass

# SUSE based systems
try:
imp.find_module('zypp_plugin')
import zypp_plugin
from katello.tracer.zypper import collect_apps
except ImportError:
pass
Expand Down
6 changes: 5 additions & 1 deletion src/katello/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from os import environ

if sys.version_info[0] == 3:
from configparser import ConfigParser
from configparser import ConfigParser as BaseConfigParser
class ConfigParser(BaseConfigParser):
def __init__(self, *args, **kwargs):
kwargs['interpolation'] = None
super(ConfigParser, self).__init__(*args, **kwargs)
else:
from ConfigParser import ConfigParser

Expand Down
1 change: 0 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
flake8; python_version >= '3.6'
mock<4.0.0; python_version >= '2.7'
unittest2
13 changes: 10 additions & 3 deletions test/dnf-plugins/test_tracer_upload.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import os
import sys
from dnf_support import PluginTestCase, configure_command
import unittest2 as unittest
import unittest

orig_path = list(sys.path)
sys.path.append(os.path.join(os.path.dirname(__file__), '../../src/'))
sys.path.append(os.path.join(os.path.dirname(__file__), '../../src/dnf-plugins'))
import tracer_upload
try:
from dnf_support import PluginTestCase, configure_command
import tracer_upload
except ImportError:
class PluginTestCase:
pass
sys.path = orig_path

from mock import Mock, patch

Expand Down Expand Up @@ -33,6 +39,7 @@ def test_plugin_disabled(self, upload_tracer):
assert not upload_tracer.called


@unittest.skipIf('dnf' not in sys.modules, "DNF not present")
class TestTracerUploadCommand(unittest.TestCase):
def setUp(self):
self.cli = Mock()
Expand Down
2 changes: 1 addition & 1 deletion test/dnf_support.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from configparser import ConfigParser
from unittest2 import TestCase
from unittest import TestCase

import dnf.cli.option_parser

Expand Down
2 changes: 1 addition & 1 deletion test/test_katello/test_enabled_report.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import sys
import unittest2 as unittest
import unittest
from mock import patch
sys.path.append(os.path.join(os.path.dirname(__file__), '../../src/'))
from katello import enabled_report
Expand Down
2 changes: 1 addition & 1 deletion test/test_katello/test_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import sys

from unittest2 import TestCase
from unittest import TestCase

sys.path.append(os.path.join(os.path.dirname(__file__), '../../src/'))
from katello import repos
Expand Down
22 changes: 1 addition & 21 deletions test/test_katello/test_tracer/test_tracer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import sys
import unittest2 as unittest
import unittest

sys.path.append(os.path.join(os.path.dirname(__file__), '../../src/'))
from katello.tracer import upload_tracer_profile, query_affected_apps
Expand Down Expand Up @@ -32,29 +32,9 @@ def test_tracer_upload_unregistered(self, mock_lookup, mock_uep):

class TestQueryAffectedApps(unittest.TestCase):
@unittest.skipIf(YUM == False, "Yum not present")
@patch('katello.tracer.yum', True)
@patch('katello.tracer.dnf', False)
def test_el_os(self):
self.assertEqual(query_affected_apps(), [])

@unittest.skipIf(YUM == False, "YUM not present")
@patch('katello.tracer.yum', False)
@patch('katello.tracer.dnf', False)
@patch('katello.tracer.zypp', True)
def test_failing_zypper_os(self):
self.assertRaises(Exception, query_affected_apps)

@unittest.skipIf(ZYPPER == False, "ZYPPER not present")
@patch('katello.tracer.yum', False)
@patch('katello.tracer.dnf', False)
@patch('katello.tracer.zypp', True)
def test_zypper_os(self):
self.assertEqual(query_affected_apps(), [])

@unittest.skipIf(ZYPPER == False, "ZYPPER not present")
@patch('katello.tracer.yum', True)
@patch('katello.tracer.dnf', False)
@patch('katello.tracer.zypp', False)
def test_failing_yum_os(self):
self.assertRaises(Exception, query_affected_apps)

4 changes: 3 additions & 1 deletion test/test_yum_plugins/test_enabled_repos_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
from rhsm.connection import RemoteServerException

from mock import patch, Mock
import unittest2 as unittest
import unittest

orig_path = list(sys.path)
try:
sys.path.append(os.path.join(os.path.dirname(__file__), '../../src/'))
sys.path.append(os.path.join(os.path.dirname(__file__), '../../src/yum-plugins'))
import enabled_repos_upload
except ImportError:
print("Yum wasn't present")
sys.path = orig_path


FAKE_REPORT = {'foobar': 1}
Expand Down
2 changes: 1 addition & 1 deletion test/unittest_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys

import unittest2 as unittest
import unittest


if sys.version_info[0] == 2:
Expand Down
9 changes: 5 additions & 4 deletions test/zypper_plugins/test_enabled_repos_upload.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import os
import sys

from unittest2 import TestCase
import unittest2 as unittest
import unittest
from mock import Mock, patch

orig_path = list(sys.path)
try:
sys.path.append(os.path.join(os.path.dirname(__file__), '../../src/'))
sys.path.append(os.path.join(os.path.dirname(__file__), '../../src/zypper_plugins'))
import enabled_repos_upload
except:
pass
pass
sys.path = orig_path

class TestEnabledReposUpload(TestCase):
class TestEnabledReposUpload(unittest.TestCase):
def setUp(self):
self.plugin = enabled_repos_upload.EnabledReposUpload()

Expand Down
5 changes: 2 additions & 3 deletions test/zypper_plugins/test_package_upload.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import os
import sys

from unittest2 import TestCase
import unittest2 as unittest
import unittest
from mock import Mock, patch

try:
Expand All @@ -12,7 +11,7 @@
except:
pass

class TestPackageUpload(TestCase):
class TestPackageUpload(unittest.TestCase):
def setUp(self):
self.plugin = package_upload.KatelloZyppPlugin()

Expand Down
7 changes: 4 additions & 3 deletions test/zypper_plugins/test_tracer_upload.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import os
import sys

from unittest2 import TestCase
import unittest2 as unittest
import unittest
from mock import Mock, patch

orig_path = list(sys.path)
try:
sys.path.append(os.path.join(os.path.dirname(__file__), '../../src/'))
sys.path.append(os.path.join(os.path.dirname(__file__), '../../src/zypper_plugins'))
import tracer_upload
except:
pass
sys.path = orig_path

class TestTracerUpload(TestCase):
class TestTracerUpload(unittest.TestCase):
def setUp(self):
self.plugin = tracer_upload.TracerUploadPlugin()

Expand Down
Loading