從 Azure 負載測試匯出測試結果,以用於第三方工具

在本文中,您將瞭解如何匯出 Azure 負載測試測試結果。 您可以使用 Azure 入口網站、CI/CD 工作流程中的成品、使用後端接聽程式,或從 Azure 記憶體帳戶複製結果,以下載結果。 您可以使用這些結果來報告第三方工具,或診斷測試失敗。 Azure 負載測試會以逗號分隔值 (CSV) 檔案格式產生測試結果,並提供負載測試每個應用程式要求的詳細數據。

您也可以使用測試結果來診斷負載測試期間的錯誤。 和 responseCoderesponseMessage 欄位提供失敗要求的詳細資訊。 如需調查錯誤的詳細資訊,請參閱 診斷失敗的負載測試

您可以遵循此處所述的步驟,從 CSV 記錄檔產生 Apache JMeter 儀錶板。

必要條件

  • 具有有效訂用帳戶的 Azure 帳戶。 如尚未擁有 Azure 訂用帳戶,請在開始之前先建立免費帳戶
  • 已完成測試回合的 Azure 負載測試資源。 如果您需要建立 Azure 負載測試資源,請參閱 建立和執行負載測試

測試結果檔案格式

Azure 負載測試會為每個 測試引擎實例產生測試結果 CSV 檔案瞭解如何相應放大負載測試

Azure 負載測試會使用 Apache JMeter CSV 記錄格式。 如需不同欄位的詳細資訊,請參閱 Apache JMeter 檔中的 JMeter 詞彙。

您可以在測試結果檔案中找到負載測試回合之每個應用程式要求的詳細數據。 下列代碼段顯示範例測試結果:

timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect
1676040230680,104,Homepage,200,OK,172.18.33.7-Thread Group 1-5,text,true,,1607,133,5,5,https://www.example.com/,104,0,100
1676040230681,101,Homepage,200,OK,172.18.33.7-Thread Group 1-3,text,true,,1591,133,5,5,https://www.example.com/,101,0,93
1676040230680,101,Homepage,200,OK,172.18.33.7-Thread Group 1-1,text,true,,1591,133,5,5,https://www.example.com/,98,0,94

存取和下載負載測試結果

負載測試回合完成之後,您可以透過 Azure 入口網站 或 CI/CD 工作流程中的成品存取和下載負載測試結果。

重要

對於超過 45 個引擎實例或大於 3 小時測試回合持續時間的負載測試,結果檔案無法下載。 您可以 設定 JMeter 後端接聽程式,將結果 匯出至您選擇的數據存放區,或 從記憶體帳戶容器複製結果。

若要在 Azure 入口網站 下載測試回合的測試結果:

  1. Azure 入口網站 中,移至您的 Azure 負載測試資源。

  2. 在左窗格中,選取 [測試 ] 以檢視測試清單,然後選取您的測試。

    Screenshot that shows the list of tests for an Azure Load Testing resource.

    提示

    若要限制清單中要顯示的測試數目,您可以使用搜尋方塊和 時間範圍 篩選。

  3. 您可以使用下列兩種方式之一,將測試結果檔案下載為 zip 資料夾:

    • 選取您正在使用之負載測試回合旁邊的省略號 (...),然後選取 [ 下載結果檔案]。

      Screenshot that shows how to download the results file for a load test run.

      注意

      負載測試回合必須具有 完成已停止失敗 狀態,才能下載結果檔案。

    • 在 [ 測試回合詳細數據 ] 窗格中,選取 [ 下載],然後選取 [ 結果]。

      Screenshot that shows how to download the test results from the 'Test run details' pane.

  4. 您可以使用任何 zip 工具來擷取資料夾並存取測試結果。

    Screenshot that shows the test results zip file in the downloads list.

    資料夾包含每個測試引擎的個別 CSV 檔案,並包含測試引擎在負載測試期間執行的要求詳細數據。

使用 JMeter 後端接聽程式匯出測試結果

您可以使用 JMeter 後端接聽程式,將測試結果匯出至 InfluxDB、MySQL 或監視工具,例如 Azure 應用程式 Insights。

