{"id":19124204,"url":"https://github.com/tair-opensource/resp-compatibility","last_synced_at":"2025-05-05T19:00:00.441Z","repository":{"id":157022985,"uuid":"633257812","full_name":"tair-opensource/resp-compatibility","owner":"tair-opensource","description":"A tool to detect which version of Redis your Redis-Like database is compatible with.","archived":false,"fork":false,"pushed_at":"2025-05-01T18:34:42.000Z","size":647,"stargazers_count":33,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-01T19:39:48.742Z","etag":null,"topics":["api","compatibility-test","nosql","redis"],"latest_commit_sha":null,"homepage":"https://tair-opensource.github.io/resp-compatibility/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tair-opensource.png","metadata":{"files":{"readme":"README-CN.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-04-27T05:48:23.000Z","updated_at":"2025-03-18T06:11:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"98bce75d-da17-47e9-993d-af12267be27c","html_url":"https://github.com/tair-opensource/resp-compatibility","commit_stats":null,"previous_names":["tair-opensource/resp-compatibility"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tair-opensource%2Fresp-compatibility","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tair-opensource%2Fresp-compatibility/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tair-opensource%2Fresp-compatibility/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tair-opensource%2Fresp-compatibility/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tair-opensource","download_url":"https://codeload.github.com/tair-opensource/resp-compatibility/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252558584,"owners_count":21767793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","compatibility-test","nosql","redis"],"created_at":"2024-11-09T05:28:24.150Z","updated_at":"2025-05-05T19:00:00.423Z","avatar_url":"https://github.com/tair-opensource.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"#  resp-compatibility\n\n` resp-compatibility`是一个用来检测你的`Redis-Like`系统兼容到开源`Redis`哪个版本的工具（6.0还是7.0等）。\n\n# 安装\n\n要求`Python 3.7`及以上版本。\n```\npip3 install -r requirements.txt\n```\n\n# 可测试命令\n\nCTS 可以测试的命令及其对应的版本信息可参考[此表](cts_refer.md)\n\n# 如何使用\n\n一些命令行支持的参数如下所示：\n\n```\noptional arguments:\n  -h, --help            show this help message and exit\n  --host HOST           the redis host\n  --port PORT           the redis port\n  --password PASSWORD   the redis password\n  --testfile TESTFILE   the redis compatibility test cases\n  --specific-version {1.0.0,2.8.0,3.2.0,4.0.0,5.0.0,6.0.0,6.2.0,7.0.0,7.2.0}\n                        the redis version\n  --show-failed         show details of failed tests\n  --cluster             server is a node of the Redis cluster\n  --ssl                 open ssl connection\n  --genhtml             generate test report in html format\n```\n例如，测试 host:port 对应的服务是否兼容 Redis 6.2.0 版本并显示失败的测试。\n```\n$ python3  resp_compatibility.py -h host -p port --testfile cts.json --specific-version 6.2.0 --show-failed\nConnecting to 127.0.0.1:6379 use standalone client\ntest: del command passed\ntest: unlink command passed\n...\ntest: xtrim command with MINID/LIMIT passed\n-------- The result of tests --------\nSummary: version: 6.2.0, total tests: 285, passed: 285, rate: 100.00%\n```\n更多的示例请参考 `python3  resp_compatibility.py -h`。\n\n## cluster\nRedis 在 API 层面有两种模式，一个是`Standalone`（Sentinel 模式的 API 兼容性和 Standalone 是一样的），一个是`Cluster`。命令在`Standalone`模式下没有跨 Slot 的限制，但是在集群模式下，要求多 key 的命令（例如 mset/mget命令）必须在同一 Slot 中。因此，我们支持了`--cluster`这个选项来测试系统对于 `Redis Cluster` 模式的兼容性，用法如下：\n```\n$ python3.9  resp_compatibility.py --testfile cts.json --host 127.0.0.1 --port 30001 --cluster --specific-version 6.2.0\nconnecting to 127.0.0.1:30001 use cluster client\ntest: del command passed\ntest: unlink command passed\n...\ntest: xtrim command with MINID/LIMIT passed\n-------- The result of tests --------\nSummary: version: 6.2.0, total tests: 260, passed: 260, rate: 100.00%\n```\n\n## genhtml\n您可以使用 `--genhtml` 选项来生成和此[网站](https://tair-opensource.github.io/resp-compatibility/)相同的 html 报告。 请注意，当使用此选项时候，将会读取 [config.yaml](config.yaml) 文件中的配置进行测试，此时命令行中的 `specific-version` 将会被文件中的覆盖。\n```\n$ python3.9  resp_compatibility.py --testfile cts.json --genhtml --show-failed\ndirectory html already exists, will be deleted and renewed.\nstart test Redis for version 4.0.0\nconnecting to 127.0.0.1:6379 using standalone client\nstart test Redis for version 5.0.0\nconnecting to 127.0.0.1:6379 using standalone client\nstart test Redis for version 6.0.0\nconnecting to 127.0.0.1:6379 using standalone client\nstart test Redis for version 7.0.0\nconnecting to 127.0.0.1:6379 using standalone client\n...\nVisit http://localhost:8000 for the report.\n```\n结束之后，一个 HTTP 服务器将会被启动在 http://localhost:8000 ，您可以访问此网站获得 html 报告。\n\n## 更多用法\n\n### 在迁移您的业务之前验证数据库的支持\n当您需要将业务系统从 A 数据库迁移到 B 时，为了防止 B 的不兼容，您可以编写自己的 `cts.json` (compatibility-test-suite) 来验证 B 数据库系统兼容性，其格式示例如下：\n```\n[\n  {\n    \"name\": \"del command\",\n    \"command\": [\n      \"set k v\",\n      \"del k\"\n    ],\n    \"result\": [\n      \"OK\",\n      1\n    ],\n    \"since\": \"1.0.0\"\n  }\n]\n```\n整体上是一个 JSON数组，包含多条测试 case，每一个都是 JSON Object，`command`和`result`是一一对应的。除过上述示例中的字段，还有一些字段如下：\n\n| name           | value              | 含义                          |\n|----------------|--------------------|-----------------------------|\n| tags           | standalone,cluster | 只在tags指定的模式下才允许此case        |\n| skipped        | true               | 跳过此case                     |\n| command_binary | true               | 将命令转为二进制，例如命令中包含非可见的ascii字符 |\n| sort_result    | true               | 对返回结果进行排序                   |\n\n### 使用别的编程语言使用此工具\n本项目的主要工作是我们在 `cts.json`中增加了超过 7000 行测试，如果您希望用别的编程语言（例如 Java, Go, Rust等）实现相同功能的测试工具，那么您只需要解析 `cts.json` 的格式，并且将测试依次执行即可，玩的愉快。\n## License\n[MIT](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftair-opensource%2Fresp-compatibility","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftair-opensource%2Fresp-compatibility","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftair-opensource%2Fresp-compatibility/lists"}