From: Rafael Zalamena Date: Mon, 26 Jun 2017 13:57:57 +0000 (-0300) Subject: topogen: use shorter names for equipments X-Git-Tag: frr-7.1-dev~151^2~303 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=31bfa9df7901a1c3c157b11e9147adea298f99f9;p=matthieu%2Ffrr.git topogen: use shorter names for equipments After some feedback from mwinter@, the names of equipments are now shorter to make it easier to type them and to keep consistency with mininet documentation. While here, update the template and make it use optional name parameters for clarity. --- diff --git a/tests/topotests/GUIDELINES.md b/tests/topotests/GUIDELINES.md index 9edf795aca..bbaa26f5ab 100644 --- a/tests/topotests/GUIDELINES.md +++ b/tests/topotests/GUIDELINES.md @@ -113,34 +113,34 @@ Here is an example of Graphviz dot file that generates the outdated, please see the linked file): ```dot -graph ospf_topo1 { - label="Template Topology"; - - # Make the Graph fit a A4 paper sheet - # 11inches x 8inches -> ~297mm x ~210mm - size="11,8!"; - # Uncomment this one for vertical A4 paper sheet - #size="8,11!"; +graph template { + label="template"; # Routers - router1 [ + r1 [ shape=octagon, - label="router1", + label="r1", ]; - router2 [ + r2 [ shape=octagon - label="router2\nrtr-id 10.0.255.1", + label="r2", ]; # Switches - switch1 [shape=box]; - switch2 [shape=box]; + s1 [ + shape=box, + label="s1\n192.168.0.0/24", + ]; + s2 [ + shape=box, + label="s2\n192.168.1.0/24", + ]; # Connections - router1 -- switch1 [label="router1-eth0\n192.168.0.1/24"]; + r1 -- s1 [label="eth0\n.1"]; - router1 -- switch2 [label="router1-eth1\n192.168.1.100/24"]; - router2 -- switch2 [label="router2-eth0\n192.168.1.1/24"]; + r1 -- s2 [label="eth1\n.100"]; + r2 -- s2 [label="eth0\n.1"]; } ``` diff --git a/tests/topotests/example-test/test_template.dot b/tests/topotests/example-test/test_template.dot index 4937bee1ac..26def69597 100644 --- a/tests/topotests/example-test/test_template.dot +++ b/tests/topotests/example-test/test_template.dot @@ -1,29 +1,29 @@ -graph ospf_topo1 { - label="Template Topology"; - - # Make the Graph fit a A4 paper sheet - # 11inches x 8inches -> ~297mm x ~210mm - size="11,8!"; - # Uncomment this one for vertical A4 paper sheet - #size="8,11!"; +graph template { + label="template"; # Routers - router1 [ + r1 [ shape=octagon, - label="router1", + label="r1", ]; - router2 [ + r2 [ shape=octagon - label="router2\nrtr-id 10.0.255.1", + label="r2", ]; # Switches - switch1 [shape=box]; - switch2 [shape=box]; + s1 [ + shape=box, + label="s1\n192.168.0.0/24", + ]; + s2 [ + shape=box, + label="s2\n192.168.1.0/24", + ]; # Connections - router1 -- switch1 [label="router1-eth0\n192.168.0.1/24"]; + r1 -- s1 [label="eth0\n.1"]; - router1 -- switch2 [label="router1-eth1\n192.168.1.100/24"]; - router2 -- switch2 [label="router2-eth0\n192.168.1.1/24"]; + r1 -- s2 [label="eth1\n.100"]; + r2 -- s2 [label="eth0\n.1"]; } diff --git a/tests/topotests/example-test/test_template.jpg b/tests/topotests/example-test/test_template.jpg index 2e76c22ee1..d8d7799394 100644 Binary files a/tests/topotests/example-test/test_template.jpg and b/tests/topotests/example-test/test_template.jpg differ diff --git a/tests/topotests/example-test/test_template.py b/tests/topotests/example-test/test_template.py index d5d3b7afb3..ac6faeaa63 100644 --- a/tests/topotests/example-test/test_template.py +++ b/tests/topotests/example-test/test_template.py @@ -52,18 +52,18 @@ class TemplateTopo(Topo): # Example # # Create 2 routers - for _router in range(1, 3): - tgen.add_router() + for routern in range(1, 3): + tgen.add_router('r{}'.format(routern)) # Create a switch with just one router connected to it to simulate a # empty network. - switch = tgen.add_switch() - switch.add_link(tgen.gears['router1']) + switch = tgen.add_switch('s1') + switch.add_link(tgen.gears['r1']) - # Create a connection between router1 and router2 - switch = tgen.add_switch() - switch.add_link(tgen.gears['router1']) - switch.add_link(tgen.gears['router2']) + # Create a connection between r1 and r2 + switch = tgen.add_switch('s2') + switch.add_link(tgen.gears['r1']) + switch.add_link(tgen.gears['r2']) def setup_module(_m): "Sets up the pytest environment" diff --git a/tests/topotests/lib/topogen.py b/tests/topotests/lib/topogen.py index 19c36ed0d7..f437401517 100644 --- a/tests/topotests/lib/topogen.py +++ b/tests/topotests/lib/topogen.py @@ -111,7 +111,7 @@ class Topogen(object): Returns a TopoRouter. """ if name is None: - name = 'router{}'.format(self.routern) + name = 'r{}'.format(self.routern) if name in self.gears: raise KeyError('router already exists') @@ -127,7 +127,7 @@ class Topogen(object): Returns the switch name and number. """ if name is None: - name = 'switch{}'.format(self.switchn) + name = 's{}'.format(self.switchn) if name in self.gears: raise KeyError('switch already exists')