<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/openstack/nova.git/nova/tests/unit/virt/test_imagecache.py, branch master</title>
<subtitle>opendev.org: openstack/nova.git
</subtitle>
<link rel='alternate' type='text/html' href='http://trove.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://trove.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>Fix typos</title>
<updated>2022-05-30T12:10:00+00:00</updated>
<author>
<name>Rajesh Tailor</name>
<email>ratailor@redhat.com</email>
</author>
<published>2022-05-23T11:26:20+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openstack/nova.git/commit/?id=2521810e553593f8d02adeef0f089b60bc7f71a6'/>
<id>2521810e553593f8d02adeef0f089b60bc7f71a6</id>
<content type='text'>
This change fixes some of the typos in unit tests as well
as in nova code-base.

Change-Id: I209bbb270baf889fcb2b9a4d1ce0ab4a962d0d0e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This change fixes some of the typos in unit tests as well
as in nova code-base.

Change-Id: I209bbb270baf889fcb2b9a4d1ce0ab4a962d0d0e
</pre>
</div>
</content>
</entry>
<entry>
<title>Include removal of ephemeral backing files in the image cache manager</title>
<updated>2020-10-09T11:24:06+00:00</updated>
<author>
<name>Surya Seetharaman</name>
<email>suryaseetharaman.9@gmail.com</email>
</author>
<published>2019-10-18T10:41:02+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openstack/nova.git/commit/?id=f44700935ff4cab7a36cc06356aefcf4c9b48880'/>
<id>f44700935ff4cab7a36cc06356aefcf4c9b48880</id>
<content type='text'>
If CONF.image_cache.remove_unused_base_images is True, the base and
swap files are removed during the image cache manager's periodic
task while the ephemeral backing files are never deleted. This is a
long standing bug and this patch proposes to remove the ephemeral
backing files in the same way as for the swap files.

Change-Id: Ibf722265a4450fb81d40dee635667e39bc5b3edc
Closes-bug: #1602193
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If CONF.image_cache.remove_unused_base_images is True, the base and
swap files are removed during the image cache manager's periodic
task while the ephemeral backing files are never deleted. This is a
long standing bug and this patch proposes to remove the ephemeral
backing files in the same way as for the swap files.

Change-Id: Ibf722265a4450fb81d40dee635667e39bc5b3edc
Closes-bug: #1602193
</pre>
</div>
</content>
</entry>
<entry>
<title>Consolidate [image_cache] conf options</title>
<updated>2019-11-13T17:09:03+00:00</updated>
<author>
<name>Eric Fried</name>
<email>openstack@fried.cc</email>
</author>
<published>2019-10-23T19:41:36+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openstack/nova.git/commit/?id=828e8047e5c8651ea757bda7922670889d5e8818'/>
<id>828e8047e5c8651ea757bda7922670889d5e8818</id>
<content type='text'>
Blueprint image-precache-support added a conf section called
[image_cache], so it makes sense to move all the existing image
cache-related conf options into it.

Old:
[DEFAULT]image_cache_manager_interval
[DEFAULT]image_cache_subdirectory_name
[DEFAULT]remove_unused_base_images
[DEFAULT]remove_unused_original_minimum_age_seconds
[libvirt]remove_unused_resized_minimum_age_seconds

New:
[image_cache]manager_interval
[image_cache]subdirectory_name
[image_cache]remove_unused_base_images
[image_cache]remove_unused_original_minimum_age_seconds
[image_cache]remove_unused_resized_minimum_age_seconds

Change-Id: I3c49825ac0d70152b6c8ee4c8ca01546265f4b80
Partial-Bug: #1847302
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Blueprint image-precache-support added a conf section called
[image_cache], so it makes sense to move all the existing image
cache-related conf options into it.

Old:
[DEFAULT]image_cache_manager_interval
[DEFAULT]image_cache_subdirectory_name
[DEFAULT]remove_unused_base_images
[DEFAULT]remove_unused_original_minimum_age_seconds
[libvirt]remove_unused_resized_minimum_age_seconds

New:
[image_cache]manager_interval
[image_cache]subdirectory_name
[image_cache]remove_unused_base_images
[image_cache]remove_unused_original_minimum_age_seconds
[image_cache]remove_unused_resized_minimum_age_seconds

Change-Id: I3c49825ac0d70152b6c8ee4c8ca01546265f4b80
Partial-Bug: #1847302
</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://trove.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>Remove mox from tests/unit/virt/test_imagecache.py</title>
<updated>2016-06-16T23:40:01+00:00</updated>
<author>
<name>Sujitha</name>
<email>sujitha.neti@intel.com</email>
</author>
<published>2016-04-12T18:38:53+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openstack/nova.git/commit/?id=b726a1269cec06183c84a7f645866a45d9d4898e'/>
<id>b726a1269cec06183c84a7f645866a45d9d4898e</id>
<content type='text'>
This patch replaces mox with mock in
tests/unit/virt/test_imagecache.py.

Part of blueprint remove-mox-newton

