#367 Adjust change in the error message and support fedora-messaging 2.0.0
Opened 10 months ago by pingou. Modified 9 months ago
pingou/waiverdb master  into  master

file modified
+1
@@ -3,6 +3,7 @@ 

  

  fedora_messaging

  Flask

+ Flask-Migrate

  Flask-RESTful!=0.3.6

  Flask-SQLAlchemy

  flask-cors

file modified
+1 -3
@@ -2,7 +2,6 @@ 

  

  import os

  from copy import copy

- from mock import patch

  import pytest

  from sqlalchemy import create_engine

  from waiverdb.app import create_app
@@ -57,8 +56,7 @@ 

      by default.

      """

      with app.test_client() as client:

-         with patch('fedora_messaging.api._session_cache'):

-             yield client

+         yield client

  

  

  @pytest.fixture()

file modified
+1 -1
@@ -260,7 +260,7 @@ 

      assert r.status_code == 404

      res_data = json.loads(r.get_data(as_text=True))

      message = (

-         'The requested URL was not found on the server.  If you entered the '

+         'The requested URL was not found on the server. If you entered the '

          'URL manually please check your spelling and try again.')

      assert res_data['message'] == message

  

file modified
+1
@@ -21,6 +21,7 @@ 

  changedir = docs

  deps =

      -rrequirements.txt

+     -rtest-requirements.txt

  whitelist_externals =

      mkdir

      rm

With this PR, the tests are passing for me locally.
However, there are a lot of noise at the end of the run (see below) which make me doubt if this is the right approach/fix.

@cverna you added the patch on _session_cache, do you remember by any chances why or what it was meant to do?

--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib64/python3.6/logging/__init__.py", line 996, in emit
    stream.write(msg)
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/_pytest/capture.py", line 427, in write
    self.buffer.write(obj)
ValueError: I/O operation on closed file
Call stack:
  File "/usr/lib64/python3.6/threading.py", line 884, in _bootstrap
    self._bootstrap_inner()
  File "/usr/lib64/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib64/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/crochet/_eventloop.py", line 412, in <lambda>
    target=lambda: self._reactor.run(installSignalHandlers=False),
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/twisted/internet/base.py", line 1283, in run
    self.mainLoop()
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/twisted/internet/base.py", line 1295, in mainLoop
    self.doIteration(t)
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/twisted/internet/epollreactor.py", line 235, in doPoll
    log.callWithLogger(selectable, _drdw, selectable, fd, event)
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/twisted/python/log.py", line 103, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/twisted/python/log.py", line 86, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/twisted/python/context.py", line 122, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/twisted/python/context.py", line 85, in callWithContext
    return func(*args,**kw)
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/twisted/internet/posixbase.py", line 627, in _doReadOrWrite
    self._disconnectSelectable(selectable, why, inRead)
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/twisted/internet/posixbase.py", line 255, in _disconnectSelectable
    selectable.connectionLost(f)
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/twisted/internet/tcp.py", line 520, in connectionLost
    self.connector.connectionLost(reason)
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/twisted/internet/base.py", line 1174, in connectionLost
    self.factory.doStop()
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/twisted/internet/protocol.py", line 96, in doStop
    self.stopFactory()
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/twisted/internet/defer.py", line 1613, in unwindGenerator
    return _cancellableInlineCallbacks(gen)
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/twisted/internet/defer.py", line 1529, in _cancellableInlineCallbacks
    _inlineCallbacks(None, g, status)
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
    result = g.send(result)
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/fedora_messaging/twisted/factory.py", line 379, in stopFactory
    yield self._client.halt()
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/twisted/internet/defer.py", line 1613, in unwindGenerator
    return _cancellableInlineCallbacks(gen)
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/twisted/internet/defer.py", line 1529, in _cancellableInlineCallbacks
    _inlineCallbacks(None, g, status)
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
    result = g.send(result)
  File "/home/pierrey/repos/gitrepo/waiverdb/.tox/py36/lib/python3.6/site-packages/fedora_messaging/twisted/protocol.py", line 594, in halt
    _std_log.info("Disconnect requested, but AMQP connection already gone")
Message: 'Disconnect requested, but AMQP connection already gone'
Arguments: ()
--- Logging error ---

Build 7ac5992d89cb9985707eacff7f182ea98661b6f7 FAILED!
Rebase or make new commits to rebuild.

1 new commit added

  • Add missing requirement to the requirements.txt file
10 months ago

1 new commit added

  • Add the test requirements when building the doc
10 months ago

Build 3c1265d11dd3dce11393df03ad3bf1c29583caf9 FAILED!
Rebase or make new commits to rebuild.

flake8 complains that from mock import patch is not needed.

With this PR, the tests are passing for me locally.
However, there are a lot of noise at the end of the run (see below) which make me doubt if this is the right approach/fix.
@cverna you added the patch on _session_cache, do you remember by any chances why or what it was meant to do?

Sorry but I honestly have no idea :(

rebased onto e0987a9

10 months ago

Build 56d81ca FAILED!
Rebase or make new commits to rebuild.

you added the patch on _session_cache, do you remember by any chances why or what it was meant to do?

It looks like it was used to avoid sending messages when running tests. Better way would be to set MESSAGE_BUS_PUBLISH = False in TestingConfig and enable/mock it when needed.

Not sure why it works for you locally - I would expect some tests to fail (as it happens on Jenkins).

But if I revert the removed patch line, I see failed test case:

=================================== FAILURES ===================================
_______________________ test_404_for_nonexistent_waiver ________________________

client = <FlaskClient <Flask 'waiverdb.app'>>
session = <sqlalchemy.orm.scoping.scoped_session object at 0x7fa845ecf358>

    def test_404_for_nonexistent_waiver(client, session):
        r = client.get('/api/v1.0/waivers/foo')
        assert r.status_code == 404
        res_data = json.loads(r.get_data(as_text=True))
        message = (
            'The requested URL was not found on the server. If you entered the '
            'URL manually please check your spelling and try again.')
>       assert res_data['message'] == message
E       AssertionError: assert ('The requested URL was not found on the server.  If you entered the URL '\n 'manually please check your spelling and try again.') == ('The requested URL was not found on the server. If you entered the URL '\n 'manually please check your spelling and try again.')
E         - The requested URL was not found on the server.  If you entered the URL manually please check your spelling and try again.
E         ?                                                -
E         + The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

BTW, I'm running tests with podman-compose from greenwave repo clone (make up && make test-waiverdb).