Tuesday, 2021-07-20

digitalsimbojaHello!08:59
digitalsimboja@maysams, @dulek: Please help check what am not getting right here09:00
opendevreviewRoman Dobosz proposed openstack/kuryr-kubernetes master: Change documentation for devstack deployment.  https://review.opendev.org/c/openstack/kuryr-kubernetes/+/80126509:00
digitalsimbojaI defined ad tags09:00
digitalsimbojahttps://paste.opendev.org/show/807580/09:00
digitalsimbojaI am calling the add_tags here09:02
digitalsimbojahttps://paste.opendev.org/show/807581/09:02
digitalsimbojai get this error09:02
digitalsimboja                                               09:03
digitalsimboja      File "/usr/lib/python3.8/unittest/mock.py", line 913, in assert_called_with09:03
digitalsimboja    raise AssertionError(_error_message()) from cause09:03
digitalsimboja                                               09:03
digitalsimboja    AssertionError: expected call not found.09:03
digitalsimbojaExpected: ports(status='ACTIVE')         09:03
digitalsimbojaActual: ports(status='ACTIVE', tags=['foo'])09:03
digitalsimboja                                                                                                                                                                                            09:03
digitalsimboja                                                                                                                                                                                            09:03
digitalsimboja                                               09:03
digitalsimboja======         09:03
maysamsdigitalsimboja: you could use a mock for the lbaasv2 driver and mock the add_tags call and set the return_value09:06
maysamsinstead of defining the function on the test09:06
maysamsdigitalsimboja: maybe something like https://github.com/openstack/kuryr-kubernetes/blob/e8abda8674079699c950c92d180dd8d3299140db/kuryr_kubernetes/tests/unit/controller/drivers/test_lbaasv2.py#L82-L8409:08
dulekdigitalsimboja: Looks like you just need to add tags to assertCalledOnceWith in the test or a similar function.09:11
dulekThe test checks if .ports() were called with particular parameters. As it's now called differently you need to modify the mock check?09:11
digitalsimbojaLet me take a look and be back09:13
digitalsimboja@maysams: I am still getting this13:19
digitalsimboja                                           13:20
digitalsimboja      File "/usr/lib/python3.8/unittest/mock.py", line 637, in __getattr__13:20
digitalsimboja    raise AttributeError("Mock object has no attribute %r" % name)13:20
digitalsimboja                                               13:20
digitalsimboja    AttributeError: Mock object has no attribute '_drv_lbaas'13:20
maysamshello digitalsimboja14:53
digitalsimbojahello14:54
maysamscan you share the code fragment that is causing such issue?14:54
digitalsimbojaa second14:55
digitalsimbojahttps://paste.opendev.org/show/807596/14:55
digitalsimbojaKeeps reporting attribute error for the instance of the driver defined in the constructor15:01
gryfdigitalsimboja, perhaps this is side effect of using mock, which has been called and return another mock. i.e. you might forgot to return some expected object using return_value/side_effect attributes.15:03
digitalsimbojaSo I need to set the return_value15:05
gryfnot sure where, since I've not seen the code you try to test.15:08
digitalsimbojaPlease take a look 15:09
digitalsimbojahttps://paste.opendev.org/show/807597/15:10
gryfok, so this review: https://review.opendev.org/c/openstack/kuryr-kubernetes/+/800707 right?15:11
digitalsimbojaYeah sure15:12
digitalsimbojaNot this in particular but here 15:15
digitalsimbojahttps://review.opendev.org/c/openstack/kuryr-kubernetes/+/79890415:15
digitalsimbojaBut same logic almost15:16
maysamsdigitalsimboja: have you tried removing the return_value15:17
maysams?15:17
digitalsimbojalet me do it15:17
maysamsor you could just try to create a mock with the driver spec instead15:18
gryfin this particular case m_handler in the test, doesn't have attribute _drv_lbaas. At least this is the thing mock is complaining of.15:18
digitalsimbojayeah sure15:18
gryfand yet, it trying to access it https://review.opendev.org/c/openstack/kuryr-kubernetes/+/798904/20/kuryr_kubernetes/controller/handlers/loadbalancer.py#14515:19
gryfwhich is weird, since you mocked it: m_handler = mock.Mock(spec=h_lb.KuryrLoadBalancerHandler)15:20
digitalsimbojaI have been on this, honestly its wierd to me15:26
digitalsimbojaI read that this usually occurs if the reference its defined on the constructor, I have tried what was recomended but did not resolve it15:27
digitalsimboja@gryf: I guess mocking the handler would bring in all the classes and methods initialized at the constructor and within the handler class?15:39
gryfthat's the idea of creating mock with spec.15:40
gryfalthough at some point you got this attribute error, so I'm wondering why.15:41
opendevreviewSunday Mgbogu proposed openstack/kuryr-kubernetes master: wip: Loadbalancers reconciliation  https://review.opendev.org/c/openstack/kuryr-kubernetes/+/79890418:06

Generated by irclog2html.py 2.17.2 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!