測試用例

在 GitHub 上查看源代碼

OpenWeave 包括許多 Python 腳本,用於在模擬的 Happy 拓撲上測試 Weave 功能。這些測試用例確保為網絡連接和 Weave 部署正確配置拓撲。

測試用例腳本中的OpenWeave庫中找到/src/test-apps/happy/tests 。有兩種類型的測試:

  • 服務-測試與服務接口
  • 獨立-測試上本地運行的拓撲結構

跑步

  1. 安裝 OpenWeave。見OpenWeave構建的說明書。
  2. 安裝快樂。看見快樂設置的說明書。
  3. 導航到包含目標測試用例的目錄。例如,運行一個迴聲曲線測試情況:
    cd <path-to-openweave-core>/src/test-apps/happy/tests/standalone/echo
    python test_weave_echo_01.py

Change test topology

OpenWeave test cases run against the sample Happy topologies found in /src/test-apps/happy/topologies/standalone. To use your own custom Happy topology in a test case:

  1. After constructing your custom topology, save it in JSON format. This saves the topology state file in the $HOME directory:
    happy-state -s my_topology.json
  2. In the test case script, locate the topology file being used. Topologies in test cases are typically assigned to the self.topology_file variable. For example, test_weave_echo_01.py uses the following topology for a default OpenWeave build:

    self.topology_file = os.path.dirname(os.path.realpath(__file__)) + \
        "/../../../topologies/standalone/three_nodes_on_thread_weave.json"
    
  3. 更新拓撲路徑以指向您的自定義拓撲狀態文件:

    self.topology_file = "~/my_topology.json"
    
  4. 或者,將您的自定義拓撲狀態文件放在 OpenWeave 中包含的相同位置:

    self.topology_file = os.path.dirname(os.path.realpath(__file__)) + \
        "/../../../topologies/standalone/my_topology.json"
    
  5. 運行測試用例