runtest.py 文件源码

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

项目:ray 作者: ray-project 项目源码 文件源码
def testInvalidObjectTableAdd(self):
        # Check that Redis returns an error when RAY.OBJECT_TABLE_ADD is called
        # with the wrong arguments.
        with self.assertRaises(redis.ResponseError):
            self.redis.execute_command("RAY.OBJECT_TABLE_ADD")
        with self.assertRaises(redis.ResponseError):
            self.redis.execute_command("RAY.OBJECT_TABLE_ADD", "hello")
        with self.assertRaises(redis.ResponseError):
            self.redis.execute_command("RAY.OBJECT_TABLE_ADD", "object_id2",
                                       "one", "hash2", "manager_id1")
        with self.assertRaises(redis.ResponseError):
            self.redis.execute_command("RAY.OBJECT_TABLE_ADD", "object_id2", 1,
                                       "hash2", "manager_id1",
                                       "extra argument")
        # Check that Redis returns an error when RAY.OBJECT_TABLE_ADD adds an
        # object ID that is already present with a different hash.
        self.redis.execute_command("RAY.OBJECT_TABLE_ADD", "object_id1", 1,
                                   "hash1", "manager_id1")
        response = self.redis.execute_command("RAY.OBJECT_TABLE_LOOKUP",
                                              "object_id1")
        self.assertEqual(set(response), {b"manager_id1"})
        with self.assertRaises(redis.ResponseError):
            self.redis.execute_command("RAY.OBJECT_TABLE_ADD", "object_id1", 1,
                                       "hash2", "manager_id2")
        # Check that the second manager was added, even though the hash was
        # mismatched.
        response = self.redis.execute_command("RAY.OBJECT_TABLE_LOOKUP",
                                              "object_id1")
        self.assertEqual(set(response), {b"manager_id1", b"manager_id2"})
        # Check that it is fine if we add the same object ID multiple times
        # with the most recent hash.
        self.redis.execute_command("RAY.OBJECT_TABLE_ADD", "object_id1", 1,
                                   "hash2", "manager_id1")
        self.redis.execute_command("RAY.OBJECT_TABLE_ADD", "object_id1", 1,
                                   "hash2", "manager_id1")
        self.redis.execute_command("RAY.OBJECT_TABLE_ADD", "object_id1", 1,
                                   "hash2", "manager_id2")
        self.redis.execute_command("RAY.OBJECT_TABLE_ADD", "object_id1", 2,
                                   "hash2", "manager_id2")
        response = self.redis.execute_command("RAY.OBJECT_TABLE_LOOKUP",
                                              "object_id1")
        self.assertEqual(set(response), {b"manager_id1", b"manager_id2"})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号