<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/openstack/nova.git/nova/tests/unit/objects/test_build_request.py, branch master</title>
<subtitle>opendev.org: openstack/nova.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/'/>
<entry>
<title>Use unittest.mock instead of third party mock</title>
<updated>2022-08-01T15:46:26+00:00</updated>
<author>
<name>Stephen Finucane</name>
<email>stephenfin@redhat.com</email>
</author>
<published>2020-03-24T15:12:07+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=89ef050b8c049b9a6f0e2c70408fc93c826c55e0'/>
<id>89ef050b8c049b9a6f0e2c70408fc93c826c55e0</id>
<content type='text'>
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib. Most of this
is autogenerated, as described below, but there is one manual change
necessary:

nova/tests/functional/regressions/test_bug_1781286.py
  We need to avoid using 'fixtures.MockPatch' since fixtures is using
  'mock' (the library) under the hood and a call to 'mock.patch.stop'
  found in that test will now "stop" mocks from the wrong library. We
  have discussed making this configurable but the option proposed isn't
  that pretty [1] so this is better.

The remainder was auto-generated with the following (hacky) script, with
one or two manual tweaks after the fact:

  import glob

  for path in glob.glob('nova/tests/**/*.py', recursive=True):
      with open(path) as fh:
          lines = fh.readlines()
      if 'import mock\n' not in lines:
          continue
      import_group_found = False
      create_first_party_group = False
      for num, line in enumerate(lines):
          line = line.strip()
          if line.startswith('import ') or line.startswith('from '):
              tokens = line.split()
              for lib in (
                  'ddt', 'six', 'webob', 'fixtures', 'testtools'
                  'neutron', 'cinder', 'ironic', 'keystone', 'oslo',
              ):
                  if lib in tokens[1]:
                      create_first_party_group = True
                      break
              if create_first_party_group:
                  break
              import_group_found = True
          if not import_group_found:
              continue
          if line.startswith('import ') or line.startswith('from '):
              tokens = line.split()
              if tokens[1] &gt; 'unittest':
                  break
              elif tokens[1] == 'unittest' and (
                  len(tokens) == 2 or tokens[4] &gt; 'mock'
              ):
                  break
          elif not line:
              break
      if create_first_party_group:
          lines.insert(num, 'from unittest import mock\n\n')
      else:
          lines.insert(num, 'from unittest import mock\n')
      del lines[lines.index('import mock\n')]
      with open(path, 'w+') as fh:
          fh.writelines(lines)

Note that we cannot remove mock from our requirements files yet due to
importing pypowervm unit test code in nova unit tests. This library
still uses the mock lib, and since we are importing test code and that
lib (correctly) only declares mock in its test-requirements.txt, mock
would not otherwise be installed and would cause errors while loading
nova unit test code.

[1] https://github.com/testing-cabal/fixtures/pull/49

Change-Id: Id5b04cf2f6ca24af8e366d23f15cf0e5cac8e1cc
Signed-off-by: Stephen Finucane &lt;stephenfin@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib. Most of this
is autogenerated, as described below, but there is one manual change
necessary:

nova/tests/functional/regressions/test_bug_1781286.py
  We need to avoid using 'fixtures.MockPatch' since fixtures is using
  'mock' (the library) under the hood and a call to 'mock.patch.stop'
  found in that test will now "stop" mocks from the wrong library. We
  have discussed making this configurable but the option proposed isn't
  that pretty [1] so this is better.

The remainder was auto-generated with the following (hacky) script, with
one or two manual tweaks after the fact:

  import glob

  for path in glob.glob('nova/tests/**/*.py', recursive=True):
      with open(path) as fh:
          lines = fh.readlines()
      if 'import mock\n' not in lines:
          continue
      import_group_found = False
      create_first_party_group = False
      for num, line in enumerate(lines):
          line = line.strip()
          if line.startswith('import ') or line.startswith('from '):
              tokens = line.split()
              for lib in (
                  'ddt', 'six', 'webob', 'fixtures', 'testtools'
                  'neutron', 'cinder', 'ironic', 'keystone', 'oslo',
              ):
                  if lib in tokens[1]:
                      create_first_party_group = True
                      break
              if create_first_party_group:
                  break
              import_group_found = True
          if not import_group_found:
              continue
          if line.startswith('import ') or line.startswith('from '):
              tokens = line.split()
              if tokens[1] &gt; 'unittest':
                  break
              elif tokens[1] == 'unittest' and (
                  len(tokens) == 2 or tokens[4] &gt; 'mock'
              ):
                  break
          elif not line:
              break
      if create_first_party_group:
          lines.insert(num, 'from unittest import mock\n\n')
      else:
          lines.insert(num, 'from unittest import mock\n')
      del lines[lines.index('import mock\n')]
      with open(path, 'w+') as fh:
          fh.writelines(lines)

