Loading src/tests/ryu-openflow/.gitlab-ci.yml +12 −11 Original line number Diff line number Diff line Loading @@ -255,17 +255,18 @@ end2end_test ryu-openflow: - docker exec mininet ovs-ofctl dump-flows s5 # Run end-to-end test: test no connectivity with ping - export TEST_H1_H2="$(curl -s 'http://172.254.252.11:5000/ping?source=h1&target=h2&count=3')" - echo $TEST_H1_H2 - echo $TEST_H1_H2 | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - export TEST_H1_H3="$(curl -s 'http://172.254.252.11:5000/ping?source=h1&target=h3&count=3')" - echo $TEST_H1_H3 - echo $TEST_H1_H3 | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - export TEST_H1_H4="$(curl -s 'http://172.254.252.11:5000/ping?source=h1&target=h4&count=3')" - echo $TEST_H1_H4 - echo $TEST_H1_H4 | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h1&target=h2&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h1&target=h3&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h1&target=h4&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h2&target=h1&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h2&target=h3&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h2&target=h4&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h3&target=h1&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h3&target=h2&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h3&target=h4&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h4&target=h1&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h4&target=h2&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h4&target=h3&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' # # Run end-to-end test: configure service IETF # - > Loading src/tests/ryu-openflow/mininet/custom_pentagon_topology.py +2 −50 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ # limitations under the License. import json, logging, re, socketserver, threading, time import json, logging, socketserver, threading, time from http.server import BaseHTTPRequestHandler, HTTPServer from urllib.parse import parse_qs, urlparse from mininet.topo import Topo Loading Loading @@ -50,16 +50,6 @@ class PentagonTopo(Topo): self.addLink(h4, sw5) def parse_ping_output(output: str): match = re.search(r'(\d+) packets transmitted, (\d+) received', output) if not match: return 0, 0, 0.0 transmitted = int(match.group(1)) received = int(match.group(2)) success_ratio = (received / transmitted) if transmitted else 0.0 return transmitted, received, success_ratio def build_ping_handler(net: Mininet): """ Create a HTTP request handler that performs pings between hosts. Loading @@ -78,32 +68,20 @@ def build_ping_handler(net: Mininet): self.wfile.write(body) def do_GET(self): LOGGER.warning('self.raw_requestline={:s}'.format(str(self.raw_requestline))) LOGGER.warning('self.requestline={:s}'.format(str(self.requestline))) LOGGER.warning('self.path={:s}'.format(str(self.path))) parsed = urlparse(self.path) if parsed.path != '/ping': self._send_json(404, {'error': 'not found'}) return params = parse_qs(parsed.query) LOGGER.warning('params={:s}'.format(str(params))) source = params.get('source', [None])[0] target = params.get('target', [None])[0] count_val = params.get('count', ['3'])[0] LOGGER.warning('source={:s}'.format(str(source))) LOGGER.warning('target={:s}'.format(str(target))) LOGGER.warning('count_val={:s}'.format(str(count_val))) if not source or not target: self._send_json(400, { 'error': 'source and target query parameters are required', 'params': str(params), 'source': str(source), 'target': str(target), 'count_val': str(count_val), }) return Loading @@ -116,15 +94,9 @@ def build_ping_handler(net: Mininet): self._send_json(400, { 'error': 'count must be a positive integer', 'params': str(params), 'source': str(source), 'target': str(target), 'count_val': str(count_val), 'count': str(count), }) return LOGGER.warning('count={:s}'.format(str(count))) src_host = None dst_host = None try: Loading @@ -134,38 +106,18 @@ def build_ping_handler(net: Mininet): self._send_json(404, { 'error': f'Unknown host: {exc}', 'params': str(params), 'source': str(source), 'target': str(target), 'count_val': str(count_val), 'count': str(count), 'src_host': str(src_host), 'dst_host': str(dst_host), }) return LOGGER.warning('src_host={:s}'.format(str(src_host))) LOGGER.warning('dst_host={:s}'.format(str(dst_host))) destination_ip = dst_host.IP() LOGGER.warning('destination_ip={:s}'.format(str(destination_ip))) output = src_host.cmd(f'ping -c {count} {destination_ip}') LOGGER.warning('output={:s}'.format(str(output))) transmitted, received, success_ratio = parse_ping_output(output) LOGGER.warning('transmitted={:s}'.format(str(transmitted))) LOGGER.warning('received={:s}'.format(str(received))) LOGGER.warning('success_ratio={:s}'.format(str(success_ratio))) self._send_json(200, { 'source': source, 'target': target, 'destination_ip': destination_ip, 'count': count, 'packets_transmitted': transmitted, 'packets_received': received, 'success_ratio': success_ratio, 'raw_output': output 'output': output, }) return PingHandler Loading Loading
src/tests/ryu-openflow/.gitlab-ci.yml +12 −11 Original line number Diff line number Diff line Loading @@ -255,17 +255,18 @@ end2end_test ryu-openflow: - docker exec mininet ovs-ofctl dump-flows s5 # Run end-to-end test: test no connectivity with ping - export TEST_H1_H2="$(curl -s 'http://172.254.252.11:5000/ping?source=h1&target=h2&count=3')" - echo $TEST_H1_H2 - echo $TEST_H1_H2 | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - export TEST_H1_H3="$(curl -s 'http://172.254.252.11:5000/ping?source=h1&target=h3&count=3')" - echo $TEST_H1_H3 - echo $TEST_H1_H3 | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - export TEST_H1_H4="$(curl -s 'http://172.254.252.11:5000/ping?source=h1&target=h4&count=3')" - echo $TEST_H1_H4 - echo $TEST_H1_H4 | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h1&target=h2&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h1&target=h3&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h1&target=h4&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h2&target=h1&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h2&target=h3&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h2&target=h4&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h3&target=h1&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h3&target=h2&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h3&target=h4&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h4&target=h1&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h4&target=h2&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' - curl -s 'http://172.254.252.11:5000/ping?source=h4&target=h3&count=3' | grep -E '3 packets transmitted, 0 received, 100\% packet loss' # # Run end-to-end test: configure service IETF # - > Loading
src/tests/ryu-openflow/mininet/custom_pentagon_topology.py +2 −50 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ # limitations under the License. import json, logging, re, socketserver, threading, time import json, logging, socketserver, threading, time from http.server import BaseHTTPRequestHandler, HTTPServer from urllib.parse import parse_qs, urlparse from mininet.topo import Topo Loading Loading @@ -50,16 +50,6 @@ class PentagonTopo(Topo): self.addLink(h4, sw5) def parse_ping_output(output: str): match = re.search(r'(\d+) packets transmitted, (\d+) received', output) if not match: return 0, 0, 0.0 transmitted = int(match.group(1)) received = int(match.group(2)) success_ratio = (received / transmitted) if transmitted else 0.0 return transmitted, received, success_ratio def build_ping_handler(net: Mininet): """ Create a HTTP request handler that performs pings between hosts. Loading @@ -78,32 +68,20 @@ def build_ping_handler(net: Mininet): self.wfile.write(body) def do_GET(self): LOGGER.warning('self.raw_requestline={:s}'.format(str(self.raw_requestline))) LOGGER.warning('self.requestline={:s}'.format(str(self.requestline))) LOGGER.warning('self.path={:s}'.format(str(self.path))) parsed = urlparse(self.path) if parsed.path != '/ping': self._send_json(404, {'error': 'not found'}) return params = parse_qs(parsed.query) LOGGER.warning('params={:s}'.format(str(params))) source = params.get('source', [None])[0] target = params.get('target', [None])[0] count_val = params.get('count', ['3'])[0] LOGGER.warning('source={:s}'.format(str(source))) LOGGER.warning('target={:s}'.format(str(target))) LOGGER.warning('count_val={:s}'.format(str(count_val))) if not source or not target: self._send_json(400, { 'error': 'source and target query parameters are required', 'params': str(params), 'source': str(source), 'target': str(target), 'count_val': str(count_val), }) return Loading @@ -116,15 +94,9 @@ def build_ping_handler(net: Mininet): self._send_json(400, { 'error': 'count must be a positive integer', 'params': str(params), 'source': str(source), 'target': str(target), 'count_val': str(count_val), 'count': str(count), }) return LOGGER.warning('count={:s}'.format(str(count))) src_host = None dst_host = None try: Loading @@ -134,38 +106,18 @@ def build_ping_handler(net: Mininet): self._send_json(404, { 'error': f'Unknown host: {exc}', 'params': str(params), 'source': str(source), 'target': str(target), 'count_val': str(count_val), 'count': str(count), 'src_host': str(src_host), 'dst_host': str(dst_host), }) return LOGGER.warning('src_host={:s}'.format(str(src_host))) LOGGER.warning('dst_host={:s}'.format(str(dst_host))) destination_ip = dst_host.IP() LOGGER.warning('destination_ip={:s}'.format(str(destination_ip))) output = src_host.cmd(f'ping -c {count} {destination_ip}') LOGGER.warning('output={:s}'.format(str(output))) transmitted, received, success_ratio = parse_ping_output(output) LOGGER.warning('transmitted={:s}'.format(str(transmitted))) LOGGER.warning('received={:s}'.format(str(received))) LOGGER.warning('success_ratio={:s}'.format(str(success_ratio))) self._send_json(200, { 'source': source, 'target': target, 'destination_ip': destination_ip, 'count': count, 'packets_transmitted': transmitted, 'packets_received': received, 'success_ratio': success_ratio, 'raw_output': output 'output': output, }) return PingHandler Loading