<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/openstack/nova.git/nova/tests/functional/db/test_instance_group.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>db: Move remaining 'nova.db.sqlalchemy' modules</title>
<updated>2021-08-09T14:34:40+00:00</updated>
<author>
<name>Stephen Finucane</name>
<email>stephenfin@redhat.com</email>
</author>
<published>2021-02-13T17:18:53+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=bf8b5fc7d05e0a66031a03e50e8f6bb76a921046'/>
<id>bf8b5fc7d05e0a66031a03e50e8f6bb76a921046</id>
<content type='text'>
The two remaining modules, 'api_models' and 'api_migrations', are
moved to the new 'nova.db.api' module.

Change-Id: I138670fe36b07546db5518f78c657197780c5040
Signed-off-by: Stephen Finucane &lt;stephenfin@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The two remaining modules, 'api_models' and 'api_migrations', are
moved to the new 'nova.db.api' module.

Change-Id: I138670fe36b07546db5518f78c657197780c5040
Signed-off-by: Stephen Finucane &lt;stephenfin@redhat.com&gt;
</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>Add policy to InstanceGroup object</title>
<updated>2018-07-12T01:30:41+00:00</updated>
<author>
<name>Yikun Jiang</name>
<email>yikunkero@gmail.com</email>
</author>
<published>2018-06-29T13:10:11+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=8fa70e5dfc73e52d52c94ec2781ff185fdcca481'/>
<id>8fa70e5dfc73e52d52c94ec2781ff185fdcca481</id>
<content type='text'>
The change items in this patch as below:
1. Add policy and rules to InstanceGroup, deprecate
the policies field.
2. Also, make _from_db_object and _create_in_db method to
support new "policy" field.

The internal usage of InstanceGroup.policies is converted to
use the new model in the REST API and RequestSpec compat code.

Related to blueprint complex-anti-affinity-policies

Change-Id: Ib33719a4b9599d86848c618a6e142c71ece79ca5
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The change items in this patch as below:
1. Add policy and rules to InstanceGroup, deprecate
the policies field.
2. Also, make _from_db_object and _create_in_db method to
support new "policy" field.

The internal usage of InstanceGroup.policies is converted to
use the new model in the REST API and RequestSpec compat code.

Related to blueprint complex-anti-affinity-policies

Change-Id: Ib33719a4b9599d86848c618a6e142c71ece79ca5
</pre>
</div>
</content>
</entry>
<entry>
<title>Refactor policies to policy in InstanceGroup DB model</title>
<updated>2018-07-09T17:15:48+00:00</updated>
<author>
<name>Yikun Jiang</name>
<email>yikunkero@gmail.com</email>
</author>
<published>2018-06-29T10:09:26+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=afc7650e64753ab7687ae2c4f2714d4bb78a4e5a'/>
<id>afc7650e64753ab7687ae2c4f2714d4bb78a4e5a</id>
<content type='text'>
A group can only have 1 policy associated it, but now we have
ONE to MANY model in group model, this patch change it to ONE
to ONE Model.

We also adapt create method to new model, and remove policy
update support in group.save because now we don't support to
update a policy of the group.

Related to blueprint complex-anti-affinity-policies

Change-Id: I95eb1c8470a567408696132ae656305be53dc5bb
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A group can only have 1 policy associated it, but now we have
ONE to MANY model in group model, this patch change it to ONE
to ONE Model.

We also adapt create method to new model, and remove policy
update support in group.save because now we don't support to
update a policy of the group.

Related to blueprint complex-anti-affinity-policies

Change-Id: I95eb1c8470a567408696132ae656305be53dc5bb
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove compatibility code for instance groups</title>
<updated>2018-06-27T14:09:55+00:00</updated>
<author>
<name>Matt Riedemann</name>
<email>mriedem.os@gmail.com</email>
</author>
<published>2018-06-26T20:06:20+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=1160921c2d053ce33279ca4ec1f00572271e7c95'/>
<id>1160921c2d053ce33279ca4ec1f00572271e7c95</id>
<content type='text'>
The /345_require_online_migration_completion cell database
migration added in Ocata prevents anyone from upgrading
the cell database schema until they have performed the online
instance group data migrations via the
"nova-manage db online_data_migrations" command.

This means we can remove the compatibility code in the InstanceGroup
object which performs a lookup routine in the API database and
if not found it falls back to the cell database, which at this
point should be empty, therefore making that dead code now.

The test_get_by_name and test_get_by_hint tests are moved
from _TestInstanceGroupListObject to _TestInstanceGroupObject
since they don't have anything to do with InstanceGroupList.

A follow up change will remove the now unused main DB API
methods for instance groups.

Change-Id: Ifbd53b13fa0fef62e0329283b73d587f367e46c2
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The /345_require_online_migration_completion cell database
migration added in Ocata prevents anyone from upgrading
the cell database schema until they have performed the online
instance group data migrations via the
"nova-manage db online_data_migrations" command.

This means we can remove the compatibility code in the InstanceGroup
object which performs a lookup routine in the API database and
if not found it falls back to the cell database, which at this
point should be empty, therefore making that dead code now.

The test_get_by_name and test_get_by_hint tests are moved
from _TestInstanceGroupListObject to _TestInstanceGroupObject
since they don't have anything to do with InstanceGroupList.

A follow up change will remove the now unused main DB API
methods for instance groups.

Change-Id: Ifbd53b13fa0fef62e0329283b73d587f367e46c2
</pre>
</div>
</content>
</entry>
<entry>
<title>Add InstanceGroup._remove_members_in_db</title>
<updated>2017-06-08T21:01:08+00:00</updated>
<author>
<name>melanie witt</name>
<email>melwittt@gmail.com</email>
</author>
<published>2017-03-30T17:15:37+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=0a2360d34920f918a0cdb3f1b2fa9e8385fcfafc'/>
<id>0a2360d34920f918a0cdb3f1b2fa9e8385fcfafc</id>
<content type='text'>
This adds a method for removing server group members from the database.
It's private because we don't expose a way to remove server group
members in the API and it's only needed to handle races near the quota
limit. To handle races, we will check quota limits, create group
members in the database, then check quota again. If the quota limits
have been exceeded after creation of the group members, they will
be removed from the database and OverQuota will be raised.

Part of blueprint cells-count-resources-to-check-quota-in-api

Change-Id: I8cda7a1503750f6b23919a6fbf7bb40c84ac582b
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This adds a method for removing server group members from the database.
It's private because we don't expose a way to remove server group
members in the API and it's only needed to handle races near the quota
limit. To handle races, we will check quota limits, create group
members in the database, then check quota again. If the quota limits
have been exceeded after creation of the group members, they will
be removed from the database and OverQuota will be raised.

Part of blueprint cells-count-resources-to-check-quota-in-api

Change-Id: I8cda7a1503750f6b23919a6fbf7bb40c84ac582b
</pre>
</div>
</content>
</entry>
<entry>
<title>Add InstanceGroupList.get_counts()</title>
<updated>2017-06-06T23:15:49+00:00</updated>
<author>
<name>melanie witt</name>
<email>melwittt@gmail.com</email>
</author>
<published>2017-03-30T17:15:02+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=a1968048340a6a5a64ffcc50ff6bccbd33b3fa8f'/>
<id>a1968048340a6a5a64ffcc50ff6bccbd33b3fa8f</id>
<content type='text'>
This adds a method for getting counts of server groups in the database
for checking quota.

Part of blueprint cells-count-resources-to-check-quota-in-api

Change-Id: I9eadf93b432630607069cdf8ec1915920e32b905
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This adds a method for getting counts of server groups in the database
for checking quota.

Part of blueprint cells-count-resources-to-check-quota-in-api

Change-Id: I9eadf93b432630607069cdf8ec1915920e32b905
</pre>
</div>
</content>
</entry>
<entry>
<title>Add online migration to move instance groups to API database</title>
<updated>2016-08-22T10:50:24+00:00</updated>
<author>
<name>melanie witt</name>
<email>melwittt@gmail.com</email>
</author>
<published>2016-06-23T03:46:50+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=d35e1577c9510827b2a4802a294714340ccdee7c'/>
<id>d35e1577c9510827b2a4802a294714340ccdee7c</id>
<content type='text'>
This moves instance groups from the main database to the API database
in an online migration.

Part of blueprint cells-instance-groups-api-db

Change-Id: I946767509903c76e9089bda02e24d964e383b91c
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This moves instance groups from the main database to the API database
in an online migration.

Part of blueprint cells-instance-groups-api-db

Change-Id: I946767509903c76e9089bda02e24d964e383b91c
</pre>
</div>
</content>
</entry>
<entry>
<title>Make InstanceGroup object favor the API database</title>
<updated>2016-08-19T17:46:19+00:00</updated>
<author>
<name>melanie witt</name>
<email>melwittt@gmail.com</email>
</author>
<published>2016-06-17T09:31:05+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=c5c4f71aa0963ddd808bbcf755bc9ac675cf2755'/>
<id>c5c4f71aa0963ddd808bbcf755bc9ac675cf2755</id>
<content type='text'>
This makes the InstanceGroup object load first from the API database,
falling back to the main database as necessary. Creates happen in the
API database only now.

Part of blueprint cells-instance-groups-api-db

Change-Id: I2fe7524818e92a4d9a55f84633e70091a42531ea
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This makes the InstanceGroup object load first from the API database,
falling back to the main database as necessary. Creates happen in the
API database only now.

Part of blueprint cells-instance-groups-api-db

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