Polyconseil / aioamqp

AMQP implementation using asyncio
Other
280 stars 88 forks source link

Test test_connection_unexistant_vhost failed #80

Closed mastak closed 8 years ago

mastak commented 8 years ago

I have one failure in tests (other tests are succeed):

nosetests  --verbosity=2 aioamqp.tests.test_protocol:ProtocolTestCase.test_connection_unexistant_vhost
test_connection_unexistant_vhost (aioamqp.tests.test_protocol.ProtocolTestCase) ... FAIL

======================================================================
FAIL: test_connection_unexistant_vhost (aioamqp.tests.test_protocol.ProtocolTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/mastak/aioamqp/aioamqp/tests/testing.py", line 41, in wrapper
    self.loop.run_until_complete(asyncio.wait_for(coro(self), timeout=timeout_, loop=self.loop))
  File "/usr/lib/python3.4/asyncio/base_events.py", line 316, in run_until_complete
    return future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 275, in result
    raise self._exception
  File "/usr/lib/python3.4/asyncio/tasks.py", line 238, in _step
    result = next(coro)
  File "/usr/lib/python3.4/asyncio/tasks.py", line 377, in wait_for
    return fut.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 275, in result
    raise self._exception
  File "/usr/lib/python3.4/asyncio/tasks.py", line 238, in _step
    result = next(coro)
  File "/home/mastak/aioamqp/aioamqp/tests/test_protocol.py", line 43, in test_connection_unexistant_vhost
    yield from amqp_connect(virtualhost='/unexistant', loop=self.loop)
nose.proxy.AssertionError: AmqpClosedConnection not raised
-------------------- >> begin captured stdout << ---------------------
http://localhost:15672/api/vhosts/%2Ftest-aioamqp
http://localhost:15672/api/vhosts/%2Ftest-aioamqp
http://localhost:15672/api/permissions/%2Ftest-aioamqp/guest

--------------------- >> end captured stdout << ----------------------
-------------------- >> begin captured logging << --------------------
asyncio: DEBUG: Using selector: EpollSelector
aioamqp.protocol: INFO: Recv open ok
aioamqp.channel: DEBUG: Channel is open
aioamqp.protocol: WARNING: Server closed connection: NOT_ALLOWED - access to vhost '/unexistant' refused for user 'guest', code=530, class_id=10, method_id=40
aioamqp.tests.testcase: DEBUG: Delete channel <aioamqp.tests.testcase.ProxyChannel object at 0x7f7745bc4d30>
aioamqp.tests.testcase: DEBUG: Delete channel <aioamqp.tests.testcase.ProxyChannel object at 0x7f7745bc4d30>
aioamqp.tests.testcase: DEBUG: Delete amqp <aioamqp.tests.testcase.ProxyAmqpProtocol object at 0x7f7745bc4e10>
aioamqp.protocol: ERROR: error on dispatch
Traceback (most recent call last):
  File "/home/mastak/aioamqp/aioamqp/protocol.py", line 255, in run
    yield from self.dispatch_frame()
  File "/home/mastak/aioamqp/aioamqp/protocol.py", line 210, in dispatch_frame
    yield from self.channels[frame.channel].dispatch_frame(frame)
  File "/home/mastak/aioamqp/aioamqp/channel.py", line 111, in dispatch_frame
    yield from methods[(frame.class_id, frame.method_id)](frame)
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 141, in coro
    res = func(*args, **kw)
  File "/home/mastak/aioamqp/aioamqp/channel.py", line 166, in close_ok
    self._get_waiter('close').set_result(True)
  File "/home/mastak/aioamqp/aioamqp/channel.py", line 50, in _get_waiter
    raise exceptions.SynchronizationError("Call %s didn't set a waiter" % rpc_name)
aioamqp.exceptions.SynchronizationError: Call close didn't set a waiter
aioamqp.protocol: WARNING: Server closed connection: CHANNEL_ERROR - expected 'channel.open', code=504, class_id=20, method_id=40
aioamqp.protocol: WARNING: Connection lost exc=None
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
Ran 1 test in 0.151s

Also I have many failures tests when I run it on mac os. It has some limits with docker, and I want to fix it. But I think it would be better if all the tests will pass on linux, and only after that I will make changes.

mastak commented 8 years ago

In rabbitmq logs, there are some errors after running tests:

=ERROR REPORT==== 19-Feb-2016::21:32:06 ===
Error on AMQP connection <0.1149.4> (192.168.155.1:64092 -> 172.17.0.2:5672, vhost: '/test-aioamqp', user: 'admin', state: running), channel 1:
operation channel.close caused a connection exception channel_error: "expected 'channel.open'"

I figured out that one channel added twice to the self.channels list: testcase.py

# ...
class ProxyChannel(Channel):
    def __init__(self, test_case, *args, **kw):
        super().__init__(*args, **kw)
        self.test_case = test_case
        self.test_case.register_channel(self)
# ...
    def reset_vhost(self):
    # ...
        @asyncio.coroutine
        def go():
            transport, protocol = yield from self.create_amqp()
            channel = yield from self.create_channel(amqp=protocol)
            self.channels.append(channel)
dzen commented 8 years ago

There are also some tests that triggers some errors in Rabbit for instance:

https://github.com/Polyconseil/aioamqp/blob/master/aioamqp/tests/test_close.py#L38

RemiCardona commented 8 years ago

Confirming original test failure. I think it's due to rabbitmq/rabbitmq-server#237 that was merged in RabbitMQ 3.6.0 (though I didn't check with an older version to confirm).

In any case, I've got a patch for this, will push ASAP.