{"id":15096007,"url":"https://github.com/toddlerya/fakerfactory","last_synced_at":"2025-04-14T22:12:10.919Z","repository":{"id":30083117,"uuid":"121117753","full_name":"toddlerya/fakerfactory","owner":"toddlerya","description":"伪造数据的API服务","archived":false,"fork":false,"pushed_at":"2022-06-15T16:13:45.000Z","size":86358,"stargazers_count":68,"open_issues_count":1,"forks_count":19,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-28T10:11:41.247Z","etag":null,"topics":["api","fake-data","gin-gonic","mock-data","testing-tools"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/toddlerya.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}},"created_at":"2018-02-11T11:42:43.000Z","updated_at":"2024-11-25T07:18:17.000Z","dependencies_parsed_at":"2022-09-06T05:42:13.780Z","dependency_job_id":null,"html_url":"https://github.com/toddlerya/fakerfactory","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddlerya%2Ffakerfactory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddlerya%2Ffakerfactory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddlerya%2Ffakerfactory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddlerya%2Ffakerfactory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toddlerya","download_url":"https://codeload.github.com/toddlerya/fakerfactory/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248968916,"owners_count":21191162,"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","fake-data","gin-gonic","mock-data","testing-tools"],"created_at":"2024-09-25T15:44:48.432Z","updated_at":"2025-04-14T22:12:10.902Z","avatar_url":"https://github.com/toddlerya.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# FakerFactory\n伪造测试数据的API服务\n\n## 结合中国国情，伪造测试数据\n\n伪造测试数据的库有很多，Python有大名鼎鼎的[faker](https://github.com/joke2k/faker)，Golang有[gofakeit](https://github.com/brianvoe/gofakeit)，\n但是这些库的中文本地化都不够完善，工作中用的数据大部分是中文，因此想做一次本地化，方便团队开展测试，不再为测试数据发愁。\n\n美中不足的是，faker和gofakeit都只是一个第三方库，不是一个服务，需要自己写代码来调用才能达到测试效果，而且安装部署起来依赖包比较多（个人目前研发生产环境均为内网，无法连接互联网），部署实在是不方便。\n\n于是我就想如果我做成一个性能比较好的服务，提供API，让大家都能通过HTTP请求灵活获取所需的数据，岂不美哉！而且这个服务的应用面应该是很广的，可以用于单元测试、功能测试、性能测试、可靠性测试，而且可以解决研发生产环境没有持续的测试数据的痛点！\n\n为什么没有用Python？考虑到几个方面：\n* Python的部署比较复杂，Golang只要编译好提供二进制文件就好，比较方便（经常出差去客户现场，部署开发环境就是噩梦）。\n* Golang的并发性能比较好（虽然Python也有Tornado框架）。\n\n\n## 目前已经支持的数据类型（即columns字段的可选参数）\n\n| 序号   |      参数      | 说明                                    |\n| :--- | :----------: | ------------------------------------- |\n| 1    |    color     | 颜色                                    |\n| 2    |     job      | 职业                                    |\n| 3    |     name     | 中文名字                                  |\n| 4    |     sex      | 性别                                    |\n| 5    |   address    | 地址信息（地区编号、邮编、固话区号、省市信息、社区名称、社区简称、经纬度） |\n| 6    |    idcard    | 大陆居民身份证号码                             |\n| 7    |     age      | 年龄                                    |\n| 8    | mobilephone  | 移动电话号码                                |\n| 9    |    email     | 电子邮箱                                  |\n| 10   |     imid     | IM类型的用户ID                             |\n| 11   |   nickname   | 用户昵称                                  |\n| 12   |   username   | 用户名                                   |\n| 13   |   password   | 用户密码                                  |\n| 14   |   website    | 网站地址                                  |\n| 15   |     url      | 网址URL（随机http或https）                   |\n| 16   |   airport    | 国内机场信息（IATA编码、城市名称、ICAO编码、机场名称、城市拼音）  |\n| 17   |    voyage    | 国内航班号                                 |\n| 18   | airlineinfo  | 国内航空公司信息（代号、中文名称）                     |\n| 19   |  traintrips  | 火车班次（覆盖高铁、动车、特快、普快、城际、旅游专线）           |\n| 20   |  trainseat   | 火车座号                                  |\n| 22   |  flightseat  | 飞机座号                                  |\n| 23   |     ipv4     | ipv4的点分型IP地址                          |\n| 24   |     ipv6     | ipv6的点分型IP地址                          |\n| 25   |     mac      | mac地址（随机大小写，分隔符）                      |\n| 26   |  useragent   | 浏览器请求头                                |\n| 27   |     imsi     | IMSI（目前只支持国内460开头的）                   |\n| 28   |     imei     | IMEI（目前支持中国、英国、美国）                    |\n| 29   |     meid     | MEID（随机大小写）                           |\n| 30   |   deviceid   | DEVICEID（设备编号）                        |\n| 31   |   telphone   | 固定电话（暂时只支持国内号码）                       |\n| 32   |   citycode   | 国内长途区号                                |\n| 33   | specialphone | 特殊电话号码（比如10086、110）                   |\n| 34   | capturetime  | 当前时间绝对秒（10位数字）                        |\n| 35   |     date     | 当前时间，数据库日期格式{YYYYMMDD,hh:mm:ss}       |\n| 36   |   carbrand   | 汽车品牌（中文）       |\n\n## 单次请求数据返回上限为10000条（即number参数的取值区间为[1,10000]）\n\n## 使用方法：\n\n#### http get请求\nhttp://{IP}:8001/api/v1/fakerfactory?number={条数}\u0026columns={字段参数[多个字段以英文逗号分隔]}\n\n#### [小试一下](http://172.16.5.43:8001/api/v1/fakerfactory?number=1\u0026columns=color,job,name,sex,address,idcard,age,mobilephone,email,imid,nickname,username,password,website,url,airport,voyage,airlineinfo,traintrips,trainseat,flightseat,ipv4,ipv6,useragent,mac,imsi,imei,meid,deviceid,telphone,citycode,specialphone,capturetime,date)\n\n## 使用效果\n\n![](media/Xnip2019-02-16_10-06-23.jpg)\n\n\n## 性能评估\n\n### FakerFactory所在服务器硬件情况\n\n| 硬件   | 详情                                       |\n| ---- | ---------------------------------------- |\n| CPU  | 4 核 Intel(R) Xeon(R) CPU E5-2660 v3 @ 2.60GHz |\n| MEM  | 8G                                       |\n| NET  | 10000Mb/s                                |\n\n### 使用ab对接口进行压测\n\n| 参数项  | 参数值                          |\n| ---- | ---------------------------- |\n| 请求条件 | 每条数据返回24个字段，一次GET请求返回1000条数据 |\n| 请求次数 | 10000                        |\n| 并发   | 20                           |\n\n  ![](media/fakerfactory-24column-20level.png)\n\n  ab测试结果解读：\n\n  - 模拟构造API请求随机生成10000000（1000 x 10000）条数据，耗时278.518秒。\n  - 生成数据总量约7.28 GB（7821829529 bytes）\n  - 吞吐率（Requests per second）： 35.90 \n  - 用户平均请求等待时间（Time per request）：557.037 ms\n  - 服务器平均请求处理时间（Time per request，across all concurrent requests）：27.852 ms\n  - 90%的请求耗时低于662 ms\n\n### 服务器性能表现\n\n  FakerFactory运行对CPU的资源消耗比较大，下面三个图为ab压测五分钟的硬件使用率\n\n  - CPU\n\n    ![](media/CPU使用率.png)\n\n  - MEM\n\n    ![](media/内存使用率.png)\n\n  - NET\n\n    ![](media/网络情况.png)\n\n### 环境依赖\n- 开发环境：go1.9以上\n- 运行环境：直接使用发布的二进制文件即可\n\n## 鸣谢\n- [gofakeit](https://github.com/brianvoe/gofakeit) Random fake data generator written in go.\n- [faker](https://github.com/joke2k/faker) Faker is a Python package that generates fake data for you.\n- [china_area_mysql](https://github.com/kakuilan/china_area_mysql) 中国5级行政区域mysql库\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoddlerya%2Ffakerfactory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoddlerya%2Ffakerfactory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoddlerya%2Ffakerfactory/lists"}