Note that we cannot remove mock from our requirements files yet due to
importing pypowervm unit test code in nova unit tests. This library
still uses the mock lib, and since we are importing test code and that
lib (correctly) only declares mock in its test-requirements.txt, mock
would not otherwise be installed and would cause errors while loading
nova unit test code.

[1] https://github.com/testing-cabal/fixtures/pull/49

Change-Id: Id5b04cf2f6ca24af8e366d23f15cf0e5cac8e1cc
Signed-off-by: Stephen Finucane &lt;stephenfin@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge "Fix misuse of nova.objects.base.obj_equal_prims"</title>
<updated>2019-08-13T22:08:39+00:00</updated>
<author>
<name>Zuul</name>
<email>zuul@review.opendev.org</email>
</author>
<published>2019-08-13T22:08:39+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=878d68ea8fd3c848708a38a7086c57476e163a04'/>
<id>878d68ea8fd3c848708a38a7086c57476e163a04</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix misuse of nova.objects.base.obj_equal_prims</title>
<updated>2019-08-13T00:38:54+00:00</updated>
<author>
<name>Takashi NATSUME</name>
<email>natsume.takashi@lab.ntt.co.jp</email>
</author>
<published>2019-08-13T00:31:32+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=5c1d9dcbb29f5a84d56c4e496b3111b4040cad13'/>
<id>5c1d9dcbb29f5a84d56c4e496b3111b4040cad13</id>
<content type='text'>
The nova.objects.base.obj_equal_prims returns True or False.
It does not assert anything.
So the return value should be asserted in tests.

Add assertTrue where the nova.objects.base.obj_equal_prims is called.

Change-Id: I49460ec3b572ee14b32229e771a5499ff91e8722
Closes-Bug: #1839853
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The nova.objects.base.obj_equal_prims returns True or False.
It does not assert anything.
So the return value should be asserted in tests.

Add assertTrue where the nova.objects.base.obj_equal_prims is called.

Change-Id: I49460ec3b572ee14b32229e771a5499ff91e8722
Closes-Bug: #1839853
</pre>
</div>
</content>
</entry>
<entry>
<title>Add Instance.hidden field</title>
<updated>2019-08-07T21:56:01+00:00</updated>
<author>
<name>Matt Riedemann</name>
<email>mriedem.os@gmail.com</email>
</author>
<published>2019-01-15T23:32:44+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=2d2cfc4aa55ae023633600ad0a2445b0bc187024'/>
<id>2d2cfc4aa55ae023633600ad0a2445b0bc187024</id>
<content type='text'>
During a cross-cell move operation, an instance can
exist in multiple cell databases but can be mapped to
only one cell in the instances_mappings table in the API DB.
When listing servers out of the API, we need a way to
filter out hidden instances to make sure we return the
appropriate record. In other words, the cell with the
hidden instance should not be the one in the instance
mapping and should not be returned when listing instances.
Note that the API already filters out duplicates (see
_get_unique_filter_method in API.get_all) but this gives
us a way to control which is shown rather than get lucky.
The DB API method to list instances will filter out hidden
instances by default.

Quotas
======

Counting quota for instances, cores and ram has to be updated
to filter out hidden instances as well so we don't double
count usage for a hidden instance since we should count it
for the non-hidden copy of the instance in another cell DB.

Similarly, we filter hidden instances when counting server
group members (this required the change in the DB API
instance_get_all_by_filters_sort method to make that filter
work).

Functional tests are added for both quota scenarios.

REST API Filters and Sorting
============================

Note that this change does not add the ability to filter or
sort instances by the new hidden field in the REST API since
it's only used internally. There is no explicit blacklist
for this, but trying to sort on hidden will result in a 400
error because the field is not in VALID_SORT_KEYS. Filtering
on hidden will not result in an error because of the
additionalProperties=True in query_params_v21 but it will not
be passed through to the DB API either.

Part of blueprint cross-cell-resize

