mirror of
https://github.com/espressif/openthread.git
synced 2026-06-06 05:24:51 +00:00
[harness-simulation] change config format from JSON to YAML (#8176)
This commit changes the format of the configuration file from JSON to YAML, as YAML is designed for human interaction and better suitable for configuration than JSON.
This commit is contained in:
@@ -10,7 +10,7 @@ Platform developers should modify the THCI implementation and/or the SI implemen
|
||||
|
||||
## POSIX Environment Setup
|
||||
|
||||
1. Open the JSON format configuration file `tools/harness-simulation/posix/simulation.conf`:
|
||||
1. Open the JSON format configuration file `tools/harness-simulation/posix/config.yml`:
|
||||
|
||||
- Edit the value of `ot_path` to the absolute path where the top directory of the OpenThread repository is located. For example, change the value of `ot_path` to `/home/<username>/repo/openthread`.
|
||||
- For each entry in `ot_build.ot`, update the value of `number` to be the number of OT FTD simulations needed with the corresponding version.
|
||||
@@ -42,10 +42,10 @@ Platform developers should modify the THCI implementation and/or the SI implemen
|
||||
|
||||
```bash
|
||||
$ cd tools/harness-simulation/posix
|
||||
$ ./launch_testbed.py -c simulation.conf
|
||||
$ ./launch_testbed.py -c config.yml
|
||||
```
|
||||
|
||||
This example starts several OT FTD simulations, OTBR simulations, and sniffer simulations and can be discovered on `eth0`. The number of each type of simulation is specified in the configuration file `simulation.conf`.
|
||||
This example starts several OT FTD simulations, OTBR simulations, and sniffer simulations and can be discovered on `eth0`. The number of each type of simulation is specified in the configuration file `config.yml`.
|
||||
|
||||
2. Run the Test Harness. The information field of the device is encoded as `<tag>_<node_id>@<ip_addr>`. Choose the desired device as the DUT.
|
||||
|
||||
|
||||
@@ -27,13 +27,13 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import json
|
||||
import os
|
||||
import yaml
|
||||
|
||||
CONFIG_PATH = r'%s\GRL\Thread1.2\Thread_Harness\simulation\simulation.conf' % os.environ['systemdrive']
|
||||
CONFIG_PATH = r'%s\GRL\Thread1.2\Thread_Harness\simulation\config.yml' % os.environ['systemdrive']
|
||||
|
||||
|
||||
def load_config():
|
||||
with open(CONFIG_PATH, 'rt') as f:
|
||||
config = json.load(f)
|
||||
config = yaml.safe_load(f)
|
||||
return config
|
||||
|
||||
@@ -31,7 +31,7 @@ copy /Y ..\..\harness-thci\OpenThread.py %THREADDIR%\Thread_Harness\THCI
|
||||
copy /Y ..\..\harness-thci\OpenThread_BR.py %THREADDIR%\Thread_Harness\THCI
|
||||
copy /Y ..\..\harness-thci\OpenThread.png %THREADDIR%\Web\images
|
||||
copy /Y ..\..\harness-thci\OpenThread_BR.png %THREADDIR%\Web\images
|
||||
copy /Y ..\posix\simulation.conf %THREADDIR%\Thread_Harness\simulation
|
||||
copy /Y ..\posix\config.yml %THREADDIR%\Thread_Harness\simulation
|
||||
xcopy /E /Y ..\posix\sniffer_sim\proto %THREADDIR%\Thread_Harness\simulation\Sniffer\proto
|
||||
|
||||
%THREADDIR%\Python27\python.exe -m pip install --upgrade pip
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
grpcio==1.20.1
|
||||
grpcio-tools==1.20.1
|
||||
PyYAML==5.4.1
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
ot_path: "/home/pi/repo/openthread"
|
||||
ot_build:
|
||||
max_number: 64
|
||||
ot:
|
||||
- tag: OT11
|
||||
version: '1.1'
|
||||
number: 33
|
||||
subpath: build/ot11/simulation
|
||||
cflags:
|
||||
- "-DOPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS=8"
|
||||
options:
|
||||
- "-DOT_REFERENCE_DEVICE=ON"
|
||||
- "-DOT_COMMISSIONER=ON"
|
||||
- "-DOT_JOINER=ON"
|
||||
- tag: OT12
|
||||
version: '1.2'
|
||||
number: 10
|
||||
subpath: build/ot12/simulation
|
||||
cflags:
|
||||
- "-DOPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS=8"
|
||||
options:
|
||||
- "-DOT_REFERENCE_DEVICE=ON"
|
||||
- "-DOT_DUA=ON"
|
||||
- "-DOT_MLR=ON"
|
||||
- "-DOT_COMMISSIONER=ON"
|
||||
- "-DOT_JOINER=ON"
|
||||
- "-DOT_CSL_RECEIVER=ON"
|
||||
- "-DOT_LINK_METRICS_SUBJECT=ON"
|
||||
- "-DOT_LINK_METRICS_INITIATOR=ON"
|
||||
- tag: OT13
|
||||
version: '1.3'
|
||||
number: 10
|
||||
subpath: build/ot13/simulation
|
||||
cflags:
|
||||
- "-DOPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS=8"
|
||||
options:
|
||||
- "-DOT_REFERENCE_DEVICE=ON"
|
||||
- "-DOT_DUA=ON"
|
||||
- "-DOT_MLR=ON"
|
||||
- "-DOT_COMMISSIONER=ON"
|
||||
- "-DOT_JOINER=ON"
|
||||
- "-DOT_CSL_RECEIVER=ON"
|
||||
- "-DOT_LINK_METRICS_SUBJECT=ON"
|
||||
- "-DOT_LINK_METRICS_INITIATOR=ON"
|
||||
otbr:
|
||||
- tag: OTBR12
|
||||
version: '1.2'
|
||||
number: 4
|
||||
docker_image: otbr-reference-device-1.2
|
||||
build_args:
|
||||
- REFERENCE_DEVICE=1
|
||||
- BORDER_ROUTING=0
|
||||
- BACKBONE_ROUTER=1
|
||||
- NAT64=0
|
||||
- WEB_GUI=0
|
||||
- REST_API=0
|
||||
- OT_COMMISSIONER=1
|
||||
options:
|
||||
- "-DOTBR_DUA_ROUTING=ON"
|
||||
- "-DOT_DUA=ON"
|
||||
- "-DOT_MLR=ON"
|
||||
rcp_subpath: build/ot12/simulation
|
||||
rcp_options:
|
||||
- "-DOT_LINK_METRICS_SUBJECT=ON"
|
||||
- tag: OTBR13
|
||||
version: '1.3'
|
||||
number: 4
|
||||
docker_image: otbr-reference-device-1.3
|
||||
build_args:
|
||||
- REFERENCE_DEVICE=1
|
||||
- BORDER_ROUTING=1
|
||||
- BACKBONE_ROUTER=1
|
||||
- NAT64=0
|
||||
- WEB_GUI=0
|
||||
- REST_API=0
|
||||
- EXTERNAL_COMMISSIONER=1
|
||||
options:
|
||||
- "-DOTBR_DUA_ROUTING=ON"
|
||||
- "-DOT_DUA=ON"
|
||||
- "-DOT_MLR=ON"
|
||||
rcp_subpath: build/ot13/simulation
|
||||
rcp_options:
|
||||
- "-DOT_LINK_METRICS_SUBJECT=ON"
|
||||
ssh:
|
||||
username: pi
|
||||
password: raspberry
|
||||
port: 22
|
||||
sniffer:
|
||||
number: 2
|
||||
server_port_base: 50051
|
||||
discovery_ifname: eth0
|
||||
@@ -34,14 +34,6 @@ OT_DIR="${POSIX_DIR}/../../.."
|
||||
ETC_DIR="${POSIX_DIR}/etc"
|
||||
SNIFFER_DIR="${POSIX_DIR}/sniffer_sim"
|
||||
|
||||
CONFIG=${1:-"${POSIX_DIR}/simulation.conf"}
|
||||
# Use absolute path in case of changing current working directory
|
||||
if [[ ${CONFIG:0:1} != '/' ]]; then
|
||||
CONFIG="${POSIX_DIR}/${CONFIG}"
|
||||
fi
|
||||
|
||||
MAX_NETWORK_SIZE=$(jq -r '.ot_build.max_number' "$CONFIG")
|
||||
|
||||
PACKAGES=(
|
||||
"docker.io"
|
||||
"git"
|
||||
@@ -55,6 +47,12 @@ sudo apt install -y "${PACKAGES[@]}"
|
||||
pip3 install -r "${POSIX_DIR}/requirements.txt"
|
||||
python3 -m grpc_tools.protoc -I"${SNIFFER_DIR}" --python_out="${SNIFFER_DIR}" --grpc_python_out="${SNIFFER_DIR}" proto/sniffer.proto
|
||||
|
||||
CONFIG_NAME=${1:-"${POSIX_DIR}/config.yml"}
|
||||
# convert YAML to JSON
|
||||
CONFIG=$(python3 -c 'import json, sys, yaml; print(json.dumps(yaml.safe_load(open(sys.argv[1]))))' "$CONFIG_NAME")
|
||||
|
||||
MAX_NETWORK_SIZE=$(jq -r '.ot_build.max_number' <<<"$CONFIG")
|
||||
|
||||
build_ot()
|
||||
{
|
||||
# SC2155: Declare and assign separately to avoid masking return values
|
||||
@@ -126,7 +124,7 @@ build_otbr()
|
||||
--build-arg OTBR_OPTIONS="${otbr_options[*]}"
|
||||
}
|
||||
|
||||
for item in $(jq -c '.ot_build.ot | .[]' "$CONFIG"); do
|
||||
for item in $(jq -c '.ot_build.ot | .[]' <<<"$CONFIG"); do
|
||||
build_ot "$item"
|
||||
done
|
||||
|
||||
@@ -144,7 +142,7 @@ git clone https://github.com/openthread/ot-br-posix.git --recurse-submodules --s
|
||||
mkdir -p root/tmp
|
||||
cp "${ETC_DIR}/requirements.txt" root/tmp/requirements.txt
|
||||
|
||||
for item in $(jq -c '.ot_build.otbr | .[]' "$CONFIG"); do
|
||||
for item in $(jq -c '.ot_build.otbr | .[]' <<<"$CONFIG"); do
|
||||
build_otbr "$item"
|
||||
done
|
||||
)
|
||||
|
||||
@@ -40,6 +40,7 @@ import struct
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import Iterable
|
||||
import yaml
|
||||
|
||||
from otbr_sim import otbr_docker
|
||||
|
||||
@@ -140,7 +141,7 @@ def main():
|
||||
help='the path of the configuration JSON file')
|
||||
args = parser.parse_args()
|
||||
with open(args.config, 'rt') as f:
|
||||
config = json.load(f)
|
||||
config = yaml.safe_load(f)
|
||||
|
||||
ot_path = config['ot_path']
|
||||
ot_build = config['ot_build']
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
grpcio
|
||||
grpcio-tools
|
||||
PyYAML
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
{
|
||||
"ot_path": "/home/pi/repo/openthread",
|
||||
"ot_build": {
|
||||
"max_number": 64,
|
||||
"ot": [
|
||||
{
|
||||
"tag": "OT11",
|
||||
"version": "1.1",
|
||||
"number": 33,
|
||||
"subpath": "build/ot11/simulation",
|
||||
"cflags": [
|
||||
"-DOPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS=8"
|
||||
],
|
||||
"options": [
|
||||
"-DOT_REFERENCE_DEVICE=ON",
|
||||
"-DOT_COMMISSIONER=ON",
|
||||
"-DOT_JOINER=ON"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "OT12",
|
||||
"version": "1.2",
|
||||
"number": 10,
|
||||
"subpath": "build/ot12/simulation",
|
||||
"cflags": [
|
||||
"-DOPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS=8"
|
||||
],
|
||||
"options": [
|
||||
"-DOT_REFERENCE_DEVICE=ON",
|
||||
"-DOT_DUA=ON",
|
||||
"-DOT_MLR=ON",
|
||||
"-DOT_COMMISSIONER=ON",
|
||||
"-DOT_JOINER=ON",
|
||||
"-DOT_CSL_RECEIVER=ON",
|
||||
"-DOT_LINK_METRICS_SUBJECT=ON",
|
||||
"-DOT_LINK_METRICS_INITIATOR=ON"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "OT13",
|
||||
"version": "1.3",
|
||||
"number": 10,
|
||||
"subpath": "build/ot13/simulation",
|
||||
"cflags": [
|
||||
"-DOPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS=8"
|
||||
],
|
||||
"options": [
|
||||
"-DOT_REFERENCE_DEVICE=ON",
|
||||
"-DOT_DUA=ON",
|
||||
"-DOT_MLR=ON",
|
||||
"-DOT_COMMISSIONER=ON",
|
||||
"-DOT_JOINER=ON",
|
||||
"-DOT_CSL_RECEIVER=ON",
|
||||
"-DOT_LINK_METRICS_SUBJECT=ON",
|
||||
"-DOT_LINK_METRICS_INITIATOR=ON"
|
||||
]
|
||||
}
|
||||
],
|
||||
"otbr": [
|
||||
{
|
||||
"tag": "OTBR12",
|
||||
"version": "1.2",
|
||||
"number": 4,
|
||||
"docker_image": "otbr-reference-device-1.2",
|
||||
"build_args": [
|
||||
"REFERENCE_DEVICE=1",
|
||||
"BORDER_ROUTING=0",
|
||||
"BACKBONE_ROUTER=1",
|
||||
"NAT64=0",
|
||||
"WEB_GUI=0",
|
||||
"REST_API=0",
|
||||
"OT_COMMISSIONER=1"
|
||||
],
|
||||
"options": [
|
||||
"-DOTBR_DUA_ROUTING=ON",
|
||||
"-DOT_DUA=ON",
|
||||
"-DOT_MLR=ON"
|
||||
],
|
||||
"rcp_subpath": "build/ot12/simulation",
|
||||
"rcp_options": [
|
||||
"-DOT_LINK_METRICS_SUBJECT=ON"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "OTBR13",
|
||||
"version": "1.3",
|
||||
"number": 4,
|
||||
"docker_image": "otbr-reference-device-1.3",
|
||||
"build_args": [
|
||||
"REFERENCE_DEVICE=1",
|
||||
"BORDER_ROUTING=1",
|
||||
"BACKBONE_ROUTER=1",
|
||||
"NAT64=0",
|
||||
"WEB_GUI=0",
|
||||
"REST_API=0",
|
||||
"EXTERNAL_COMMISSIONER=1"
|
||||
],
|
||||
"options": [
|
||||
"-DOTBR_DUA_ROUTING=ON",
|
||||
"-DOT_DUA=ON",
|
||||
"-DOT_MLR=ON"
|
||||
],
|
||||
"rcp_subpath": "build/ot13/simulation",
|
||||
"rcp_options": [
|
||||
"-DOT_LINK_METRICS_SUBJECT=ON"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"ssh": {
|
||||
"username": "pi",
|
||||
"password": "raspberry",
|
||||
"port": 22
|
||||
},
|
||||
"sniffer": {
|
||||
"number": 2,
|
||||
"server_port_base": 50051
|
||||
},
|
||||
"discovery_ifname": "eth0"
|
||||
}
|
||||
Reference in New Issue
Block a user