Skip to content

Commit 7a5cd1f

Browse files
committed
Module tests with Python 3
1 parent 20b1255 commit 7a5cd1f

26 files changed

Lines changed: 66 additions & 68 deletions

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ before_install:
3333
install:
3434
- sudo apt-get install -y python2.7 python3 python3-pip
3535
- pip2 install grpcio scapy codecov
36-
- pip3 install grpcio coverage
36+
- pip3 install grpcio scapy-python3 coverage
3737
- "[[ ${DEBUG:-0} == 0 ]] || sudo apt-get install -y g++-5" # install gcov-5
3838
- "[[ ${SANITIZE:-0} == 0 ]] || sudo apt-get install -y llvm-3.8"
3939
- "[[ $TAG_SUFFIX != _32 ]] || sudo apt-get install -y lib32gcc1"
@@ -53,7 +53,8 @@ script:
5353
- (cd core && ./all_test) # TcpFlowReconstructTest requires working directory to be `core/`
5454
- coverage2 run -m unittest discover -v
5555
- coverage3 run -m unittest discover -v
56-
- bessctl/bessctl -- daemon start -- run testing/run_module_tests
56+
- python2 bessctl/bessctl -- daemon start -- run testing/run_module_tests
57+
- python3 bessctl/bessctl -- daemon start -- run testing/run_module_tests
5758

5859
after_success:
5960
- bessctl/bessctl daemon stop # flush out the coverage data

bessctl/conf/perftest/bpf.bess

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ bpf:2 -> Sink() # for matched packets (by the second filter)
1010

1111
def run_testcase(exps, test_pkts):
1212
rewrite.clear()
13-
rewrite.add(templates=map(lambda x: str(x), test_pkts))
13+
rewrite.add(templates=map(lambda x: bytes(x), test_pkts))
1414

1515
# the higher number, the higher priority.
1616
bpf.clear()

bessctl/conf/perftest/flowgen.bess

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ip = scapy.IP(src=src_ip, dst=dst_ip)
2323
src_port = int($BESS_SRC_PORT!'10001')
2424
tcp = scapy.TCP(sport=src_port, dport=12345, seq=12345)
2525
payload = "BESS is the Queen of Packet Processing."
26-
pkt_template = str(eth/ip/tcp/payload)
26+
pkt_template = bytes(eth/ip/tcp/payload)
2727

2828
# This script is multi threaded but connects to a single port.
2929
myport = PMDPort(port_id=0, num_inc_q=num_cores, num_out_q=num_cores)
@@ -49,7 +49,7 @@ while True:
4949
portstats = myport.get_port_stats().inc.packets
5050
delta = portstats - prev_portstats
5151
nextround = max(1e6, 1.1 * delta / sleeptime)
52-
print("Received " + str(delta / sleeptime) + " pps. Ramping up to: " + str(nextround))
52+
print("Received " + bytes(delta / sleeptime) + " pps. Ramping up to: " + bytes(nextround))
5353
for wid, pkt_src in flowgens.items():
5454
bess.pause_worker(wid)
5555
pkt_src.update(pps = nextround / num_cores)

bessctl/conf/perftest/nat.bess

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ eth = scapy.Ether(src='02:1e:67:9f:4d:ac', dst='06:16:3e:1b:72:32')
1010
ip = scapy.IP(src='10.0.0.1', dst='192.168.1.1')
1111
udp = scapy.UDP(sport=10001, dport=10002)
1212
payload = 'helloworld'
13-
pkt_bytes = str(eth/ip/udp/payload)
13+
pkt_bytes = bytes(eth/ip/udp/payload)
1414

1515
Source() \
1616
-> Rewrite(templates=[pkt_bytes]) \

bessctl/conf/perftest/pktgen.bess

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def build_pkt(size):
2121
payload = ('hello' + '0123456789' * 200)[:size-len(eth/ip/udp)]
2222
pkt = eth/ip/udp/payload
2323
pkt.show()
24-
return str(pkt)
24+
return bytes(pkt)
2525

2626
if imix:
2727
# https://en.wikipedia.org/wiki/Internet_Mix
@@ -45,7 +45,7 @@ ports = [PMDPort(port_id=i, num_inc_q=num_cores, num_out_q=num_cores) \
4545
for i in range(num_ports)]
4646

4747
for i in range(num_cores):
48-
print("starting up worker: " + str(i))
48+
print("starting up worker: " + bytes(i))
4949
bess.add_worker(wid=i, core=i)
5050

5151
src = Source()

bessctl/conf/port/unix_port.bess

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ else:
3838
s.connect(SOCKET_PATH)
3939

4040
for i in range(ITERATION):
41-
original = gen_packet('10.0.0.1', '192.168.1.10' + str(i))
42-
s.send(str(original))
41+
original = gen_packet('10.0.0.1', '192.168.1.10' + bytes(i))
42+
s.send(bytes(original))
4343

4444
modified = s.recv(2048)
4545
pkt = scapy.Ether(modified)

bessctl/conf/samples/acl.bess

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def gen_packet(proto, src_ip, dst_ip):
77
udp = proto(sport=10001, dport=10002)
88
payload = 'helloworld'
99
pkt = eth/ip/udp/payload
10-
return str(pkt)
10+
return bytes(pkt)
1111

1212
packets = [gen_packet(scapy.UDP, '172.16.100.1', '10.0.0.1'),
1313
gen_packet(scapy.UDP, '172.12.55.99', '12.34.56.78'),

bessctl/conf/samples/drr.bess

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ ip1 = scapy.IP(src='192.168.1.1', dst='10.0.0.1')
55
ip2 = scapy.IP(src='192.168.2.2', dst= '10.0.0.2')
66
udp = scapy.UDP(sport=10001, dport=10002)
77
payload = 'helloworld'
8-
pkt_bytes1 = str(eth/ip1/udp/payload)
9-
pkt_bytes2 = str(eth/ip2/udp/payload)
8+
pkt_bytes1 = bytes(eth/ip1/udp/payload)
9+
pkt_bytes2 = bytes(eth/ip2/udp/payload)
1010

1111
# Create the pipeline from two sources rewriting each to have their own
1212
# source port and destination port respectively, the pushing them into

bessctl/conf/samples/exactmatch.bess

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def gen_packet(proto, src_ip, dst_ip):
1111
udp = proto(sport=10001, dport=10002)
1212
payload = 'helloworld'
1313
pkt = eth/ip/udp/payload
14-
return str(pkt)
14+
return bytes(pkt)
1515

1616
packets = [gen_packet(scapy.UDP, '172.16.100.1', '10.0.0.1'),
1717
gen_packet(scapy.UDP, '172.12.55.99', '12.34.56.78'),

bessctl/conf/samples/flowgen.bess

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ip = scapy.IP(src='10.0.0.1', dst='10.0.0.2') # dst IP is overwritten
1010
tcp = scapy.TCP(sport=10001, dport=10002)
1111
payload = ('hello' + '0123456789' * 200)[:pkt_size-len(eth/ip/tcp)]
1212
pkt = eth/ip/tcp/payload
13-
pkt_data = str(pkt)
13+
pkt_data = bytes(pkt)
1414

1515
# NOTE: without quick_rampup=1, it takes a while to converge to
1616
# the desied load level, especially when flow duration is pareto distribution

0 commit comments

Comments
 (0)