Change-Id: Iaffb27bd8c562ba120047c04bb62619c0864f594
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
During a cross-cell move operation, an instance can
exist in multiple cell databases but can be mapped to
only one cell in the instances_mappings table in the API DB.
When listing servers out of the API, we need a way to
filter out hidden instances to make sure we return the
appropriate record. In other words, the cell with the
hidden instance should not be the one in the instance
mapping and should not be returned when listing instances.
Note that the API already filters out duplicates (see
_get_unique_filter_method in API.get_all) but this gives
us a way to control which is shown rather than get lucky.
The DB API method to list instances will filter out hidden
instances by default.

Quotas
======

Counting quota for instances, cores and ram has to be updated
to filter out hidden instances as well so we don't double
count usage for a hidden instance since we should count it
for the non-hidden copy of the instance in another cell DB.

Similarly, we filter hidden instances when counting server
group members (this required the change in the DB API
instance_get_all_by_filters_sort method to make that filter
work).

Functional tests are added for both quota scenarios.

REST API Filters and Sorting
============================

Note that this change does not add the ability to filter or
sort instances by the new hidden field in the REST API since
it's only used internally. There is no explicit blacklist
for this, but trying to sort on hidden will result in a 400
error because the field is not in VALID_SORT_KEYS. Filtering
on hidden will not result in an error because of the
additionalProperties=True in query_params_v21 but it will not
be passed through to the DB API either.

Part of blueprint cross-cell-resize

Change-Id: Iaffb27bd8c562ba120047c04bb62619c0864f594
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix incompatible version handling in BuildRequest</title>
<updated>2019-01-17T08:18:20+00:00</updated>
<author>
<name>Balazs Gibizer</name>
<email>balazs.gibizer@ericsson.com</email>
</author>
<published>2019-01-16T09:57:07+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=975f0156137e37f7a9139c0268547d79dcc3c43c'/>
<id>975f0156137e37f7a9139c0268547d79dcc3c43c</id>
<content type='text'>
The BuildRequest object code assumed that IncompatibleObjectVersion
exception has a objver field that contains the object version. This
assumption is not true. The unit test made another mistake serializing
the function object obj_to_primitive instead of serializing the result
of the call of obj_to_primitive. This caused a false positive test
covering the error in the implementation as well.

Closes-Bug: #1812177

Change-Id: I1ef4a23aa2bf5cb46b481045f3d968f62f74606d
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The BuildRequest object code assumed that IncompatibleObjectVersion
exception has a objver field that contains the object version. This
assumption is not true. The unit test made another mistake serializing
the function object obj_to_primitive instead of serializing the result
of the call of obj_to_primitive. This caused a false positive test
covering the error in the implementation as well.

Closes-Bug: #1812177

Change-Id: I1ef4a23aa2bf5cb46b481045f3d968f62f74606d
</pre>
</div>
</content>
</entry>
<entry>
<title>Use uuidsentinel from oslo.utils</title>
<updated>2018-09-05T14:08:54+00:00</updated>
<author>
<name>Eric Fried</name>
<email>efried@us.ibm.com</email>
</author>
<published>2018-09-05T14:08:54+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=8e1ca5bf34f924b9a23ddbcf31ae727a7dcacb20'/>
<id>8e1ca5bf34f924b9a23ddbcf31ae727a7dcacb20</id>
<content type='text'>
oslo.utils release 3.37.0 [1] introduced uuidsentinel [2]. This change
rips out nova's uuidsentinel and replaces it with the one from
oslo.utils.

[1] https://review.openstack.org/#/c/599754/
[2] https://review.openstack.org/#/c/594179/

Change-Id: I7f5f08691ca3f73073c66c29dddb996fb2c2b266
Depends-On: https://review.openstack.org/600041
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
oslo.utils release 3.37.0 [1] introduced uuidsentinel [2]. This change
rips out nova's uuidsentinel and replaces it with the one from
oslo.utils.

[1] https://review.openstack.org/#/c/599754/
[2] https://review.openstack.org/#/c/594179/

