severb / graypy

Python logging handler for Graylog that sends messages in GELF (Graylog Extended Log Format).
https://www.graylog.org/
BSD 3-Clause "New" or "Revised" License
258 stars 90 forks source link

test_resolve_host fails due to hostname != FQDN #113

Closed bdrung closed 5 years ago

bdrung commented 5 years ago

The Debian package of graypy 1.1.2-1 fails in test_resolve_host:

I: pybuild base:217: cd /<<PKGBUILDDIR>>/.pybuild/cpython2_2.7_graypy/build; python2.7 -m pytest tests
============================= test session starts ==============================
platform linux2 -- Python 2.7.16, pytest-3.10.1, py-1.7.0, pluggy-0.8.0
rootdir: /<<PKGBUILDDIR>>, inifile:
collected 262 items

tests/integration/test_chunked_logging.py s                              [  0%]
tests/integration/test_common_logging.py sssssssssssssss                 [  6%]
tests/integration/test_debugging_fields.py sssssss                       [  8%]
tests/integration/test_extra_fields.py sssssss                           [ 11%]
tests/integration/test_status_issue.py sssssssssssssssssssssssssssssssss [ 24%]
ssssssssssss                                                             [ 28%]
tests/unit/test_ExcludeFilter.py .......                                 [ 31%]
tests/unit/test_GELFRabbitHandler.py ..x.                                [ 32%]
tests/unit/test_handler.py ............................................. [ 50%]
...................sssssssssssssss...................................... [ 77%]
......................................F........ss..........              [100%]

=================================== FAILURES ===================================
______________________________ test_resolve_host _______________________________

    def test_resolve_host():
        """Test all posible resolutions of :meth:`BaseGELFHandler._resolve_host`"""
        assert socket.gethostname() == BaseGELFHandler._resolve_host(False, None)
        assert socket.getfqdn() == BaseGELFHandler._resolve_host(True, None)
>       assert socket.gethostname() == BaseGELFHandler._resolve_host(True, "localhost")
E       AssertionError: assert 'x86-grnet-02' == 'x86-grnet-02.debian.org'
E         - x86-grnet-02
E         + x86-grnet-02.debian.org

tests/unit/test_handler.py:176: AssertionError
========= 1 failed, 168 passed, 92 skipped, 1 xfailed in 0.86 seconds ==========

BaseGELFHandler._resolve_host returns the FQDN, but socket.gethostname returns only the hostname (first part of the FQDN).

Full build log: https://buildd.debian.org/status/fetch.php?pkg=graypy&arch=all&ver=1.1.2-1&stamp=1562588890&raw=0

nklapste commented 5 years ago

Good catch this is the result of a incorrectly built test case! This will be addressed in PR #114