runtest.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:ray 作者: ray-project 项目源码 文件源码
def testObjectTableAddAndRemove(self):
        # Try removing a manager from an object ID that has not been added yet.
        with self.assertRaises(redis.ResponseError):
            self.redis.execute_command("RAY.OBJECT_TABLE_REMOVE", "object_id1",
                                       "manager_id1")
        # Try calling RAY.OBJECT_TABLE_LOOKUP with an object ID that has not
        # been added yet.
        response = self.redis.execute_command("RAY.OBJECT_TABLE_LOOKUP",
                                              "object_id1")
        self.assertEqual(response, None)
        # Add some managers and try again.
        self.redis.execute_command("RAY.OBJECT_TABLE_ADD", "object_id1", 1,
                                   "hash1", "manager_id1")
        self.redis.execute_command("RAY.OBJECT_TABLE_ADD", "object_id1", 1,
                                   "hash1", "manager_id2")
        response = self.redis.execute_command("RAY.OBJECT_TABLE_LOOKUP",
                                              "object_id1")
        self.assertEqual(set(response), {b"manager_id1", b"manager_id2"})
        # Remove a manager that doesn't exist, and make sure we still have the
        # same set.
        self.redis.execute_command("RAY.OBJECT_TABLE_REMOVE", "object_id1",
                                   "manager_id3")
        response = self.redis.execute_command("RAY.OBJECT_TABLE_LOOKUP",
                                              "object_id1")
        self.assertEqual(set(response), {b"manager_id1", b"manager_id2"})
        # Remove a manager that does exist. Make sure it gets removed the first
        # time and does nothing the second time.
        self.redis.execute_command("RAY.OBJECT_TABLE_REMOVE", "object_id1",
                                   "manager_id1")
        response = self.redis.execute_command("RAY.OBJECT_TABLE_LOOKUP",
                                              "object_id1")
        self.assertEqual(set(response), {b"manager_id2"})
        self.redis.execute_command("RAY.OBJECT_TABLE_REMOVE", "object_id1",
                                   "manager_id1")
        response = self.redis.execute_command("RAY.OBJECT_TABLE_LOOKUP",
                                              "object_id1")
        self.assertEqual(set(response), {b"manager_id2"})
        # Remove the last manager, and make sure we have an empty set.
        self.redis.execute_command("RAY.OBJECT_TABLE_REMOVE", "object_id1",
                                   "manager_id2")
        response = self.redis.execute_command("RAY.OBJECT_TABLE_LOOKUP",
                                              "object_id1")
        self.assertEqual(set(response), set())
        # Remove a manager from an empty set, and make sure we now have an
        # empty set.
        self.redis.execute_command("RAY.OBJECT_TABLE_REMOVE", "object_id1",
                                   "manager_id3")
        response = self.redis.execute_command("RAY.OBJECT_TABLE_LOOKUP",
                                              "object_id1")
        self.assertEqual(set(response), set())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号