Change-Id: Ia1db65f912bdff10c53add0b93cb01516ead9c54
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch replaces mox with mock in
tests/unit/virt/test_imagecache.py.

Part of blueprint remove-mox-newton

Change-Id: Ia1db65f912bdff10c53add0b93cb01516ead9c54
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix invalid uuid warnings in virt testcases</title>
<updated>2016-06-02T12:54:12+00:00</updated>
<author>
<name>srushti</name>
<email>srushti.gadadare@nttdata.com</email>
</author>
<published>2016-04-06T05:46:56+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openstack/nova.git/commit/?id=7c10322b1738da90ecd3687dd49277f9e18a18e5'/>
<id>7c10322b1738da90ecd3687dd49277f9e18a18e5</id>
<content type='text'>
Currently, unit testcases of virt emit FutureWarnings
from oslo.versionedobjects about invalid uuids as documented here[1].

This commit changes these tests to use valid uuids so
that when they are run these warnings are no longer emitted.

Fake constants are defined for project_id and user_id as they
are used without '-' at keystone side.

[1] http://docs.openstack.org/developer/oslo.versionedobjects/api/fields.html#oslo_versionedobjects.fields.UUIDField

Partial-Bug: #1557378
Change-Id: If69412eddb5e64cb8ccc5dce9176d19382c0b3f1
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently, unit testcases of virt emit FutureWarnings
from oslo.versionedobjects about invalid uuids as documented here[1].

This commit changes these tests to use valid uuids so
that when they are run these warnings are no longer emitted.

Fake constants are defined for project_id and user_id as they
are used without '-' at keystone side.

[1] http://docs.openstack.org/developer/oslo.versionedobjects/api/fields.html#oslo_versionedobjects.fields.UUIDField

Partial-Bug: #1557378
Change-Id: If69412eddb5e64cb8ccc5dce9176d19382c0b3f1
</pre>
</div>
</content>
</entry>
<entry>
<title>Rename ImageCacheManager._list_base_images to _scan_base_images</title>
<updated>2016-05-26T13:45:42+00:00</updated>
<author>
<name>Matthew Booth</name>
<email>mbooth@redhat.com</email>
</author>
<published>2016-05-26T09:06:54+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openstack/nova.git/commit/?id=cb15d34cc1caf980c636eace5cae0be2b1b5108f'/>
<id>cb15d34cc1caf980c636eace5cae0be2b1b5108f</id>
<content type='text'>
The method's return value is never used, only its side-effects are
used. We rename it to reflect its actual usage, and remove the unused
return value to avoid confusion.

NOTE(mdbooth): The use of global state is a large part of what makes
ImageCacheManager hard to read. I don't mean to imply with this change
that's what should be done here, only to make it clearer to the reader
that it is what's being done currently.

Change-Id: Ic82f6d4f00fd1226673750538019339937a623bc
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The method's return value is never used, only its side-effects are
used. We rename it to reflect its actual usage, and remove the unused
return value to avoid confusion.

NOTE(mdbooth): The use of global state is a large part of what makes
ImageCacheManager hard to read. I don't mean to imply with this change
that's what should be done here, only to make it clearer to the reader
that it is what's being done currently.

Change-Id: Ic82f6d4f00fd1226673750538019339937a623bc
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove all references to image_popularity from image cache</title>
<updated>2016-05-26T13:44:51+00:00</updated>
<author>
<name>Matthew Booth</name>
<email>mbooth@redhat.com</email>
</author>
<published>2016-05-26T09:28:33+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openstack/nova.git/commit/?id=d661db6a990138125db27aff757181a5ba9e971b'/>
<id>d661db6a990138125db27aff757181a5ba9e971b</id>
<content type='text'>
Nothing ever reads it.

Change-Id: Ieeb068b992263cf0208c2d8dc3a8d6f0683bf18c
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Nothing ever reads it.

Change-Id: Ieeb068b992263cf0208c2d8dc3a8d6f0683bf18c
</pre>
</div>
</content>
</entry>
<entry>
<title>config options: Centralise 'virt.imagecache' options</title>
<updated>2016-03-30T11:47:53+00:00</updated>
<author>
<name>Stephen Finucane</name>
<email>stephen.finucane@intel.com</email>
</author>
<published>2016-01-14T10:44:05+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openstack/nova.git/commit/?id=1154923f8e218162222353b40e1ada9e664e40ef'/>
<id>1154923f8e218162222353b40e1ada9e664e40ef</id>
<content type='text'>
Add options from 'virt.imagecache'. These options are part of the
'DEFAULT' group but are included in the "nova.conf.virt" file in hope
that they can eventually be moved to their own group.

Change-Id: I0e683c08b0479e41487c6b05de7d588f5d88ad0e
Implements: bp centralize-config-options-newton
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add options from 'virt.imagecache'. These options are part of the
'DEFAULT' group but are included in the "nova.conf.virt" file in hope
that they can eventually be moved to their own group.

Change-Id: I0e683c08b0479e41487c6b05de7d588f5d88ad0e
Implements: bp centralize-config-options-newton
</pre>
</div>
</content>
</entry>
</feed>