您可以使用預設 JMeter 後端接聽程式、來自 jmeter-plugins.org 的後端接聽程式,或以 Java 封存 (JAR) 檔案的形式自定義後端接聽程式。

下列代碼段示範如何在 JMeter 檔案中針對 Azure 應用程式 Insights 使用後端接聽程式(JMX):

<BackendListener guiclass="BackendListenerGui" testclass="BackendListener" testname="Backend Listener" enabled="true">
  <elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" enabled="true">
    <collectionProp name="Arguments.arguments">
      <elementProp name="testName" elementType="Argument">
        <stringProp name="Argument.name">testName</stringProp>
        <stringProp name="Argument.value">jmeter</stringProp>
        <stringProp name="Argument.metadata">=</stringProp>
      </elementProp>
      <elementProp name="connectionString" elementType="Argument">
        <stringProp name="Argument.name">connectionString</stringProp>
        <stringProp name="Argument.value">Enter your AppInsights connection string</stringProp>
        <stringProp name="Argument.metadata">=</stringProp>
      </elementProp>
      <elementProp name="liveMetrics" elementType="Argument">
        <stringProp name="Argument.name">liveMetrics</stringProp>
        <stringProp name="Argument.value">true</stringProp>
        <stringProp name="Argument.metadata">=</stringProp>
      </elementProp>
      <elementProp name="samplersList" elementType="Argument">
        <stringProp name="Argument.name">samplersList</stringProp>
        <stringProp name="Argument.value"></stringProp>
        <stringProp name="Argument.metadata">=</stringProp>
      </elementProp>
      <elementProp name="useRegexForSamplerList" elementType="Argument">
        <stringProp name="Argument.name">useRegexForSamplerList</stringProp>
        <stringProp name="Argument.value">false</stringProp>
        <stringProp name="Argument.metadata">=</stringProp>
      </elementProp>
      <elementProp name="logResponseData" elementType="Argument">
        <stringProp name="Argument.name">logResponseData</stringProp>
        <stringProp name="Argument.value">OnFailure</stringProp>
        <stringProp name="Argument.metadata">=</stringProp>
      </elementProp>
      <elementProp name="logSampleData" elementType="Argument">
        <stringProp name="Argument.name">logSampleData</stringProp>
        <stringProp name="Argument.value">OnFailure</stringProp>
        <stringProp name="Argument.metadata">=</stringProp>
      </elementProp>
    </collectionProp>
  </elementProp>
  <stringProp name="classname">io.github.adrianmo.jmeter.backendlistener.azure.AzureBackendClient</stringProp>
</BackendListener>

您可以使用 Azure 應用程式 Insights 後端接聽程式下載完整的範例。

從記憶體帳戶容器複製測試成品

重要

僅針對具有 45 個以上的引擎實例或測試回合持續時間大於 3 小時的負載測試啟用從記憶體帳戶容器複製測試成品。

若要從記憶體帳戶複製測試回合的測試結果和記錄檔,請在 Azure 入口網站:

  1. Azure 入口網站 中,移至您的 Azure 負載測試資源。

  2. 在左窗格中,選取 [測試 ] 以檢視測試清單,然後選取您的測試。

    Screenshot that shows the list of tests for an Azure Load Testing resource.

  3. 從測試回合清單中,選取您的測試回合。

    Screenshot that shows the list of test runs for a test in an Azure Load Testing resource.

    提示

    若要限制清單中要顯示的測試數目,您可以使用搜尋方塊和 時間範圍 篩選。

  4. 在 [ 測試回合詳細數據 ] 窗格中,選取 [ 複製成品]。

    Screenshot that shows how to copy the test artifacts from the 'Test run details' pane.

    注意

    負載測試回合必須位於 [完成]、 [已停止] 或 [失敗 ] 狀態,才能下載結果檔案。

  5. 複製記憶體帳戶容器的SAS URL。

    您可以使用 Azure 儲存體 ExplorerAzCopy 中的 SAS URL,將測試回合的結果 CSV 檔案和記錄檔複製到記憶體帳戶。

    SAS URL 從產生時起 60 分鐘有效。 如果 URL 到期,請選取 [ 複製成品 ] 以產生新的 SAS URL。