{"id":29571923,"url":"https://github.com/oceanbase/ob-open-test","last_synced_at":"2025-07-19T04:36:37.613Z","repository":{"id":194736308,"uuid":"685339222","full_name":"oceanbase/ob-open-test","owner":"oceanbase","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-22T02:58:43.000Z","size":242,"stargazers_count":0,"open_issues_count":2,"forks_count":1,"subscribers_count":6,"default_branch":"main","last_synced_at":"2023-12-22T04:11:17.707Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oceanbase.png","metadata":{"files":{"readme":"README.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}},"created_at":"2023-08-31T02:36:58.000Z","updated_at":"2023-09-14T07:49:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"9791e280-9726-47b3-8977-0944c7d8b464","html_url":"https://github.com/oceanbase/ob-open-test","commit_stats":null,"previous_names":["oceanbase/ob-open-test"],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/oceanbase/ob-open-test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oceanbase%2Fob-open-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oceanbase%2Fob-open-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oceanbase%2Fob-open-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oceanbase%2Fob-open-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oceanbase","download_url":"https://codeload.github.com/oceanbase/ob-open-test/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oceanbase%2Fob-open-test/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265889162,"owners_count":23844539,"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":[],"created_at":"2025-07-19T04:36:36.792Z","updated_at":"2025-07-19T04:36:37.599Z","avatar_url":"https://github.com/oceanbase.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 前言\nob-open-test是一个基于ob-operator、chaosblade的开源测试工具，其核心为基于K8S环境建设的高可用测试平台。\n开源最重要的是可信，一个产品是否能被选用，可靠性测试是极为重要的。OceanBase是一个属于数据库基建的底层应用，其是否稳定、是否高可用于上层业务逻辑强关联。\n因此我们设计了ob-open-test来面向OceanBase实现低成本的测试，多场景平台设计。\n# 依赖\n## kubernetes\nkubernetes可以快速搭建已设计的容器，并在生产环境中进行部署，ob-open-test的所有功能性依赖均基于kubernetes设计。\n## ob-operator\nob-operator 可以让 OceanBase 以容器的方式，无缝运行在公有云或私有部署的 Kubernetes 集群上。\nob-operator 现已支持 OceanBase 集群的创建、删除，完整的节点生命周期管理，并通过 Service 的形式暴露给用户使用。后续会支持租户管理、ob-proxy 管理、多 Kubernetes 集群等功能。\n[https://github.com/oceanbase/ob-operator](https://github.com/oceanbase/ob-operator)\n\n## chaosblade\nChaosblade Operator 是混沌工程实验工具 ChaosBlade 下的一款面向云原生领域的混沌实验注入工具，可单独部署使用。通过定义 Kubernetes CRD 来管理混沌实验，每个实验都有非常明确的执行状态。工具具有部署简单、执行便捷、标准化实现、场景丰富等特点。将 ChaosBlade 混沌实验模型与 Kubernetes CRD 很好的结合在一起，可以实现基础资源、应用服务、容器等场景在 Kubernetes 平台上场景复用，方便了 Kubernetes 下资源场景的扩展，而且可通过 chaosblade cli 统一执行调用。\n\n## gin\nGin 是一个用 Go (Golang) 编写的 Web 框架。用于实现ob-open-test-web模块。\n\n\n# 安装\u0026卸载\nob-open-test分为服务和单例，方便用户在不同的场景下进行调用。服务倾向于用户自行编排任务执行场景来实现所需的测试场景；单例为我们已设计的场景来执行对应的测试场景。\n## 运行环境\nob-open-test做了兼容处理在云内外环境均可，但是由于依赖kubectl来找到对应的集群，因此云外环境需要在对应kubernetes的node上。\n\n## 服务\n在kubectl的机器上执行install.sh即可\n```shell\nchmod +x install.sh\n./install.sh\n```\n\n\n## 单例\n单例是没有安装及卸载的流程，内部 已包含了所需的依赖及执行步骤\n```shell\n./{caseName}/run\n```\n\n例如：\n```shell\ngo build -o stability ./cmd/stability/stability.go \nchmod +x stability\n./stability\n```\n\n## 任务\n任务创建\n\n\n\n## 独立模块调用\n例：obcluster\n\n获取当前支持的版本\n```shell\ncurl --location --request GET '127.0.0.1:8080/obcluster/version'\n```\n创建集群\ntag为版本号，上一个版本请求中所对应的值，非必填项，不填时会取第一个版本\n```shell\ncurl --location --request POST '127.0.0.1:8080/obcluster/add' --header 'Content-Type: application/json' \\\n--data '{    \"name\":\"test\",\n\"tag\":”v3.1.4-10000092022071511-1124“\n}'\n```\n\n获取集群端口\n由于集群拉起需要时间，建议在创建集群一分钟后在执行此请求进行端口获取\n\n```shell\ncurl --location --request POST '127.0.0.1:8080/obcluster/get' --header 'Content-Type: application/json' \\\n--data '{   \"name\":\"test\"}'\n\n```\n销毁集群\n```shell\ncurl --location --request POST '127.0.0.1:8080/obcluster/delete' --header 'Content-Type: application/json' \\\n--data '{   \"name\":\"test\"}'\n```\n# \n\n# 使用\n当前ob-open-test通过http提供服务，后续将支持yaml直接调用\n## 单一功能\n### 1. ob集群操作\n#### 1. 创建集群\n此为异步操作，\n需要输入集群别名（用于后续的控制）\n```shell\ncurl --location --request POST '127.0.0.1:8080/obcluster/add' --header 'Content-Type: application/json' \\\n--data '{    \"name\":\"test\",\n\"tag\":”v3.1.4-10000092022071511-1124“\n}'\n```\n#### 2. 获取集群信息\n未销毁的集群信息会存储在ob-open-test的应用缓存中，可获取对应的集群信息，集群状态\n```shell\ncurl --location --request POST '127.0.0.1:8080/obcluster/get' --header 'Content-Type: application/json' \\\n--data '{   \"name\":\"test\"}'\n\n```\n#### 3. 销毁集群\n```shell\ncurl --location --request POST '127.0.0.1:8080/obcluster/delete' --header 'Content-Type: application/json' \\\n--data '{   \"name\":\"test\"}'\n```\n\n\n# 结构\nob-open-test的总体结构如下\n![](picture/structure.jpeg)\n## 调度体系\n\n服务调度按task\u003e\u003esteps\u003emodel的方式进行\n![](picture/dispatching-system.jpeg)\n### task设计\ntask为用户的操作入口，也是整个系统的调度入口，结构如下，主要由任务名，多个步骤结构体，任务状态、创建时间组成。\n```go\ntype Task struct {\n    //任务名\n    Name       string\n    //步骤\n    Steps      []Step\n    //任务状态\n    State      string\n    //创建时间\n    CreateTime int64\n}\n```\ntask主要是面向用户设计的任务编排策略，其包含了基础的start和destory两个方法，后续可接入触发器进行定时触发、条件触发等。可设计场景如代码合并后需要统一执行的一些测试，如设计一个稳定性测试任务、压测任务、基础sql验证任务、模糊测试任务等。任务具有很强的先后顺序，必须满足所有的上一个步骤完成后才可继续触发下一个步骤。\nsteps为整个任务所需的核心结构表示这个任务需要执行的主要步骤，里面主要是执行具体的步骤，如拉起一个oceanbase集群还需要拉起obproxy集群以及相关的prometheus服务等相关组件，将这些一个个小操作聚合在一起实现为一个步骤。步骤的小操作中先后顺序不强，可同一时间去执行。\n```go\ntype Step struct {\n\tName   string\n\tType   int\n\tModels []Model\n}\n```\n\nmodel是对各个工具的包装，相当于封装了各个功能将其统一为几个调度接口，可视为SDK的模式\n部分统一的方法建议均一进行重写，以适应模块的调度\n```go\n//组件，包装ob-operator,chaos,workbench\ntype Model interface {\n\t//模块名\n\tGetName() string\n\t//控制方法命令\n\tSetConf(map[string]string)\n\t//开始\n\tStart()\n\t//逆向销毁\n\tDestory()\n\t//等待时间，用于waitEnd的超时等待命令\n\tGetStatusTime() time.Duration\n\t//此处可用context代替\n\tWaitEnd(timeout time.Duration) int\n}\n```\n\nob模块\n本模块封装了ob-operator的调用方法，可实现集群的拉起和销毁，后续可根据扩展Confs map内信息来实现对应能力的扩展，不影响其他模块的独立工作\n```go\ntype OBModel struct {\n\tName  string\n\tConfs map[string]string\n}\n```\nchaos模块\n本模块封装了chaosblade的调用方法，可实现对ob模块拉起的nampspace的资源操作，通过逐步开放ChaosClient来实现多种混沌测试的场景\n\n```go\ntype ChaosModel struct {\n\tName  string\n\tConfs map[string]string\n\tCC    ChaosClient\n}\n```\n\n\n\n\n# 安全建议\n\n## 关于引用外部地址可能涉及的存在的被攻击的风险\n\n### 1. GetOBServerTagURL\n\nobopentest-ob/OBCluster.go中的获取所有的observer版本信息依赖于从dockerhub内获取对应的版本list，所以需要做一个get请求，若用户觉得存在风险可以自行匹配到内部可控仓库。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foceanbase%2Fob-open-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foceanbase%2Fob-open-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foceanbase%2Fob-open-test/lists"}