Skip to content

Commit

Permalink
version 0.1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
ajbalogh committed Jan 17, 2021
1 parent 7e93a74 commit 80aaa58
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 21 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ config = api.config()
tx_port, rx_port = config.ports \
.port(name='Tx Port', location='10.36.74.26;02;13')
.port(name='Rx Port', location='10.36.74.26;02;14')
flow = config.flows.flow(name='Tx -> Rx Flow')
flow = config.flows.flow(name='Tx -> Rx Flow')[-1]
flow.tx_rx.port.tx_name = tx_port.name
flow.tx_rx.port.tx_name = rx_port.name
flow.packet.ethernet().vlan().ipv4().tcp()
Expand All @@ -35,9 +35,8 @@ tx_state = api.transmit_state(state='start')
api.set_transmit(tx_state)

while True:
results = api.get_port_results(api.result_portrequest)
df = pandas.DataFrame.from_dict(results)
print(df)
if df.frames_tx.sum() >= flow.duration.fixed_packets.packets:
metrics = api.get_port_metrics(api.port_metrics_request())
tx_frames = sum([metric.frames_tx for metric in metrics])
if tx_frames >= flow.duration.fixed_packets.packets:
break
```
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.11
0.1.12
1 change: 1 addition & 0 deletions snappi/snappigenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def _get_openapi_file(self):
with open(self._openapi_filename, 'rb') as fp:
openapi_content = fp.read()
self._openapi = yaml.safe_load(openapi_content)
print('generating using model version %s' % self._openapi['info']['version'])

def _generate(self):
self._write_api_class()
Expand Down
2 changes: 1 addition & 1 deletion snappi/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def b2b_config(api):
tx_device.ipv4.prefix.value = 16
vlan1, vlan2 = tx_device.ipv4.ethernet.vlans.vlan().vlan()
vlan1.id.value = 1
vlan2.id.value = 2
vlan2.id.values = [2, 3, 4]
tx_device.ipv4.ethernet.mac.value = '00:00:01:00:00:01'

flow = config.flows.flow(name='Tx -> Rx Flow')[0]
Expand Down
24 changes: 12 additions & 12 deletions snappi/tests/e2e_port_flow_config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# import snappiserver
# snappiserver.SnappiServer().start()
import snappiserver
snappiserver.SnappiServer().start()


# # python type hinting
Expand All @@ -12,16 +12,17 @@

# TBD: put all classes into one autogenerated file snappi.py
# TBD: import all classes in __init__.py
from snappi import *
import snappi

api = Api() # type: snappi.Api
api = snappi.Api() # type: snappi.Api

config = api.config()

tx_port = config.ports.port(name='Tx Port', location='10.36.74.26;02;13')
rx_port = config.ports.port(name='Rx Port', location='10.36.74.26;02;14')
tx_port, rx_port = config.ports \
.port(name='Tx Port', location='10.36.74.26;02;13') \
.port(name='Rx Port', location='10.36.74.26;02;14')

flow = config.flows.flow(name='Tx -> Rx Flow')
flow = config.flows.flow(name='Tx -> Rx Flow')[-1]
flow.tx_rx.port.tx_name = tx_port.name
flow.tx_rx.port.rx_name = rx_port.name
flow.size.fixed = 128
Expand All @@ -32,7 +33,7 @@
flow.packet.ethernet().vlan().ipv4().tcp()

eth = flow.packet[0] # type: snappi.FlowEthernet
ip = flow.packet[2] # type: FlowIpv4
ip = flow.packet[2] # type: snappi.FlowIpv4

# TBD: eth = flow.packet[FlowEthernet][0]
eth.src.value = '00:00:01:00:00:01'
Expand Down Expand Up @@ -78,12 +79,11 @@
# get port metrics
port_metrics_request = api.port_metrics_request()
port_metrics = api.get_port_metrics(port_metrics_request)
for metric in port_metrics:
print(metric)
print(sum([metric.frames_tx for metric in port_metrics]))

# get flow metrics
flow_metrics_request = api.flow_metrics_request()
flow_metrics_request.metric_group_names = ''
flow_metrics = api.get_flow_metrics(flow_metrics_request)
for metric in flow_metrics:
print(metric)
print(sum(metric.frames_tx for metric in flow_metrics))

8 changes: 6 additions & 2 deletions snappi/tests/snappiserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,27 @@ def set_transmit_state():

@app.route('/results/port', methods=['POST'])
def get_port_metrics():
global CONFIG
api = Api()
port_metrics_request = api.port_metrics_request()
port_metrics_request.deserialize(request.data.decode('utf-8'))
port_metrics = api.port_metrics()
port_metrics.metric().metric()
for port in CONFIG.ports:
port_metrics.metric(name=port.name, frames_tx=10000, frames_rx=10000)
return Response(port_metrics.serialize(),
mimetype='application/json',
status=200)


@app.route('/results/flow', methods=['POST'])
def get_flow_metrics():
global CONFIG
api = Api()
flow_metrics_request = api.flow_metrics_request()
flow_metrics_request.deserialize(request.data.decode('utf-8'))
flow_metrics = api.flow_metrics()
flow_metrics.metric().metric()
for flow in CONFIG.flows:
flow_metrics.metric(name=flow.name, frames_tx=10000, frames_rx=10000)
return Response(flow_metrics.serialize(),
mimetype='application/json',
status=200)
Expand Down

0 comments on commit 80aaa58

Please sign in to comment.