Files
Tobias WaldekranzandJoachim Wiberg 753f3806a1 test: Improve efficiency of logical to physical topology matching
- Present the topologies to networkx as multigraphs, rather than
  expaning each port of the record shape as a separate node.

- Create a topology mapping by locating a subgraph monomorphism of the
  logical topology in the physical ditto.

This cuts down the time of finding a mapping by several orders of
magnitude. Example:

Before:

time python3 test/infamy/topology.py \
     	     test/virt/quad/topology.dot.in \
	     test/infamy/topologies/ring-4-duts.dot >/dev/null

real    13m1,213s
user    13m0,112s
sys     0m0,732s

After:

time python3 test/infamy/topology.py \
     	     test/virt/quad/topology.dot.in \
	     test/infamy/topologies/ring-4-duts.dot >/dev/null

real    0m0,153s
user    0m0,128s
sys     0m0,024s
2024-05-03 14:44:54 +02:00

59 lines
1.4 KiB
Python
Executable File

#!/usr/bin/env python3
import socket
import time
import infamy, infamy.neigh
def ll6ping(node):
neigh = None
cport, nport = env.ptop.get_mgmt_link(ctrl, node)
neigh = infamy.neigh.ll6ping(cport, flags=["-w1", "-c1", "-L", "-n"])
if neigh:
print(f"Found {neigh} on {cport} (connected to {node}:{nport})")
return neigh
return None
def netconf_syn(neigh):
try:
ai = socket.getaddrinfo(neigh, 830, 0, 0, socket.SOL_TCP)
sock = socket.socket(ai[0][0], ai[0][1], 0)
sock.connect(ai[0][4])
sock.close()
print(f"{neigh} answers to TCP connections on port 830 (NETCONF)")
return True
except:
return False
with infamy.Test() as test:
with test.step("Initialize"):
env = infamy.Env()
ctrl = env.ptop.get_ctrl()
infixen = env.ptop.get_infixen()
with test.step(f"Reach {infixen}"):
timeout = time.time() + 300
print(f"Waiting a maximum of 5min for {infixen} to come up")
while infixen and time.time() < timeout:
time.sleep(1)
retry = []
for node in infixen:
neigh = ll6ping(node)
if neigh and netconf_syn(neigh):
continue
retry.append(node)
infixen = retry
if infixen:
print(f"Unable to reach {infixen}")
test.fail()
test.succeed()