Re: [openstack-dev] Decorator behavior

2014-04-01 Thread Yuriy Taraday
Hello.


On Mon, Mar 31, 2014 at 9:32 PM, Dan Smith  wrote:
>
>  >
> > (self, context, [], {'migration': migration, 'image': image,
> > 'instance': instance, 'reservations': reservations})
> >
> > while when running a test case, they see these arguments:
> >
> > (self, context, [instance, image, reservations, migration,
> > instance_type], {})
>
> All RPC-called methods get called with all of their arguments as keyword
> arguments. I think this explains the runtime behavior you're seeing.
> Tests tend to differ in this regard because test writers are human and
> call the methods in the way they normally expect, passing positional
> arguments when appropriate.
>

It might be wise to add something like
https://pypi.python.org/pypi/kwonlyto all methods that are used in RPC
and modify tests appropriately to avoid
such confusion in future.

-- 

Kind regards, Yuriy.
___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


Re: [openstack-dev] Decorator behavior

2014-03-31 Thread Dan Smith
> At run time there are decorators that behave in an unexpected manner.
> For instance, in nova/compute/manager.py when ComputeManager's
> resize_instance method is called, the "migration" positional argument
> is somehow added to kwargs (paired with the "migration" key) and is
> stripped out of the args parameters when the decorators are called.
> However, when this same method is called in
> nova/tests/compute/test_compute_mgr.py, the "migration" positional
> argument remains in args when the decorators are called.  In other
> words at run time the decorators see these arguments:
> 
> (self, context, [], {'migration': migration, 'image': image,
> 'instance': instance, 'reservations': reservations})
> 
> while when running a test case, they see these arguments:
> 
> (self, context, [instance, image, reservations, migration,
> instance_type], {})

All RPC-called methods get called with all of their arguments as keyword
arguments. I think this explains the runtime behavior you're seeing.
Tests tend to differ in this regard because test writers are human and
call the methods in the way they normally expect, passing positional
arguments when appropriate.

--Dan


___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


[openstack-dev] Decorator behavior

2014-03-31 Thread John S Warren
At run time there are decorators that behave in an unexpected manner.
For instance, in nova/compute/manager.py when ComputeManager's
resize_instance method is called, the "migration" positional argument
is somehow added to kwargs (paired with the "migration" key) and is
stripped out of the args parameters when the decorators are called.
However, when this same method is called in
nova/tests/compute/test_compute_mgr.py, the "migration" positional
argument remains in args when the decorators are called.  In other
words at run time the decorators see these arguments:

(self, context, [], {'migration': migration, 'image': image,
'instance': instance, 'reservations': reservations})

while when running a test case, they see these arguments:

(self, context, [instance, image, reservations, migration,
instance_type], {})


What is happening at run time to cause this behavior?  How can this
behavior be duplicated when executing test cases, so that the test
cases correctly mimic run-time behavior?___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev