使用GPT工具对GitLab做性能与可用性测试 1 测试工具简介 GitLab Performance Tool (GPT)是由 GitLab 质量保证团队构建和维护的工具,可以对任何 GitLab 实例(包括 GitLab)进行性能和可用性测试。默认测试以下内容:
出于安全考虑,默认不测试 HTTP POST、PUT、DELETE 和 PATCH,如果确实需要测试,可以在测试命令后面加 --unsafe
标识;
2 准备测试环境 2.1 准备电脑和网络 - 尽可能的靠近目标 GitLab,以免受到网络环境的干扰;
- 测试过程需要从 https://gitlab.com下载测试工具和测试数据
2.2 初始化环境 1 2 3 git clone https://gitlab.com/gitlab-org/quality/performance.git cd performance
2.3 准备测试环境
以 GitLab 管理员的身份创建个人访问 Token,scope 包含 API
根据用户数量修改对影的文件,:1k.json, 2k.json, 3k.json, 5k.json, 10k.json, 25k.json, 50k.json
比如1k用户,修改 ./k6/config/environments/1k.json 中的下面两行:
1 2 3 4 5 6 7 8 docker run --rm -it -e ACCESS_TOKEN=<TOKEN> -v $(pwd )/k6/config:/config -v $(pwd )/results:/results gitlab/gpt-data-generator -f --max-wait-for-delete=360000 --environment 1k.json GPT Data Generator v1.2.0 - opinionated test data for the GitLab Performance Tool Checking that GitLab environment 'https://gitlab-tst.xcloud.lenovo.com' is available, supported and that provided Access Token works... Project has successfully imported in 1 hour 34 minutes 21 seconds: https://gitlab.ccops.cc/gpt/large_projects/gitlabhq1 Validating project 'gpt/large_projects/gitlabhq1' imported successfully...
3 运行测试
看到类似结果压测完成,这里我用的测试环境,有几个指标没有通过
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 docker run --rm -it -e ACCESS_TOKEN=<TOKEN> -v $(pwd )/k6/config:/config -v $(pwd )/k6/tests:/tests -v results:/results gitlab/gitlab-performance-tool --environment 1k.json --options 60s_20rps.json ❯ Overall Results Score: 97.26% NAME | RPS | RPS RESULT | TTFB AVG | TTFB P90 | REQ STATUS | RESULT ---------------------------------------------------------|------|--------------------|-----------|----------------------|----------------|------------------ api_v4_groups | 20/s | 19.92/s (>16.00/s) | 73.47ms | 84.11ms (<200ms) | 100.00% (>99%) | Passed api_v4_groups_group | 20/s | 19.46/s (>0.80/s) | 298.00ms | 472.49ms (<24000ms) | 100.00% (>20%) | Passed¹ api_v4_groups_group_subgroups | 20/s | 19.91/s (>16.00/s) | 77.63ms | 92.44ms (<200ms) | 100.00% (>99%) | Passed api_v4_groups_issues | 20/s | 19.54/s (>3.20/s) | 268.86ms | 314.08ms (<8000ms) | 100.00% (>99%) | Passed¹ api_v4_groups_merge_requests | 20/s | 19.61/s (>1.60/s) | 238.45ms | 270.27ms (<17500ms) | 100.00% (>99%) | Passed¹ api_v4_groups_projects | 20/s | 19.61/s (>0.80/s) | 228.83ms | 253.38ms (<22000ms) | 100.00% (>30%) | Passed¹ api_v4_projects | 20/s | 19.28/s (>2.40/s) | 399.77ms | 435.57ms (<7000ms) | 100.00% (>99%) | Passed¹ api_v4_projects_deploy_keys | 20/s | 19.99/s (>16.00/s) | 55.06ms | 67.73ms (<200ms) | 100.00% (>99%) | Passed api_v4_projects_issues | 20/s | 19.77/s (>16.00/s) | 200.49ms | 222.74ms (<1000ms) | 100.00% (>99%) | Passed¹ api_v4_projects_issues_issue | 20/s | 19.65/s (>16.00/s) | 232.28ms | 261.34ms (<2600ms) | 100.00% (>99%) | Passed¹ api_v4_projects_issues_search | 20/s | 19.64/s (>16.00/s) | 90.58ms | 237.13ms (<800ms) | 26.46% (>99%) | FAILED¹² api_v4_projects_languages | 20/s | 19.94/s (>16.00/s) | 51.86ms | 65.50ms (<200ms) | 100.00% (>99%) | Passed api_v4_projects_merge_requests | 20/s | 19.85/s (>16.00/s) | 127.96ms | 152.74ms (<400ms) | 100.00% (>99%) | Passed¹ api_v4_projects_merge_requests_merge_request | 20/s | 19.56/s (>8.00/s) | 244.40ms | 278.60ms (<3500ms) | 100.00% (>99%) | Passed¹ api_v4_projects_merge_requests_merge_request_commits | 20/s | 19.79/s (>16.00/s) | 140.37ms | 152.18ms (<200ms) | 100.00% (>99%) | Passed api_v4_projects_merge_requests_merge_request_diffs | 20/s | 19.85/s (>16.00/s) | 95.93ms | 112.73ms (<200ms) | 100.00% (>99%) | Passed api_v4_projects_merge_requests_merge_request_discussions | 20/s | 19.7/s (>16.00/s) | 186.49ms | 211.41ms (<400ms) | 100.00% (>99%) | Passed¹ api_v4_projects_merge_requests_search | 20/s | 19.95/s (>4.80/s) | 89.08ms | 197.40ms (<5000ms) | 25.04% (>99%) | FAILED¹² api_v4_projects_project | 20/s | 19.82/s (>16.00/s) | 117.18ms | 141.67ms (<200ms) | 100.00% (>99%) | Passed api_v4_projects_project_pipelines | 20/s | 19.95/s (>16.00/s) | 71.23ms | 88.48ms (<200ms) | 100.00% (>99%) | Passed api_v4_projects_project_pipelines_pipeline | 20/s | 19.9/s (>16.00/s) | 77.10ms | 93.40ms (<200ms) | 100.00% (>99%) | Passed api_v4_projects_project_pipelines_pipeline_jobs | 20/s | 19.52/s (>3.20/s) | 286.58ms | 322.66ms (<2000ms) | 100.00% (>99%) | Passed¹ api_v4_projects_project_services | 20/s | 19.99/s (>16.00/s) | 48.40ms | 58.94ms (<200ms) | 100.00% (>99%) | Passed api_v4_projects_releases | 20/s | 19.83/s (>16.00/s) | 90.41ms | 109.00ms (<200ms) | 100.00% (>99%) | Passed api_v4_projects_repository_branches | 20/s | 19.82/s (>16.00/s) | 50.81ms | 61.15ms (<200ms) | 100.00% (>99%) | Passed api_v4_projects_repository_branches_branch | 20/s | 19.89/s (>16.00/s) | 94.10ms | 111.80ms (<200ms) | 100.00% (>99%) | Passed api_v4_projects_repository_branches_search | 20/s | 19.87/s (>16.00/s) | 52.96ms | 62.52ms (<200ms) | 100.00% (>99%) | Passed api_v4_projects_repository_commits | 20/s | 19.92/s (>16.00/s) | 90.66ms | 105.03ms (<200ms) | 100.00% (>99%) | Passed api_v4_projects_repository_commits_commit | 20/s | 19.91/s (>16.00/s) | 82.08ms | 97.62ms (<200ms) | 100.00% (>99%) | Passed api_v4_projects_repository_commits_commit_diff | 20/s | 19.82/s (>16.00/s) | 152.17ms | 171.05ms (<200ms) | 100.00% (>99%) | Passed api_v4_projects_repository_compare | 20/s | 19.76/s (>16.00/s) | 77.96ms | 92.19ms (<200ms) | 100.00% (>99%) | Passed api_v4_projects_repository_files_file | 20/s | 19.91/s (>16.00/s) | 87.45ms | 100.89ms (<200ms) | 100.00% (>99%) | Passed api_v4_projects_repository_files_file_blame | 20/s | 12.21/s (>0.16/s) | 1458.96ms | 1627.86ms (<35000ms) | 100.00% (>15%) | Passed¹ api_v4_projects_repository_files_file_raw | 20/s | 19.89/s (>16.00/s) | 95.57ms | 106.45ms (<200ms) | 100.00% (>99%) | Passed api_v4_projects_repository_tags | 20/s | 19.85/s (>16.00/s) | 108.27ms | 121.12ms (<200ms) | 100.00% (>99%) | Passed api_v4_projects_repository_tree | 20/s | 19.9/s (>16.00/s) | 88.82ms | 102.92ms (<200ms) | 100.00% (>99%) | Passed api_v4_user | 20/s | 19.95/s (>16.00/s) | 59.33ms | 72.38ms (<200ms) | 100.00% (>99%) | Passed api_v4_users | 20/s | 19.8/s (>16.00/s) | 156.16ms | 181.81ms (<300ms) | 100.00% (>99%) | Passed¹ git_clone | 1/s | 0.36/s (>0.03/s) | 293.97ms | 554.25ms (<800ms) | 100.00% (>99%) | Passed¹ git_ls_remote | 2/s | 2.01/s (>1.60/s) | 73.25ms | 105.27ms (<200ms) | 100.00% (>99%) | Passed git_pull | 2/s | 2.01/s (>1.60/s) | 106.97ms | 164.31ms (<400ms) | 100.00% (>99%) | Passed web_group | 2/s | 2.01/s (>1.60/s) | 219.10ms | 391.24ms (<500ms) | 100.00% (>99%) | Passed¹ web_group_issues | 2/s | 2.01/s (>1.60/s) | 213.94ms | 276.40ms (<500ms) | 100.00% (>99%) | Passed¹ web_group_merge_requests | 2/s | 2.0/s (>1.60/s) | 385.19ms | 569.83ms (<800ms) | 100.00% (>99%) | Passed¹ web_project | 2/s | 1.99/s (>1.60/s) | 378.87ms | 583.02ms (<800ms) | 100.00% (>99%) | Passed¹ web_project_branches | 2/s | 1.96/s (>1.60/s) | 500.27ms | 585.83ms (<900ms) | 100.00% (>99%) | Passed¹ web_project_branches_search | 2/s | 1.88/s (>1.60/s) | 822.09ms | 898.32ms (<1600ms) | 100.00% (>99%) | Passed¹ web_project_commit | 2/s | 1.86/s (>0.64/s) | 679.06ms | 1880.21ms (<3500ms) | 100.00% (>99%) | Passed¹ web_project_commits | 2/s | 1.92/s (>1.60/s) | 576.26ms | 631.53ms (<1000ms) | 100.00% (>99%) | Passed¹ web_project_file_blame | 2/s | 0.88/s (>0.32/s) | 2060.52ms | 2210.59ms (<2400ms) | 100.00% (>99%) | Passed¹ web_project_file_rendered | 2/s | 1.68/s (>1.28/s) | 676.32ms | 584.32ms (<1700ms) | 100.00% (>99%) | Passed¹ web_project_file_source | 2/s | 1.81/s (>0.64/s) | 758.57ms | 1202.11ms (<4000ms) | 100.00% (>99%) | Passed¹ web_project_files | 2/s | 1.98/s (>1.60/s) | 196.70ms | 326.01ms (<1200ms) | 100.00% (>99%) | Passed¹ web_project_issue | 2/s | 1.99/s (>1.60/s) | 291.03ms | 509.75ms (<2000ms) | 100.00% (>99%) | Passed¹ web_project_issues | 2/s | 2.01/s (>1.60/s) | 238.38ms | 294.93ms (<700ms) | 100.00% (>99%) | Passed¹ web_project_issues_search | 2/s | 2.01/s (>1.60/s) | 217.77ms | 250.98ms (<700ms) | 100.00% (>99%) | Passed¹ web_project_merge_request | 2/s | 1.64/s (>1.60/s) | 761.40ms | 1893.35ms (<2800ms) | 100.00% (>99%) | Passed¹ web_project_merge_request_changes | 2/s | 1.88/s (>1.60/s) | 589.07ms | 777.76ms (<1500ms) | 100.00% (>99%) | Passed¹ web_project_merge_request_commits | 2/s | 1.55/s (>0.96/s) | 1127.50ms | 1911.22ms (<1950ms) | 100.00% (>99%) | Passed¹ web_project_merge_requests | 2/s | 2.0/s (>1.60/s) | 417.53ms | 480.46ms (<900ms) | 100.00% (>99%) | Passed¹ web_project_merge_requests_search | 2/s | 2.01/s (>1.60/s) | 417.60ms | 470.00ms (<700ms) | 100.00% (>99%) | Passed¹ web_project_pipelines | 2/s | 1.99/s (>1.28/s) | 371.85ms | 535.50ms (<600ms) | 100.00% (>99%) | Passed¹ web_project_pipelines_pipeline | 2/s | 1.98/s (>1.60/s) | 474.16ms | 1045.01ms (<2500ms) | 100.00% (>99%) | Passed¹ web_project_repository_compare | 2/s | 0.54/s (>0.08/s) | 3425.43ms | 4400.40ms (<7500ms) | 100.00% (>99%) | Passed¹ web_project_tags | 2/s | 1.84/s (>1.28/s) | 770.31ms | 806.39ms (<1500ms) | 100.00% (>99%) | Passed¹ web_user | 2/s | 2.01/s (>0.96/s) | 239.81ms | 313.18ms (<4000ms) | 100.00% (>99%) | Passed ¹ Result covers endpoint(s) that have known issue(s). Threshold(s) have been adjusted to compensate. ² Failure may not be clear from summary alone. Refer to the individual test 's full output for further debugging. █ Results files # 扫描后的文件存放到这里 /results/1k_v15-11-4_2023-06-15_065825/1k_v15-11-4_2023-06-15_065825_results_output.log /results/1k_v15-11-4_2023-06-15_065825/1k_v15-11-4_2023-06-15_065825_results.json /results/1k_v15-11-4_2023-06-15_065825/1k_v15-11-4_2023-06-15_065825_results.csv /results/1k_v15-11-4_2023-06-15_065825/1k_v15-11-4_2023-06-15_065825_results.txt One or more tests have failed...
4 清理测试数据
方法二选一
4.1 通过命令 1 docker run --rm -it -e ACCESS_TOKEN=<TOKEN> -v $(pwd )/k6/config:/config -v $(pwd )/results:/results gitlab/gpt-data-generator -f --max-wait-for-delete=360000 --environment 1k.json --clean-up
4.2 web页面删除组