查看 IDT 测试结果和日志 - AWS IoT Greengrass

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

查看 IDT 测试结果和日志

本节介绍 IDT 生成控制台日志和测试报告的格式。

控制台消息格式

AWS IoT Device Tester在控制台启动测试套件时,使用标准格式将消息打印到控制台。以下摘录显示了 IDT 生成的控制台消息的示例。

time="2000-01-02T03:04:05-07:00" level=info msg=Using suite: MyTestSuite_1.0.0 executionId=9a52f362-1227-11eb-86c9-8c8590419f30

大多数控制台消息包含以下字段:

time

记录的事件的完整 ISO 8601 时间戳。

level

记录事件的消息级别。通常,记录的消息级别是其中之一infowarn,或者error. IDT 发行fatal要么panic如果遇到导致其提前退出的预期事件,则会发送消息。

msg

记录的消息。

executionId

当前 IDT 流程的唯一 ID 字符串。此 ID 用于区分个别 IDT 运行。

从测试套件生成的控制台消息提供了有关被测设备以及 IDT 运行的测试套件、测试组和测试用例的其他信息。以下摘录显示了从测试套件生成的控制台消息的示例。

time="2000-01-02T03:04:05-07:00" level=info msg=Hello world! suiteId=MyTestSuite groupId=myTestGroup testCaseId=myTestCase deviceId=my-device executionId=9a52f362-1227-11eb-86c9-8c8590419f30

控制台消息的测试套件特定部分包含以下字段:

suiteId

当前运行的测试套件的名称。

groupId

当前运行的测试组的 ID。

testCaseId

当前正在运行的测试用例的 ID。

deviceId

当前测试用例正在使用的受测设备的 ID。

要在 IDT 完成测试运行时向控制台打印测试摘要,您必须包含Reportstate在你的测试管弦乐队里。测试摘要包含有关测试套件的信息、运行的每个组的测试结果以及生成的日志和报告文件的位置。以下示例显示了测试摘要消息。

========== Test Summary ========== Execution Time: 5m00s Tests Completed: 4 Tests Passed: 3 Tests Failed: 1 Tests Skipped: 0 ---------------------------------- Test Groups: GroupA: PASSED GroupB: FAILED ---------------------------------- Failed Tests: Group Name: GroupB Test Name: TestB1 Reason: Something bad happened ---------------------------------- Path to IoT Device Tester Report: /path/to/awsiotdevicetester_report.xml Path to Test Execution Logs: /path/to/logs Path to Aggregated JUnit Report: /path/to/MyTestSuite_Report.xml

AWS IoT Device Tester报告架构

awsiotdevicetester_report.xml是一份包含以下信息的签名报告:

  • IDT 版本。

  • 测试套件版本。

  • 用于签署报告的报告签名和密钥。

  • 中指定的设备 SKU 以及设备池名称device.json文件。

  • 测试的产品版本和设备功能。

  • 测试结果的摘要汇总。此信息与中包含的信息相同suite-name_report.xml文件。

<apnreport> <awsiotdevicetesterversion>idt-version</awsiotdevicetesterversion> <testsuiteversion>test-suite-version</testsuiteversion> <signature>signature</signature> <keyname>keyname</keyname> <session> <testsession>execution-id</testsession> <starttime>start-time</starttime> <endtime>end-time</endtime> </session> <awsproduct> <name>product-name</name> <version>product-version</version> <features> <feature name="<feature-name>" value="supported | not-supported | <feature-value>" type="optional | required"/> </features> </awsproduct> <device> <sku>device-sku</sku> <name>device-name</name> <features> <feature name="<feature-name>" value="<feature-value>"/> </features> <executionMethod>ssh | uart | docker</executionMethod> </device> <devenvironment> <os name="<os-name>"/> </devenvironment> <report> <suite-name-report-contents> </report> </apnreport>

awsiotdevicetester_report.xml 文件包含一个 <awsproduct> 标签,其中包含有关正测试的产品以及在运行测试套件后验证的产品功能的信息。

<awsproduct> 标签中使用的属性
name

所测试的产品的名称。

version

所测试的产品的版本。

features

验证的功能。标记为required是测试套件验证设备所必需的。以下代码段演示了此信息在 awsiotdevicetester_report.xml 文件中的显示方式。

<feature name="ssh" value="supported" type="required"></feature>

标记为optional是验证所必需的。以下代码段显示了可选功能。

<feature name="hsi" value="supported" type="optional"></feature>
 <feature name="mqtt" value="not-supported" type="optional"></feature>

测试套件报告架构

suite-name_Result.xml 报告采用 JUnit XML 格式。您可以将它集成到持续集成和开发平台,例如 JenkinsBamboo 等。此报告包含测试结果的摘要汇总。

<testsuites name="<suite-name> results" time="<run-duration>" tests="<number-of-test>" failures="<number-of-tests>" skipped="<number-of-tests>" errors="<number-of-tests>" disabled="0"> <testsuite name="<test-group-id>" package="" tests="<number-of-tests>" failures="<number-of-tests>" skipped="<number-of-tests>" errors="<number-of-tests>" disabled="0"> <!--success--> <testcase classname="<classname>" name="<name>" time="<run-duration>"/> <!--failure--> <testcase classname="<classname>" name="<name>" time="<run-duration>"> <failure type="<failure-type>"> reason </failure> </testcase> <!--skipped--> <testcase classname="<classname>" name="<name>" time="<run-duration>"> <skipped> reason </skipped> </testcase> <!--error--> <testcase classname="<classname>" name="<name>" time="<run-duration>"> <error> reason </error> </testcase> </testsuite> </testsuites>

两者中的报告部分awsiotdevicetester_report.xml要么suite-name_report.xml列出了已经运行的测试以及结果。

第一个 XML 标签 <testsuites> 包含测试执行情况的摘要。例如:

<testsuites name="MyTestSuite results" time="2299" tests="28" failures="0" errors="0" disabled="0">
<testsuites> 标签中使用的属性
name

测试套件的名称。

time

运行测试套件所用的时间(以秒为单位)。

tests

执行的测试数。

failures

已运行但未通过的测试数。

errors

IDT 无法执行的测试数。

disabled

此属性未使用,可以忽略。

如果出现测试失败或错误,则可以通过检查 <testsuites> XML 标签来确定失败的测试。<testsuites> 标签内的 <testsuite> XML 标签显示了测试组的测试结果摘要。例如:

<testsuite name="combination" package="" tests="1" failures="0" time="161" disabled="0" errors="0" skipped="0">

其格式与 <testsuites> 标签类似,但包含一个未使用并可忽略的 skipped 属性。在每个 <testsuite> XML 标签内部,对于一个测试组,所执行的每个测试都有 <testcase> 标签。例如:

<testcase classname="Security Test" name="IP Change Tests" attempts="1"></testcase>>
<testcase> 标签中使用的属性
name

测试的名称。

attempts

IDT 执行测试用例的次数。

当测试失败或出现错误时,将会在 <testcase> 标签中添加包含用于故障排除的信息的 <failure><error> 标签。例如:

<testcase classname="mcu.Full_MQTT" name="MQTT_TestCase" attempts="1"> <failure type="Failure">Reason for the test failure</failure> <error>Reason for the test execution error</error> </testcase>