Earlier  
Posted Nick Remark
#openstack-nova - 2023-06-29
13:49:23 dvo-plv Hello, All. I'm currently writing functional test, my result should be expected fail. How should I handle this properly?
13:56:48 dvo-plv Should I set just @unittest.expectedFailure, or I need to create some additional note?
15:32:04 melwitt dvo-plv: are you doing the func test as part of a bug fix? if so what we usually do is put the func test first and assert the wrong behavior with a code comment explaining what bug it's about, then stack the fix patch on top and as part of it change the assert in the func test to assert the correct behavior and remove the code comment about the buggy behavior. and if the func test is for a regression, it should go under
15:32:04 melwitt nova/tests/functional/regressions/
15:34:02 dvo-plv No, this is not a bug. This is a test for new feature
15:34:14 dvo-plv test is based on this Sean's comment https://review.opendev.org/c/openstack/nova/+/876075/14/nova/scheduler/request_filter.py#285
15:34:45 dvo-plv I need to catch configuration conflict between image and flavor, during the resize and rebuils
15:36:16 melwitt dvo-plv: ok I see. for that you can do like self.assertRaises(exception, func, arg, arg, arg, ...) if you want to assert that the proper exception is raised in a particular situation
15:38:17 melwitt in the test. expectedFailure is more for a test that we have to disable because something is wrong and remove the decorator whenever the problem is fixed. there's only a couple of examples in the code like https://github.com/openstack/nova/blob/d56d1a828df512136645aa257082bc929a4e353d/nova/tests/functional/libvirt/test_shared_resource_provider.py#L36
16:42:51 dvo-plv okay, i see thank you
16:46:08 opendevreview Alexey Stupnikov proposed openstack/nova master: Add functional tests to reproduce bug #1994983 https://review.opendev.org/c/openstack/nova/+/863416
17:54:19 dvo-plv melwitt, Maybe you can ghelp me how to handle this output
17:54:23 dvo-plv (Pdb) n
17:54:23 dvo-plv AssertionError: Notification instance.resize.end hasn't been received. Received:
17:54:23 dvo-plv []
17:54:53 dvo-plv It does not catch with asserraises
17:54:54 dvo-plv (Pdb) x = self.assertRaises(exception.FlavorImageConflict,self._resize_server(server, new_flavor_id))
17:54:54 dvo-plv *** AssertionError: Notification instance.resize.end hasn't been received. Received:
17:54:54 dvo-plv []
17:57:15 melwitt dvo-plv: it should be self.assertRaises(exception.FlavorImageConflict, self._resize_server, server, new_flavor_id) https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertRaises in case you're curious
18:00:01 dvo-plv I alredy tried this way
18:00:03 dvo-plv (Pdb) ex = self.assertRaises(exception.FlavorImageConflict,self._resize_server,server,new_flavor_id)
18:00:03 dvo-plv *** AssertionError: Notification instance.resize.end hasn't been received. Received:
18:00:03 dvo-plv []
18:00:03 dvo-plv (Pdb) ex
18:00:03 dvo-plv *** NameError: name 'ex' is not defined
18:00:14 dvo-plv it does not generate output for handing
18:01:44 dvo-plv I expected this output
18:01:45 dvo-plv File "/opt/stack/nova/nova/virt/hardware.py", line 1971, in get_packed_virtqueue_constraint
18:01:45 dvo-plv raise exception.FlavorImageConflict(
18:01:45 dvo-plv nova.exception.FlavorImageConflict: Flavor vhrvsprsjopvuncogcmp has hw:virtio_packed_ring extra spec explicitly set to False, conflicting with image fake-image-custom-property which has hw_virtio_packed_ring explicitly set to True.
18:03:07 melwitt can you link your code or pastebin it? it sounds like you might be missing a notifications fixture/mock
18:04:48 dvo-plv it calls this method https://review.opendev.org/c/openstack/nova/+/876075/14/nova/virt/hardware.py
18:04:58 dvo-plv via this https://review.opendev.org/c/openstack/nova/+/876075/14/nova/scheduler/request_filter.py
18:06:03 melwitt I mean the code of your func test. it's hard to tell what's wrong without seeing it
18:06:50 dvo-plv def test_resize_virtio_packed_ring_image_flavor_conflict(self):
18:06:50 dvo-plv """Ensure that packed_virtqueue_filter filter will reject resize
18:06:50 dvo-plv due to image property and flavor extra spec conflict
18:06:50 dvo-plv """
18:06:50 dvo-plv # Decorate compute 1 and compute2 resource provider with trait.
18:06:52 dvo-plv rp_uuid1 = self._get_provider_uuid_by_host(self.compute1.host)
18:06:53 dvo-plv rp_uuid2 = self._get_provider_uuid_by_host(self.compute2.host)
18:06:55 dvo-plv self._set_provider_traits(rp_uuid1, ['COMPUTE_NET_VIRTIO_PACKED'])
18:06:57 dvo-plv self._set_provider_traits(rp_uuid2, ['COMPUTE_NET_VIRTIO_PACKED'])
18:06:59 dvo-plv # Create image with enabled Virtio Packed Ring property
18:07:01 dvo-plv image = self._create_image(metadata={'hw_virtio_packed_ring': 'true'})
18:07:03 dvo-plv flavor_id = self._create_flavor(extra_spec={})
18:07:05 dvo-plv # Create server using only image with property
18:07:07 dvo-plv server = self._create_server(flavor_id=flavor_id,
18:07:09 dvo-plv image_uuid=image['id'],
18:07:11 dvo-plv expected_state='ACTIVE',
18:07:13 dvo-plv networks='none')
18:07:16 melwitt please use pastebin for pastes 😆
18:07:16 melwitt please use pastebin for pastes 😆
18:07:17 dvo-plv server = self._wait_for_state_change(server, 'ACTIVE')
18:07:19 dvo-plv # Create flavor with disabled Virtio Packed Ring in the extra spec
18:07:21 dvo-plv new_flavor_id = self._create_flavor(extra_spec={'hw:virtio_packed_ring': 'false'})
18:07:23 dvo-plv import rpdb
18:07:25 dvo-plv debugger = rpdb.Rpdb(port=12345)
18:07:27 dvo-plv debugger.set_trace()
18:07:29 dvo-plv ex = self.assertRaises(exception.FlavorImageConflict, self._resize_server, server, new_flavor_id)
18:09:09 dvo-plv https://paste.opendev.org/show/bD8BWCnpsUY8Rr7c6Hc7/
18:10:01 dvo-plv I implemented this test here
18:10:05 dvo-plv (functional) stack@server72:/opt/stack/nova$ tox -e functional -- nova.tests.functional.test_servers.TraitsBasedSchedulingTest.test_resize_virtio_packed_ring_image_flavor_conflict
18:13:32 melwitt oh, right sorry 😣 bc this is a func test you will rather have to look at the returned http status code and message. sec
18:13:32 melwitt oh, right sorry 😣 bc this is a func test you will rather have to look at the returned http status code and message. sec
18:14:38 dvo-plv I saw this option in the other examples
18:14:39 dvo-plv self.assertEqual(403, ex.response.status_code)
18:14:50 dvo-plv but i can not get status code
18:17:27 dvo-plv https://paste.opendev.org/show/bOdkEFYHa3h24nBD5Ws1/
18:17:30 dvo-plv this is test output
18:17:33 melwitt yeah, I think you can't use the _resize_server helper function in this case bc it will only return you the server object and bc it will wait for expected notifications https://github.com/openstack/nova/blob/master/nova/tests/functional/integrated_helpers.py#L530 which are not all going to happen in your case
18:17:54 melwitt since you're testing for an error condition
18:19:12 melwitt so you'll want to unwrap that i.e. call self.api.post_server_action directly, like this https://github.com/openstack/nova/blob/master/nova/tests/functional/test_servers.py#L347
18:19:22 dvo-plv I see, I will try to figure out without this wrapper, thank you
18:22:27 melwitt in the func tests the error exception will always be client.OpenStackApiException with the details encapsulated inside of it as it's imitating a rest API caller who will receive only an error from the client, not the internal exception that nova raised
18:25:19 dvo-plv okay, I believe it will help me, thank you
18:54:23 dvo-plv maybe I need something else for my case ?
18:54:59 dvo-plv I updated my test in this way
18:54:59 dvo-plv https://paste.opendev.org/show/bXTsHeFs7ct1qOUcLg1r/
18:55:11 dvo-plv But i get this error testtools.matchers._impl.MismatchError: <bound method TestOpenStackClient.post_server_action of <nova.tests.functional.api.client.TestOpenStackClient object at 0x7f7b4fe13b50>> returned {}
18:55:33 dvo-plv (Pdb) self.api.post_server_action(server['id'], {'resize': {'flavorRef': new_flavor_id}})
18:55:34 dvo-plv {}
19:00:24 dvo-plv It does not call class Fault(webob.exc.HTTPException) fault names
19:02:01 melwitt dvo-plv: that means that when you requested the resize you got a http status OK and you were expecting probably a 409 or? if your code is supposed to raise a conflict/409 to the rest API caller, there may be a bug with the exception not propagating up to the API
19:02:14 melwitt *you may have a bug
19:02:40 dvo-plv yes, look like it does not call status code from this class 409: "conflictingRequest",
19:02:47 dvo-plv class Fault(webob.exc.HTTPException):
19:04:50 melwitt yeah so you'll want to debug and trace from where you raise exception.FlavorImageConflict up to the API and find where it's not being propagated up
19:05:38 melwitt (again, if your intended behavior is a http 409 returned to the rest API caller)
#openstack-nova - 2023-06-30
08:13:50 opendevreview Yamato Tanaka proposed openstack/python-novaclient master: Do exact-matching when finding one instance by name https://review.opendev.org/c/openstack/python-novaclient/+/887268
08:20:48 opendevreview Alexey Stupnikov proposed openstack/nova master: Add functional tests to reproduce bug #1994983 https://review.opendev.org/c/openstack/nova/+/863416
08:35:39 opendevreview Guillaume Espanel proposed openstack/nova master: Skip useless qemu-img convert when snapshotting https://review.opendev.org/c/openstack/nova/+/851854
08:50:33 opendevreview Guillaume Espanel proposed openstack/nova master: Skip useless qemu-img convert when snapshotting https://review.opendev.org/c/openstack/nova/+/851854
09:45:31 opendevreview Amit Uniyal proposed openstack/nova-specs master: Adds cleanup to remove dangling volumes https://review.opendev.org/c/openstack/nova-specs/+/878757
09:52:09 opendevreview Arnaud Morin proposed openstack/nova stable/2023.1: Unbind port when offloading a shelved instance https://review.opendev.org/c/openstack/nova/+/887183
12:10:04 opendevreview Alexey Stupnikov proposed openstack/nova master: Add functional tests to reproduce bug #1994983 https://review.opendev.org/c/openstack/nova/+/863416
13:44:02 opendevreview Alexey Stupnikov proposed openstack/nova master: Log some InstanceNotFound exceptions from libvirt https://review.opendev.org/c/openstack/nova/+/863665
13:53:34 opendevreview Alexey Stupnikov proposed openstack/nova master: Add functional tests to reproduce bug #1994983 https://review.opendev.org/c/openstack/nova/+/863416
15:22:35 opendevreview Alexey Stupnikov proposed openstack/nova master: Log some InstanceNotFound exceptions from libvirt https://review.opendev.org/c/openstack/nova/+/863665

Earlier   Later