Skip to content

Conversation

@keszybz
Copy link
Member

@keszybz keszybz commented Dec 15, 2016

@weberhofer, please check if this fixes your issue.

@weberhofer
Copy link
Contributor

Thank you, @keszybz for that quick response. These are the new results:

[   16s] ============================= test session starts ==============================
[   16s] platform linux2 -- Python 2.7.12, pytest-3.0.2, py-1.4.31, pluggy-0.3.1 -- /usr/bin/python
[   16s] cachedir: ../../.cache
[   16s] rootdir: /home/abuild/rpmbuild/BUILD/python-systemd-233, inifile: pytest.ini
[   16s] collecting ... collected 25 items / 2 errors

==================================== ERRORS ====================================
___ ERROR collecting build/lib.linux-x86_64-2.7/systemd/test/test_journal.py ___
/usr/lib/python2.7/site-packages/py/_path/local.py:650: in pyimport
    __import__(modname)
E     File "/home/abuild/rpmbuild/BUILD/python-systemd-233/build/lib.linux-x86_64-2.7/systemd/test/test_journal.py", line 212
E       print('printed message...', file=stream)
E                                       ^
E   SyntaxError: invalid syntax
___ ERROR collecting build/lib.linux-x86_64-2.7/systemd/test/test_journal.py ___
/usr/lib/python2.7/site-packages/_pytest/python.py:411: in _importtestmodule
    mod = self.fspath.pyimport(ensuresyspath=importmode)
/usr/lib/python2.7/site-packages/py/_path/local.py:650: in pyimport
    __import__(modname)
E     File "/home/abuild/rpmbuild/BUILD/python-systemd-233/build/lib.linux-x86_64-2.7/systemd/test/test_journal.py", line 212
E       print('printed message...', file=stream)
E                                       ^
E   SyntaxError: invalid syntax
!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!
=========================== 2 error in 0.57 seconds ============================
Makefile:54: recipe for target 'check' failed

Is the the failing line 212 required in the file? When I remove it I get the following error:


    def test_journal_stream():
        # This will fail when running in a bare chroot without /run/systemd/journal/stdout
        with skip_oserror(errno.ENOENT):
>           stream = journal.stream('test_journal.py')

systemd/test/test_journal.py:207: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

identifier = 'test_journal.py', priority = 6, level_prefix = False

    def stream(identifier=None, priority=LOG_INFO, level_prefix=False):
        r"""Return a file object wrapping a stream to journal.
    
        Log messages written to this file as simple newline sepearted text strings
        are written to the journal.
    
        The file will be line buffered, so messages are actually sent after a
        newline character is written.
    
        >>> from systemd import journal
        >>> stream = journal.stream('myapp')                       # doctest: +SKIP
        >>> res = stream.write('message...\n')                     # doctest: +SKIP
    
        will produce the following message in the journal::
    
          PRIORITY=7
          SYSLOG_IDENTIFIER=myapp
          MESSAGE=message...
    
        If identifier is None, a suitable default based on sys.argv[0] will be used.
    
        This interface can be used conveniently with the print function:
    
        >>> from __future__ import print_function
        >>> stream = journal.stream()                              # doctest: +SKIP
        >>> print('message...', file=stream)                       # doctest: +SKIP
    
        priority is the syslog priority, one of `LOG_EMERG`, `LOG_ALERT`,
        `LOG_CRIT`, `LOG_ERR`, `LOG_WARNING`, `LOG_NOTICE`, `LOG_INFO`, `LOG_DEBUG`.
    
        level_prefix is a boolean. If true, kernel-style log priority level prefixes
        (such as '<1>') are interpreted. See sd-daemon(3) for more information.
        """
    
        if identifier is None:
            if not _sys.argv or not _sys.argv[0] or _sys.argv[0] == '-c':
                identifier = 'python'
            else:
                identifier = _sys.argv[0]
    
>       fd = stream_fd(identifier, priority, level_prefix)
E       IOError: [Errno 2] No such file or directory

systemd/journal.py:489: IOError
================ 1 failed, 40 passed, 5 skipped in 0.39 seconds ================

@keszybz
Copy link
Member Author

keszybz commented Dec 16, 2016

Pfff. Can you give it another try?

@weberhofer
Copy link
Contributor

Tests are running now fine on Leap 42.2, but on 42.1 (systemd version is "210") I get one single failure:

=================================== FAILURES ===================================
_____________________________ [doctest] login.rst ______________________________
011 Example: polling for events
012 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
013 
014 This example shows that session/uid/seat/machine events can be waited
015 for (using e.g. `poll`). This makes it easy to integrate Monitor in an
016 external event loop:
017 
018   >>> import select
019   >>> from systemd import login
020   >>> m = login.Monitor("machine")
UNEXPECTED EXCEPTION: OSError(2, 'No such file or directory')
Traceback (most recent call last):

  File "/usr/lib64/python2.7/doctest.py", line 1315, in __run
    compileflags, 1) in test.globs

  File "<doctest login.rst[2]>", line 1, in <module>

OSError: [Errno 2] No such file or directory

/home/abuild/rpmbuild/BUILD/python-systemd-233/docs/login.rst:20: UnexpectedException
================ 1 failed, 36 passed, 9 skipped in 0.14 seconds ================
Makefile:54: recipe for target 'check' failed

