在 GitHub 上查看源代码 |
OpenWeave 包括许多 Python 脚本,用于在模拟的 Happy 拓扑上测试 Weave 功能。这些测试用例确保为网络连接和 Weave 部署正确配置拓扑。
测试用例脚本中的OpenWeave库中找到/src/test-apps/happy/tests
。有两种类型的测试:
跑步
- 安装 OpenWeave。见OpenWeave构建的说明书。
- 安装快乐。看见快乐设置的说明书。
- 导航到包含目标测试用例的目录。例如,运行一个回声曲线测试情况:
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:
- 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
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"
更新拓扑路径以指向您的自定义拓扑状态文件:
self.topology_file = "~/my_topology.json"
或者,将您的自定义拓扑状态文件放在 OpenWeave 中包含的相同位置:
self.topology_file = os.path.dirname(os.path.realpath(__file__)) + \ "/../../../topologies/standalone/my_topology.json"