Skip to content

Commit

Permalink
updated for snappi v0.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
fredpower44 committed Oct 12, 2021
1 parent a0722f9 commit b46bac9
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
snappi-trex is a snappi plugin that allows executing scripts written using
[snappi](https://github.com/open-traffic-generator/snappi) with Cisco's [TRex Traffic Generator](https://trex-tgn.cisco.com).

snappi-trex is currently compatible with snappi v0.6.1 and Open Traffic Generator v0.6.1
snappi-trex is currently compatible with snappi v0.6.4 and Open Traffic Generator v0.6.4

## Design
snappi-trex converts snappi Open Traffic Generator API configuration into the equivalent TRex STL Client configuration. This allows users to use the TRex Traffic Generator and its useful features without having to write complex TRex scripts.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.5
0.1.6
2 changes: 1 addition & 1 deletion docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ sudo apt-get install python3-pip
```
Install snappi
```sh
pip3 install snappi==0.6.1
pip3 install snappi==0.6.4
```
Now, install the snappi-trex extension.
```sh
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ setuptools
wheel
twine
python-dotenv
snappi==0.4.38
snappi==0.6.4
6 changes: 6 additions & 0 deletions snappi_trex/setconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ def set_rate(rate):
bps = rate['gbps'] * 1000000000
elif rate['choice'] == 'percentage':
percent = rate['percentage']
if pps:
pps = int(pps)
if bps:
bps = int(bps)
if percent:
percent = int(percent)
return pps, bps, percent


Expand Down
10 changes: 5 additions & 5 deletions snappi_trex/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ def validate_rate(rate):
raise SnappiTrexException('Invalid \'rate\' choice')

if pps is not None:
if not isinstance(pps, float) and not isinstance(pps, int):
if not isinstance(pps, str) and not isinstance(pps, int):
print(isinstance(pps, float))
raise SnappiTrexException('\'pps\' must be integer or float')
if bps is not None:
if not isinstance(bps, float) and not isinstance(bps, int):
if not isinstance(bps, str) and not isinstance(bps, int):
raise SnappiTrexException('\'(k/m/g)bps\' must be integer or float')
if percent is not None:
if not isinstance(percent, float) and not isinstance(percent, int):
if not isinstance(percent, str) and not isinstance(percent, int):
raise SnappiTrexException('\'percentage\' must be integer or float')

@staticmethod
Expand Down Expand Up @@ -299,8 +299,8 @@ def validate_capture_settings(settings, port_ids):
raise SnappiTrexException('\'{}\' is not a supported capture format'.format(s['format']))
if 'packet_size' in s and s['packet_size'] is not None:
raise SnappiTrexException('maximum capture packet size options are not supported')
if s['overwrite']:
raise SnappiTrexException('overwrite not supported for captures')
# if not s['overwrite']:
# raise SnappiTrexException('overwrite not supported for captures')

capture_filter_info = Info.get_capture_filter_info()
if 'filters' in s:
Expand Down
10 changes: 5 additions & 5 deletions tests/data/setrate_validation_bad.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
{
"choice": "pps",
"pps": "19.4d",
"pps": 1203.321,
"bps": 10923.52,
"kbps": 123.34,
"mbps": 0.9823,
Expand All @@ -20,7 +20,7 @@
{
"choice": "bps",
"pps": "19.4d",
"bps": "10923.52",
"bps": 10923.52,
"kbps": "123.34",
"mbps": "0.9823",
"gbps": "0.0032",
Expand All @@ -30,7 +30,7 @@
"choice": "kbps",
"pps": "19.4d",
"bps": "10923.52",
"kbps": "123.34",
"kbps": 123.34,
"mbps": "0.9823",
"gbps": "0.0032",
"percentage": "23.41"
Expand All @@ -40,7 +40,7 @@
"pps": "19.4d",
"bps": "10923.52",
"kbps": "123.34",
"mbps": "0.9823",
"mbps": 0.9823,
"gbps": "0.0032",
"percentage": "23.41"
},
Expand All @@ -50,7 +50,7 @@
"bps": "10923.52",
"kbps": "123.34",
"mbps": "0.9823",
"gbps": "0.0032",
"gbps": 0.0032,
"percentage": "23.41"
}
]
10 changes: 5 additions & 5 deletions tests/data/setrate_validation_good.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"choice": "pps",
"pps": 19.4,
"pps": 19,
"bps": 10923.52,
"kbps": 123.34,
"mbps": 0.9823,
Expand All @@ -11,7 +11,7 @@
{
"choice": "bps",
"pps": 19.4,
"bps": 10923.52,
"bps": 10923,
"kbps": 123.34,
"mbps": 0.9823,
"gbps": 0.0032,
Expand All @@ -21,7 +21,7 @@
"choice": "kbps",
"pps": 19.4,
"bps": 10923.52,
"kbps": 123.34,
"kbps": 123,
"mbps": 0.9823,
"gbps": 0.0032,
"percentage": 23.41
Expand All @@ -31,7 +31,7 @@
"pps": 19.4,
"bps": 10923.52,
"kbps": 123.34,
"mbps": 0.9823,
"mbps": 1,
"gbps": 0.0032,
"percentage": 23.41
},
Expand All @@ -41,7 +41,7 @@
"bps": 10923.52,
"kbps": 123.34,
"mbps": 0.9823,
"gbps": 0.0032,
"gbps": 1,
"percentage": 23.41
}
]

0 comments on commit b46bac9

Please sign in to comment.