Skip to content

Commit

Permalink
Problem: KeyError occurs from netifaces (#1481)
Browse files Browse the repository at this point in the history
* Problem: KeyError occurs from netifaces

avoid network interfaces that doesn't have address info for netifaces.AF_INET

* update doc

* Update testground/benchmark/benchmark/network.py

Signed-off-by: yihuang <[email protected]>

---------

Signed-off-by: yihuang <[email protected]>
Co-authored-by: yihuang <[email protected]>
  • Loading branch information
mmsqe and yihuang authored Jun 21, 2024
1 parent 3a0e503 commit 9570416
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion testground/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ $ TESTGROUND_HOME=$PWD/data testground plan import --from /path/to/cronos/testgr
Run the benchmark test plan in local docker environment:

```bash
$ testground run composition -f /path/to/cronos/testground/benchmark/compositions/local.toml --wait
$ TESTGROUND_HOME=$PWD/data testground run composition -f /path/to/cronos/testground/benchmark/compositions/local.toml --wait
```

### macOS
Expand Down
2 changes: 1 addition & 1 deletion testground/benchmark/benchmark/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ def get_data_ip(params: RunParams) -> ipaddress.IPv4Address:
def ip4_addresses() -> List[ipaddress.IPv4Address]:
ip_list = []
for interface in netifaces.interfaces():
for link in netifaces.ifaddresses(interface)[netifaces.AF_INET]:
for link in netifaces.ifaddresses(interface).get(netifaces.AF_INET, []):
ip_list.append(ipaddress.IPv4Address(link["addr"]))
return ip_list

0 comments on commit 9570416

Please sign in to comment.