<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/openstack/nova.git/nova/tests/unit/cmd/test_nova_api.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>Fix wrong unit test about config option enabled_apis</title>
<updated>2017-03-24T02:28:24+00:00</updated>
<author>
<name>ChangBo Guo(gcb)</name>
<email>eric.guo@easystack.cn</email>
</author>
<published>2017-03-17T08:14:26+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=36af34a1537bbfc30a8e124bfc82c4650a31c8d3'/>
<id>36af34a1537bbfc30a8e124bfc82c4650a31c8d3</id>
<content type='text'>
Accorrding to declaration of config option 'enabled_apis'[1],
it only allows values from ['osapi_compute', 'metadata'], otherwise
a ValueError will be raised when use its value.

oslo.config will land patch "Fix conversion to item_type on __call__ in
List type" again[2], which was reverted due to Nova test failure.

This commit will adjust Nova unit test to make the config option be
used as expected: only accept valid values in unit test.

[1] https://github.com/openstack/nova/blob/abb33a457738c12cb538a874a6627777dfd46b8b/nova/conf/service.py#L84
[2] https://review.openstack.org/#/c/398335

Change-Id: I61983d34269a44940bbb99783143767cf4c97cb1
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Accorrding to declaration of config option 'enabled_apis'[1],
it only allows values from ['osapi_compute', 'metadata'], otherwise
a ValueError will be raised when use its value.

oslo.config will land patch "Fix conversion to item_type on __call__ in
List type" again[2], which was reverted due to Nova test failure.

This commit will adjust Nova unit test to make the config option be
used as expected: only accept valid values in unit test.

[1] https://github.com/openstack/nova/blob/abb33a457738c12cb538a874a6627777dfd46b8b/nova/conf/service.py#L84
[2] https://review.openstack.org/#/c/398335

Change-Id: I61983d34269a44940bbb99783143767cf4c97cb1
</pre>
</div>
</content>
</entry>
<entry>
<title>Device tagging API support</title>
<updated>2016-06-30T03:55:16+00:00</updated>
<author>
<name>Artom Lifshitz</name>
<email>alifshit@redhat.com</email>
</author>
<published>2016-06-28T21:28:48+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=e83e114e1b00ec882276380be2331bebc79c833b'/>
<id>e83e114e1b00ec882276380be2331bebc79c833b</id>
<content type='text'>
This patch allows the user to specify a tag for a virtual network
interface and/or block device mapping when booting an instance.

Implements: blueprint bp/virt-device-role-tagging
Change-Id: I89247200f4cf1f644daf476727b4a6acb22b0cf6
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch allows the user to specify a tag for a virtual network
interface and/or block device mapping when booting an instance.

Implements: blueprint bp/virt-device-role-tagging
Change-Id: I89247200f4cf1f644daf476727b4a6acb22b0cf6
</pre>
</div>
</content>
</entry>
<entry>
<title>Fail to start nova-api if no APIs were able to be started</title>
<updated>2016-05-03T14:51:40+00:00</updated>
<author>
<name>Dan Smith</name>
<email>dansmith@redhat.com</email>
</author>
<published>2016-04-22T21:22:08+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=9b2329d10021a7fa5f43b9fd8be3c833dd7212d0'/>
<id>9b2329d10021a7fa5f43b9fd8be3c833dd7212d0</id>
<content type='text'>
This helps to make it clear that either you specified no API services,
or you specified all bad ones, or that you fat-fingered the thing
entirely. If we can't start any, we shouldn't start the process acting
like we did and then wait for you to figure out the hard way that we
aren't actually listening for any requests.

Change-Id: I864486a58cf3fde35647ae3b8d2ad917c809ea54
Related-Bug: #1572495
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This helps to make it clear that either you specified no API services,
or you specified all bad ones, or that you fat-fingered the thing
entirely. If we can't start any, we shouldn't start the process acting
like we did and then wait for you to figure out the hard way that we
aren't actually listening for any requests.

Change-Id: I864486a58cf3fde35647ae3b8d2ad917c809ea54
Related-Bug: #1572495
</pre>
</div>
</content>
</entry>
<entry>
<title>Test that nova-api ignores paste failures, but continues on</title>
<updated>2016-05-03T14:51:33+00:00</updated>
<author>
<name>Dan Smith</name>
<email>dansmith@redhat.com</email>
</author>
<published>2016-04-22T21:15:14+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=8182a550433c2db901ae9b926d8a44a1e23ad380'/>
<id>8182a550433c2db901ae9b926d8a44a1e23ad380</id>
<content type='text'>
Change-Id: I3232016c61f7a598d15b9e8a11a9975f5cfad3d0
Related-Bug: #1572495
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Change-Id: I3232016c61f7a598d15b9e8a11a9975f5cfad3d0
Related-Bug: #1572495
</pre>
</div>
</content>
</entry>
<entry>
<title>Prevent nova-api from dying if enabled_apis is wrong</title>
<updated>2016-04-22T18:41:10+00:00</updated>
<author>
<name>Sean Dague</name>
<email>sean@dague.net</email>
</author>
<published>2016-04-20T10:53:18+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=533bd8175968a1bc9ac068ae2b23a62d0e07ea99'/>
<id>533bd8175968a1bc9ac068ae2b23a62d0e07ea99</id>
<content type='text'>
This prevents nova-api from dying if there are values in
``enabled_apis`` which don't actually exist.

Closes-Bug: #1572495

Change-Id: Id9a6f5e38b017f4687eb245fd238104379d437d6
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This prevents nova-api from dying if there are values in
``enabled_apis`` which don't actually exist.

Closes-Bug: #1572495

Change-Id: Id9a6f5e38b017f4687eb245fd238104379d437d6
</pre>
</div>
</content>
</entry>
</feed>
