runtest.py 文件源码

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

项目:ray 作者: ray-project 项目源码 文件源码
def testObjectTableAddAndLookup(self):
        # 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"})
        # Add a manager that already exists again and try again.
        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"})
        # Check that we properly handle NULL characters. In the past, NULL
        # characters were handled improperly causing a "hash mismatch" error if
        # two object IDs that agreed up to the NULL character were inserted
        # with different hashes.
        self.redis.execute_command("RAY.OBJECT_TABLE_ADD", "\x00object_id3", 1,
                                   "hash1", "manager_id1")
        self.redis.execute_command("RAY.OBJECT_TABLE_ADD", "\x00object_id4", 1,
                                   "hash2", "manager_id1")
        # Check that NULL characters in the hash are handled properly.
        self.redis.execute_command("RAY.OBJECT_TABLE_ADD", "object_id3", 1,
                                   "\x00hash1", "manager_id1")
        with self.assertRaises(redis.ResponseError):
            self.redis.execute_command("RAY.OBJECT_TABLE_ADD", "object_id3", 1,
                                       "\x00hash2", "manager_id1")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号