Don't hardcode service counts to check health
In core-network.py , the deploy()
function takes a count
argument giving the expected number of running services in "good health" condition:
deploy(BASIC_W_NRF, 9)
This hand-coding of the count is error-prone, hard to maintain, and not friendly to user customization (e.g --type start-custom MYFILE.yaml
).
Instead, it is possible to inspect the yaml file (with the python yaml module) to extract the (static) list of services it is supposed to launch, and then compare it with what's actually running:
import yaml
with open('docker-compose-basic-nrf.yaml') as f:
data = yaml.load(f, Loader=yaml.FullLoader)
print(data['services'].keys())
=>
dict_keys(['mysql', 'oai-udr', 'oai-udm', 'oai-ausf', 'oai-nrf', 'oai-amf', 'oai-smf', 'oai-spgwu', 'oai-ext-dn'])
$ docker-compose -f docker-compose-basic-nrf.yaml ps -a | fgrep '(healthy)'
mysql "docker-entrypoint.s…" mysql running (healthy) 3306/tcp, 33060/tcp
oai-amf "/bin/bash /openair-…" oai-amf running (healthy) 80/tcp, 9090/tcp, 38412/sctp
oai-ausf "/bin/bash /openair-…" oai-ausf running (healthy) 80/tcp
oai-ext-dn "/bin/bash -c ' ip r…" oai-ext-dn running (healthy)
oai-nrf "/bin/bash /openair-…" oai-nrf running (healthy) 80/tcp, 9090/tcp
oai-smf "/bin/bash /openair-…" oai-smf running (healthy) 80/tcp, 8080/tcp, 8805/udp
oai-spgwu "/bin/bash /openair-…" oai-spgwu running (healthy) 2152/udp, 8805/udp
oai-udm "/bin/bash /openair-…" oai-udm running (healthy) 80/tcp
oai-udr "/bin/bash /openair-…" oai-udr running (healthy) 80/tcp
Edited by Alexandre Ferrieux