<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # Load Performance Testing > 原文:[https://docs.gitlab.com/ee/user/project/merge_requests/load_performance_testing.html](https://docs.gitlab.com/ee/user/project/merge_requests/load_performance_testing.html) * [How Load Performance Testing works](#how-load-performance-testing-works) * [Configure the Load Performance Testing job](#configure-the-load-performance-testing-job) * [Determine the test parameters](#determine-the-test-parameters) * [Test Environment setup](#test-environment-setup) * [Write the load performance test](#write-the-load-performance-test) * [Configure the test in GitLab CI/CD](#configure-the-test-in-gitlab-cicd) * [Load Performance testing in Review Apps](#load-performance-testing-in-review-apps) # Load Performance Testing[](#load-performance-testing-premium "Permalink") [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/10683) in [GitLab Premium](https://about.gitlab.com/pricing/) 13.2. 使用負載性能測試,您可以在[GitLab CI / CD 中](../../../ci/README.html)測試任何待處理代碼更改對應用程序后端的影響. GitLab 使用免費的開源工具[k6](https://k6.io/)來測量負載下應用程序的系統性能. Unlike [Browser Performance Testing](browser_performance_testing.html), which is used to measure how web sites perform in client browsers, Load Performance Testing can be used to perform various types of [load tests](https://k6.io/docs/#use-cases) against application endpoints such as APIs, Web Controllers, and so on. This can be used to test how the backend or the server performs at scale. 例如,您可以使用負載性能測試對應用程序中流行的 API 端點執行許多并發 GET 調用,以查看其性能. ## How Load Performance Testing works[](#how-load-performance-testing-works "Permalink") 首先,在您的`.gitlab-ci.yml`文件中定義一個作業,以生成" [負載性能"報告工件](../../../ci/pipelines/job_artifacts.html#artifactsreportsload_performance-premium) . GitLab 會檢查此報告,比較源分支和目標分支之間的關鍵負載性能指標,然后在合并請求小部件中顯示信息: [![Load Performance Widget](https://img.kancloud.cn/9e/37/9e371567fa84cd899aedc8bf43c96950_978x486.png)](img/load_performance_testing.png) 接下來,您需要配置測試環境并編寫 k6 測試. 測試完成后,合并請求窗口小部件顯示的關鍵性能指標是: * 支票:在 k6 測試中配置的[支票的](https://k6.io/docs/using-k6/checks)通過率. * TTFB P90: The 90th percentile of how long it took to start receiving responses, aka the [Time to First Byte](https://en.wikipedia.org/wiki/Time_to_first_byte) (TTFB). * TTFB P95:TTFB 的第 95 個百分點. * RPS:測試能夠達到的平均每秒請求數(RPS). **注意:**如果"負載性能"報告沒有可比較的數據,例如,當您第一次在`.gitlab-ci.yml`添加"負載性能"作業時,"負載性能"報告小部件將不會顯示. 它必須在目標分支(例如`master` )上至少運行一次,然后才能在針對該分支的合并請求中顯示. ## Configure the Load Performance Testing job[](#configure-the-load-performance-testing-job "Permalink") 配置負載性能測試作業可以分為幾個不同的部分: * 確定測試參數,例如吞吐量,等等. * 設置目標測試環境以進行負載性能測試. * 設計并編寫 k6 測試. ### Determine the test parameters[](#determine-the-test-parameters "Permalink") 您需要做的第一件事是確定要運行[的負載測試](https://k6.io/docs/test-types/introduction)的[類型](https://k6.io/docs/test-types/introduction)以及運行方式(例如,用戶數量,吞吐量等). 請參閱[k6 文檔](https://k6.io/docs/) ,尤其是[k6 測試指南](https://k6.io/docs/testing-guides) ,以獲取有關上述內容及更多內容的指南. ### Test Environment setup[](#test-environment-setup "Permalink") 負載性能測試的大部分工作是為高負載準備目標測試環境. 您應該確保它能夠處理將要測試的[吞吐量](https://k6.io/blog/monthly-visits-concurrent-users) . 通常還需要在目標環境中具有代表性的測試數據,以供負載性能測試使用. 強烈建議[不要在生產環境中運行這些測試](https://k6.io/our-beliefs#load-test-in-a-pre-production-environment) . ### Write the load performance test[](#write-the-load-performance-test "Permalink") 準備好環境后,您可以編寫 k6 測試本身. k6 是一種靈活的工具,可用于運行[多種性能測試](https://k6.io/docs/test-types/introduction) . 有關如何編寫測試的詳細信息,請參閱[k6 文檔](https://k6.io/docs/) . ### Configure the test in GitLab CI/CD[](#configure-the-test-in-gitlab-cicd "Permalink") 準備好 k6 測試后,下一步就是在 GitLab CI / CD 中配置負載性能測試作業. 最簡單的方法是使用 GitLab 隨附的[`Verify/Load-Performance-Testing.gitlab-ci.yml`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/ci/templates/Verify/Load-Performance-Testing.gitlab-ci.yml)模板. **注意:**對于大型 k6 測試,您需要確保執行實際測試的 GitLab Runner 實例能夠處理運行測試. 有關規格的詳細信息,請參閱[k6 的指南](https://k6.io/docs/testing-guides/running-large-tests#hardware-considerations) . [默認的共享 GitLab.com 運行程序](../../gitlab_com/#linux-shared-runners)可能沒有足夠的規格來處理大多數大型 k6 測試. 該模板在作業中運行[k6 Docker 容器](https://hub.docker.com/r/loadimpact/k6/) ,并提供了幾種自定義作業的方法. 配置工作流程示例: 1. 設置一個可以運行 Docker 容器的 GitLab Runner,例如使用[Docker-in-Docker 工作流](../../../ci/docker/using_docker_build.html#use-docker-in-docker-workflow-with-docker-executor)的 Runner. 2. 在`.gitlab-ci.yml`文件中配置默認??的 Load Performance Testing CI 作業. 您需要包括模板并使用變量進行配置: ``` include: template: Verify/Load-Performance-Testing.gitlab-ci.yml load_performance: variables: K6_TEST_FILE: <PATH TO K6 TEST FILE IN PROJECT> ``` 上面的示例在運行 k6 測試的 CI / CD 管道中創建了一個`load_performance`作業. **注意:**對于 Kubernetes 設置,應使用其他模板: [`Jobs/Load-Performance-Testing.gitlab-ci.yml`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/ci/templates/Jobs/Load-Performance-Testing.gitlab-ci.yml) . k6 具有[各種選項](https://k6.io/docs/using-k6/options)來配置它將如何運行測試,例如運行什么吞吐量(RPS),測試應該運行多長時間等等. 幾乎所有選項都可以在測試本身中進行配置,但是您也可以通過`K6_OPTIONS`變量傳遞命令行選項. 例如,您可以使用 CLI 選項覆蓋測試的持續時間: ``` include: template: Verify/Load-Performance-Testing.gitlab-ci.yml load_performance: variables: K6_TEST_FILE: <PATH TO K6 TEST FILE IN PROJECT> K6_OPTIONS: '--duration 30s' ``` 如果 k6 的結果通過[摘要導出](https://k6.io/docs/results-visualization/json#summary-export)保存為" [負載性能"報告工件,則](../../../ci/pipelines/job_artifacts.html#artifactsreportsload_performance-premium) GitLab 僅在 MR 小部件中顯示關鍵性能指標. 始終使用最新的可用負載性能工件. 如果啟用了[GitLab Pages,](../pages/index.html)則可以直接在瀏覽器中查看報告. ### Load Performance testing in Review Apps[](#load-performance-testing-in-review-apps "Permalink") 上面的 CI / CD YAML 配置示例適用于針對靜態環境進行測試,但是可以通過一些額外的步驟將其擴展為與[審閱應用程序](../../../ci/review_apps)或[動態環境](../../../ci/environments)一起使用. 最好的方法是將動態 URL 捕獲到一個自定義環境變量中,然后由`load_performance`作業[繼承](../../../ci/variables/README.html#inherit-environment-variables)該`load_performance` . 然后應將要運行的 k6 測試腳本配置為使用該環境 URL,例如: `http.get(`${__ENV.ENVIRONMENT_URL`})` . 例如: 1. 在`review`工作中: 1. 捕獲動態 URL 并將其保存到`.env`文件,例如`echo "ENVIRONMENT_URL=$CI_ENVIRONMENT_URL" >> review.env` . 2. 將`.env`文件設置為[`artifacts:reports:dotenv` report](../../../ci/variables/README.html#inherit-environment-variables) . 2. 將`load_performance`作業設置為依賴于審閱作業,以便它繼承環境變量. 3. 配置 k6 測試腳本以在其步驟中使用環境變量. 您的`.gitlab-ci.yml`文件可能類似于: ``` stages: - deploy - performance include: template: Verify/Load-Performance-Testing.gitlab-ci.yml review: stage: deploy environment: name: review/$CI_COMMIT_REF_NAME url: http://$CI_ENVIRONMENT_SLUG.example.com script: - run_deploy_script - echo "ENVIRONMENT_URL=$CI_ENVIRONMENT_URL" >> review.env artifacts: reports: dotenv: review.env rules: - if: '$CI_COMMIT_BRANCH' # Modify to match your pipeline rules, or use `only/except` if needed. load_performance: dependencies: - review rules: - if: '$CI_COMMIT_BRANCH' # Modify to match your pipeline rules, or use `only/except` if needed. ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看