Added a new method in Openstack. Code works fine but test case failed.

Asked by Sateesh Bodla

Hi All,

I have added a new method "def create_empty_queue" in class Connection of impl_kombu.py file of rpc module. I am calling that function in call method using following code:

conn = rpc.create_connection(new=True)
conn.create_empty_queue(topic)

This is working fine when I execute some commands related to nova and results in what I expected. But when I run the test cases I am getting an errors that Connection object has no attribute 'create_empty_queue'. Please find the trace below. Do I need to add any thing in the test cases for this newly added method. Please let me know what I should do to resolve this.

======================================================================
ERROR: test_proxycallback_handles_exceptions (nova.tests.rpc.test_kombu.RpcKombuTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/novachanges/nova/nova/tests/rpc/common.py", line 196, in test_proxycallback_handles_exceptions
    "args": {"value": value}})
  File "/root/novachanges/nova/nova/rpc/impl_kombu.py", line 705, in cast
    conn.create_empty_queue(topic)
AttributeError: 'Connection' object has no attribute 'create_empty_queue'
-------------------- >> begin captured logging << --------------------
nova.rpc.common: INFO: Connected to AMQP server on localhost:5672
--------------------- >> end captured logging << ---------------------

Thanks in advance,
Sateesh B.

Question information

Language:
English Edit question
Status:
Solved
For:
OpenStack Compute (nova) Edit question
Assignee:
No assignee Edit question
Solved by:
yong sheng gong
Solved:
Last query:
Last reply:
Revision history for this message
Sateesh Bodla (sateesh-bodla) said :
#1

I have tested the above case in virtual environment using the command "tools/with_venv.sh ./run_tests.sh".

Revision history for this message
yong sheng gong (gongysh) said :
#2

Could you please paste your method that calls:
conn = rpc.create_connection(new=True)
conn.create_empty_queue(topic)

Thanks

Revision history for this message
Sateesh Bodla (sateesh-bodla) said :
#3

Hi Yong,

I am calling the above function in rpc call and cast menthods of rpc/impl_kombu.py file. Please find below the code:

def call(context, topic, msg, timeout=None):
    """Sends a message on a topic and wait for a response."""
    conn = rpc.create_connection(new=True)
    conn.create_empty_queue(topic)
    return rpc_amqp.call(context, topic, msg, timeout, Connection.pool)

def cast(context, topic, msg):
    """Sends a message on a topic without waiting for a response."""
    conn = rpc.create_connection(new=True)
    conn.create_empty_queue(topic)
    return rpc_amqp.cast(context, topic, msg, Connection.pool)

I have defined this create_empty_queue method in Connection class.

Thanks in advance,
Sateesh B.

Revision history for this message
Best yong sheng gong (gongysh) said :
#4

 Although I don't know why you do this, I think you should write:

def call(context, topic, msg, timeout=None):
    """Sends a message on a topic and wait for a response."""
    conn = create_connection(new=True)
    conn.create_empty_queue(topic)
    return rpc_amqp.call(context, topic, msg, timeout, Connection.pool)

def cast(context, topic, msg):
    """Sends a message on a topic without waiting for a response."""
    conn = create_connection(new=True)
    conn.create_empty_queue(topic)
    return rpc_amqp.cast(context, topic, msg, Connection.pool)

Also:

class Connection(object):
    """Connection object."""

    def create_empty_queue(self, topic):
        print "test me"

Revision history for this message
Sateesh Bodla (sateesh-bodla) said :
#5

Thanks yong sheng gong, that solved my question.