@weberhofer
Copy link
Contributor

For the notes: I'm building python-systemd-233.tar.gz patched with #34

@keszybz
Copy link
Member Author

keszybz commented Dec 17, 2016

@weberhofer Hopefully it'll work now. I tested it in (rawhide) mock, and the tests pass...

@weberhofer
Copy link
Contributor

The build on Leap 42.2 is ok, Tumbleweed and 42.1 are failing:

__________________________________ test_seats __________________________________

    def test_seats():
        # just check that we get some sequence back
        with skip_oserror(errno.ENOENT):
            seats = login.seats()
>           assert len(seats) >= 0

systemd/test/test_login.py:21: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib64/python2.7/contextlib.py:35: in __exit__
    self.gen.throw(type, value, traceback)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

code = 2

    @contextlib.contextmanager
    def skip_oserror(code):
        try:
            yield
        except (OSError, IOError) as e:
            if e.errno == code:
>               pytest.skip()
E               NameError: global name 'pytest' is not defined

systemd/test/test_login.py:14: NameError
________________________________ test_sessions _________________________________

    def test_sessions():
        with skip_oserror(errno.ENOENT):
            sessions = login.sessions()
>           assert len(sessions) >= 0

systemd/test/test_login.py:26: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib64/python2.7/contextlib.py:35: in __exit__
    self.gen.throw(type, value, traceback)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

code = 2

    @contextlib.contextmanager
    def skip_oserror(code):
        try:
            yield
        except (OSError, IOError) as e:
            if e.errno == code:
>               pytest.skip()
E               NameError: global name 'pytest' is not defined

systemd/test/test_login.py:14: NameError
______________________________ test_machine_names ______________________________

    def test_machine_names():
        with skip_oserror(errno.ENOENT):
            machine_names = login.machine_names()
>           assert len(machine_names) >= 0

systemd/test/test_login.py:31: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib64/python2.7/contextlib.py:35: in __exit__
    self.gen.throw(type, value, traceback)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

code = 2

    @contextlib.contextmanager
    def skip_oserror(code):
        try:
            yield
        except (OSError, IOError) as e:
            if e.errno == code:
>               pytest.skip()
E               NameError: global name 'pytest' is not defined

systemd/test/test_login.py:14: NameError
__________________________________ test_uids ___________________________________

    def test_uids():
        with skip_oserror(errno.ENOENT):
            uids = login.uids()
>           assert len(uids) >= 0

systemd/test/test_login.py:36: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib64/python2.7/contextlib.py:35: in __exit__
    self.gen.throw(type, value, traceback)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

code = 2

    @contextlib.contextmanager
    def skip_oserror(code):
        try:
            yield
        except (OSError, IOError) as e:
            if e.errno == code:
>               pytest.skip()
E               NameError: global name 'pytest' is not defined

systemd/test/test_login.py:14: NameError
_________________________________ test_monitor _________________________________

    def test_monitor():
        p = select.poll()
    
        with skip_oserror(errno.ENOENT):
            m = login.Monitor("machine")
            p.register(m, m.get_events())
            login.machine_names()
            p.poll(1)
>           login.machine_names()

systemd/test/test_login.py:46: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib64/python2.7/contextlib.py:35: in __exit__
    self.gen.throw(type, value, traceback)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

code = 2

    @contextlib.contextmanager
    def skip_oserror(code):
        try:
            yield
        except (OSError, IOError) as e:
            if e.errno == code:
>               pytest.skip()
E               NameError: global name 'pytest' is not defined

systemd/test/test_login.py:14: NameError
================ 5 failed, 37 passed, 9 skipped in 0.65 seconds ================

@keszybz
Copy link
Member Author

keszybz commented Dec 17, 2016

I'm an idiot :(

I'll have to work on setting up better CI. AFAIK, there's no publicly available free service that runs on CentOS/Red Hat/Fedora instead of Ubuntu unfortunately.

@sebix
Copy link
Contributor

sebix commented Dec 17, 2016

AFAIK, there's no publicly available free service that runs on CentOS/Red Hat/Fedora instead of Ubuntu unfortunately.

OBS can: http://openbuildservice.org/2013/11/22/Source-Update-Via_Token/

@weberhofer
Copy link
Contributor

@keszybz if you like I can set up a project within my OBS account and connect it to your github project.

@keszybz
Copy link
Member Author

keszybz commented Dec 17, 2016

Sure, that would be nice.

It would be nice to hook up systemd to obs too. So far we have ubuntu (through semaphore), centos (through some centos internal service), and ubuntu (through ubuntu's internal QA), but more variety would be helpful.

@weberhofer
Copy link
Contributor

Dear @keszybz did you receive the token for automatic pushes to the OBS I have sent via mail?

keszybz added 2 commits March 12, 2017 12:26
This way we can skip ENOENT (which happens in containers).
While at it, let's extend the tests a bit, so that we at least
call all functions and check the type of the return value.

Also, drop '.nspawn' from the machine name, nspawn doesn't
use that suffix any more.
@keszybz
Copy link
Member Author

keszybz commented Mar 13, 2017

I'll merge this, since it's possible that the OBS builds are failing because of the lack of those patches.

@keszybz keszybz merged commit e121ae4 into systemd:master Mar 13, 2017
@keszybz keszybz deleted the test-skipping branch March 25, 2017 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants