Byte encoding of member Id
From stein we will be porting to python3. To deal with that, when calling for class PartitionCoordinator the member id need to be encoded in byte format otherwise it raises MemberNotInGroupError exception. Closes-Bug: https://storyboard.openstack.org/#!/story/2005894 Change-Id: Idee3216c7c1b4f6391d08649637e619ba1a0ac13
This commit is contained in:
parent
83fb96463c
commit
9c9112ad1f
@ -18,6 +18,7 @@ import struct
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
import tenacity
|
||||
@ -114,7 +115,8 @@ class PartitionCoordinator(object):
|
||||
self.backend_url = self.conf.coordination.backend_url
|
||||
self._coordinator = None
|
||||
self._groups = set()
|
||||
self._my_id = my_id or uuidutils.generate_uuid()
|
||||
self._my_id = my_id or \
|
||||
encodeutils.safe_encode(uuidutils.generate_uuid())
|
||||
|
||||
def start(self):
|
||||
if self.backend_url:
|
||||
|
@ -193,6 +193,11 @@ class TestPartitioning(base.BaseTestCase):
|
||||
self.assertEqual(['group1', 'group2'],
|
||||
sorted(self.shared_storage.keys()))
|
||||
|
||||
def test_member_id(self):
|
||||
agent = 'agent'.encode('ascii')
|
||||
coord = self._get_new_started_coordinator({}, agent)
|
||||
self.assertEqual(agent, coord._my_id)
|
||||
|
||||
def test_partitioning(self):
|
||||
all_resources = ['resource_%s' % i for i in range(1000)]
|
||||
agents = ['agent_%s' % i for i in range(10)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user