Google is committed to advancing racial equity for Black communities. See how.
本頁面由 Cloud Translation API 翻譯而成。
Switch to English

測試用例

在GitHub上查看源代碼

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

測試用例腳本位於OpenWeave存儲庫中,位於/src/test-apps/happy/tests 。有兩種類型的測試:

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

  1. 安裝OpenWeave。有關說明,請參見《 OpenWeave構建指南》。
  2. 安裝快樂。有關說明,請參見快樂安裝指南。
  3. 導航到包含目標測試用例的目錄。例如,運行Echo配置文件測試用例:
    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. 運行測試用例