Make sure zmq can work with redis

In ZmqDriver's listen method, it calls create_consumer
three times. After the first call, the keys related to this
topic in redis reads like this:
  "topic": set(["topic.host"])
  "topic.host": ""

If the second call, it tries to add the following keys:
  "topic.host": set(["topic.host.host"])
  "topic.host.host": ""

But the key "topic.host" already exists as a string type.
So the error occurs.

To resolve this problem, change the value of keys from string
to set.

Change-Id: Ic801393d492d2656fcfd8b87f1d2efc6ab3bbd62
Closes-Bug: #1290772
This commit is contained in:
zhangjl 2014-12-17 16:04:14 +08:00
parent e55a83e832
commit 8eed6bbd09
2 changed files with 6 additions and 1 deletions

View File

@ -127,7 +127,7 @@ class MatchMakerRedis(mm_common.HeartbeatMatchMakerBase):
# No value is needed, we just
# care if it exists. Sets aren't viable
# because only keys can expire.
pipe.set(key_host, '')
pipe.sadd(key_host, '')
pipe.execute()

View File

@ -46,6 +46,7 @@ class RedisMatchMakerTest(test_utils.BaseTestCase):
"network": ["controller1", "node1", "node2", "node3"],
"cert": ["controller1"],
"console": ["controller1"],
"l3_agent.node1": ["node1"],
"consoleauth": ["controller1"]}
self.matcher = matchmaker_redis.MatchMakerRedis()
self.populate()
@ -70,6 +71,10 @@ class RedisMatchMakerTest(test_utils.BaseTestCase):
self.assertEqual(
sorted(self.matcher.redis.smembers('cert')),
['cert.controller1', 'cert.keymaster'])
self.matcher.register('l3_agent.node1', 'node1')
self.assertEqual(
sorted(self.matcher.redis.smembers('l3_agent.node1')),
['l3_agent.node1.node1'])
def test_unregister(self):
self.matcher.unregister('conductor', 'controller1')