Change-Id: I7f5f08691ca3f73073c66c29dddb996fb2c2b266
Depends-On: https://review.openstack.org/600041
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix all invalid obj_make_compatible test case</title>
<updated>2018-07-27T02:20:46+00:00</updated>
<author>
<name>Yikun Jiang</name>
<email>yikunkero@gmail.com</email>
</author>
<published>2018-06-11T12:30:55+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=4729fa819675ca511fe0027950d9aadf0aebef1b'/>
<id>4729fa819675ca511fe0027950d9aadf0aebef1b</id>
<content type='text'>
We use obj_to_primitive() to generate the primitive obj, the
origin obj value is primitive['nova_object.data'], so, we need
transfer primitive to obj data before obj_make_compatible
called.

This patch fixed all invalid obj_make_compatible test cases.

Closes-Bug: #1776373

Change-Id: I048b22b2447b671228a7ba067e06c59b59e81ce5
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We use obj_to_primitive() to generate the primitive obj, the
origin obj value is primitive['nova_object.data'], so, we need
transfer primitive to obj data before obj_make_compatible
called.

This patch fixed all invalid obj_make_compatible test cases.

Closes-Bug: #1776373

Change-Id: I048b22b2447b671228a7ba067e06c59b59e81ce5
</pre>
</div>
</content>
</entry>
<entry>
<title>Add tags to instance.create Notification</title>
<updated>2017-07-24T22:05:05+00:00</updated>
<author>
<name>Kevin_Zheng</name>
<email>zhengzhenyu@huawei.com</email>
</author>
<published>2017-04-21T08:43:48+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=f665565d694a1e362c0e2fa6c40ee9849b68e777'/>
<id>f665565d694a1e362c0e2fa6c40ee9849b68e777</id>
<content type='text'>
This patch added a new field 'tags' to InstanceCreatePayload.

Partial-implement: bp additional-notification-fields-for-searchlight
Partial-implement: blueprint support-tag-instance-when-boot

Change-Id: Iefaa9da4e136fd5e823bf7b11c8aa5b4cd6d7de8
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch added a new field 'tags' to InstanceCreatePayload.

Partial-implement: bp additional-notification-fields-for-searchlight
Partial-implement: blueprint support-tag-instance-when-boot

Change-Id: Iefaa9da4e136fd5e823bf7b11c8aa5b4cd6d7de8
</pre>
</div>
</content>
</entry>
<entry>
<title>Support tag instances when boot(2/4)</title>
<updated>2017-06-06T06:16:41+00:00</updated>
<author>
<name>Kevin_Zheng</name>
<email>zhengzhenyu@huawei.com</email>
</author>
<published>2017-04-25T07:29:36+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=18c61263a3c0344a79b3d86dcce9ac2a7824fca9'/>
<id>18c61263a3c0344a79b3d86dcce9ac2a7824fca9</id>
<content type='text'>
This is the second patch of the series,
this patch adds tags to build_request
object.

Change-Id: I1121eaf24856dcb74f07c224531a821b3cdc46fc
Part of blueprint support-tag-instance-when-boot
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is the second patch of the series,
this patch adds tags to build_request
object.

Change-Id: I1121eaf24856dcb74f07c224531a821b3cdc46fc
Part of blueprint support-tag-instance-when-boot
</pre>
</div>
</content>
</entry>
<entry>
<title>Default deleted if the instance from BuildRequest is not having it</title>
<updated>2016-11-28T17:36:53+00:00</updated>
<author>
<name>Sylvain Bauza</name>
<email>sbauza@redhat.com</email>
</author>
<published>2016-11-28T17:36:53+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=37ec9b99c7ca85467f5d274505e86436d86657dc'/>
<id>37ec9b99c7ca85467f5d274505e86436d86657dc</id>
<content type='text'>
We should already have the rehydrated instance having the deleted field being
set. That field is also a BooleanField type, so we should never try to cast it
from an integer (even if we support it). Instead, we need to make sure that if
the field is not set for any reason (mostly because an Instance wasn't persisted
before we persisted the BuildRequest object that was nesting it), then we would
default the deleted field to False.

Change-Id: I828191f750a5978fed65a86e797388d11042b4a0
Related-Bug: #1644513
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We should already have the rehydrated instance having the deleted field being
set. That field is also a BooleanField type, so we should never try to cast it
from an integer (even if we support it). Instead, we need to make sure that if
the field is not set for any reason (mostly because an Instance wasn't persisted
before we persisted the BuildRequest object that was nesting it), then we would
default the deleted field to False.

Change-Id: I828191f750a5978fed65a86e797388d11042b4a0
Related-Bug: #1644513
</pre>
</div>
</content>
</entry>
</feed>
