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

[BUG] test_pkgrepo not run on Debian #61641

Open
bdrung opened this issue Feb 14, 2022 · 0 comments
Open

[BUG] test_pkgrepo not run on Debian #61641

bdrung opened this issue Feb 14, 2022 · 0 comments
Labels
Bug broken, incorrect, or confusing behavior severity-high 2nd top severity, seen by most users, causes major problems Tests
Milestone

Comments

@bdrung
Copy link
Contributor

bdrung commented Feb 14, 2022

Description

The tests in tests/pytests/functional/states/test_pkgrepo.py should be run on Debian based systems:

@pytest.mark.skipif(
    not any([x for x in ["ubuntu", "debian"] if x in platform.platform()]),
    reason="Test only for debian based platforms",
)

But on Ubuntu 21.10, platform.platform() does not return the distribution name:

$ python3 -c "import platform; print(platform.platform())"
Linux-5.13.0-28-generic-x86_64-with-glibc2.34

Note 1

Once #61626 is reviewed and merged, following code could be used to run the test cases on all Debian based systems (not only on Debian and Ubuntu):

from salt.grains.core import freedesktop_os_release, _family_id

def is_debian_based():
    os_release = freedesktop_os_release()
    return _family_id(os_release["ID"], os_release.get["ID_LIKE"]) == "debian"

@pytest.mark.skipif(
    not is_debian_based(),
    reason="Test only for debian based platforms",
)

Note 2

If I remove the skipif, these test cases fail to run during Debian package build, because they want to write to /etc/apt/sources.list:

____________________________ test_adding_repo_file _____________________________

states = <LazyLoader module='salt.loaded.states'>
tmp_path = PosixPath('/tmp/pytest-of-bdrung/pytest-0/test_adding_repo_file0')

    def test_adding_repo_file(states, tmp_path):
        """
        test adding a repo file using pkgrepo.managed
        """
        repo_file = str(tmp_path / "stable-binary.list")
        repo_content = "deb http://www.deb-multimedia.org stable main"
        ret = states.pkgrepo.managed(name=repo_content, file=repo_file, clean_file=True)
        with salt.utils.files.fopen(repo_file, "r") as fp:
            file_content = fp.read()
>       assert file_content.strip() == repo_content
E       AssertionError: assert '' == 'deb http://w...g stable main'
E         - deb http://www.deb-multimedia.org stable main

tests/pytests/functional/states/test_pkgrepo.py:16: AssertionError
------------------------------ Captured log setup ------------------------------
ERROR    salt.utils.event:event.py:426 Unable to connect pusher: Stream is closed
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/salt/utils/event.py", line 423, in connect_pull
    self.pusher.connect(timeout=timeout)
  File "/<<PKGBUILDDIR>>/salt/utils/asynchronous.py", line 125, in wrap
    raise exc_info[1].with_traceback(exc_info[2])
  File "/<<PKGBUILDDIR>>/salt/utils/asynchronous.py", line 131, in _target
    result = io_loop.run_sync(lambda: getattr(self.obj, key)(*args, **kwargs))
  File "/<<PKGBUILDDIR>>/salt/ext/tornado/ioloop.py", line 459, in run_sync
    return future_cell[0].result()
  File "/<<PKGBUILDDIR>>/salt/ext/tornado/concurrent.py", line 249, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 4, in raise_exc_info
  File "/<<PKGBUILDDIR>>/salt/transport/ipc.py", line 342, in _connect
    yield self.stream.connect(sock_addr)
  File "/<<PKGBUILDDIR>>/salt/ext/tornado/gen.py", line 1056, in run
    value = future.result()
  File "/<<PKGBUILDDIR>>/salt/ext/tornado/concurrent.py", line 249, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 4, in raise_exc_info
salt.ext.tornado.iostream.StreamClosedError: Stream is closed
------------------------------ Captured log call -------------------------------
ERROR    salt.state:state.py:317 Failed to configure repo 'deb http://www.deb-multimedia.org stable main': [Errno 13] Permission denied: '/etc/apt/sources.list'

Versions Report

salt 3004, but the master branch is affected as well.

@bdrung bdrung added Bug broken, incorrect, or confusing behavior needs-triage labels Feb 14, 2022
@OrangeDog OrangeDog added severity-high 2nd top severity, seen by most users, causes major problems Tests and removed needs-triage labels Feb 16, 2022
@OrangeDog OrangeDog added this to the Approved milestone Feb 16, 2022
@s0undt3ch s0undt3ch removed their assignment Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior severity-high 2nd top severity, seen by most users, causes major problems Tests
Projects
None yet
Development

No branches or pull requests

3 participants