Skip to content

Commit

Permalink
Update to latest snappi (#574)
Browse files Browse the repository at this point in the history
* Worked on following issues:
1. Modified warnings as per latest model
2. Added set_control_state and set_control_action as per the latest model
3. Added get_version API

* Comment from vibaswan addressed

* Added backward compatabilty code back

* updated snappi-ixnetwork version

* updated runner details

* updated runner details

* removed support for python2

* update python binary path

* updated python to point to virtualenv

* removed bad chars

* trying to correct tests

* modify test

* exposing username and password

* bug fix

* bug fix

* bug fix

* bug fix

* bug fix

* bug fix

* trying by disabling shell

* trying by disabling shell

* change back to original

* bug fix

* bug fix

* bug fix

* enabling whole test

* linting python code and handling snappi_convergence

* rectifying snappi convergence

* trying to make the password generic

* bug fix

* bug fix

* add support for new runner with novus10g

* bug fix

* Adding backward compatibility for ping test

* modified failed cases

* updating latest model code

* committing imix e2e tc files

* Update publish.yml

* Run only 10g

* Run only 10g

* Run only 10g

* revert changes

* Run only 10g

* Allow unsecure version

* indentation fix

* dummy change

* Test fix

* Fixed workflow for publish artifacts

* Update Test

* Update latest snappi 1.11.0

* Disabling snappi-convergence

* bug fix

* revert version-0.11.5

* version-03.7

* Update requirement.txt

* snappi 0.11.7

* Update tests

* snappi 0.11.17

* snappi 0.13.0

* snappi 0.12.6

* snappi 0.12.1

* snappi 0.11.17

* Enable snappi-convergence tests

* Enable snappi-convergence api

* Update tests removing all TCs except udp and tcp

* Disable snappi convergence tests

* Update snappi 1.12.1

* Update requirement

* change location port in do.py

* Added ethernet, ipv4, ipv6 basic TCs

* Added pretest

* Added arp tests

* Added capture tests

* Added imix tests

* Added ipv4 priority TCs

* Added layer1 tests

* Added latency tests

* Added pfc tests

* Added traffic tests (WIP)

* Added traffic tests (WIP)

* Added loopback TC(connection add)

* Added bgp and bgp-evpn TC(connection add)

* Added lag and iterative tests

* Added ping tests

* Added TC vlan, vxlan

* Added error and few traffic TCs

* Update latest snappi 1.13.0

* Added udp and tcp TCs

* Update capture api

* Added bgp validation

* Added Protocol metrics TCs

* Added few skipped TCs

* bug fix

* Cleanup and update readme

* Bug fix and addressing review comments

* Bug fix and addressing review comments

* Added update flows

* Skip convergence TCs

* Skip convergence TCs

* Minor fix in TC

* removing e2e tag from custom and ipv6_imix.
add ipsec_imix and tcp_imix tests

* modified as per the latest model changes

* Update publish.yml

* fixing conftest so that pytest does not fail instantly

* Fix capture buffer lenths

* remover snappi convergence ref in setup

* fix ipsec_imix type

* Update test_arp_packet.py

* Update test_arp_packet.py

* Update publish.yml

* Code cleanup

---------

Co-authored-by: desaimg1 <[email protected]>
Co-authored-by: Ashutosh Kumar <[email protected]>
Co-authored-by: vhowdhur <[email protected]>
Co-authored-by: Vibaswan <[email protected]>
Co-authored-by: Dipendu Ghosh <[email protected]>
Co-authored-by: desaimg1 <[email protected]>
  • Loading branch information
7 people authored Sep 30, 2024
1 parent 142692a commit d3c7322
Show file tree
Hide file tree
Showing 87 changed files with 3,904 additions and 2,985 deletions.
52 changes: 28 additions & 24 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,23 @@ name: cicd

on:
push:
branches: [main]
pull_request:

jobs:
cicd:
runs-on: [self-hosted, Linux, Ubuntu, x64]
strategy:
max-parallel: 1
matrix:
python-version: [python27, python38]
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

jobs:
test_novus_10g:
runs-on: [snappi-ixn-ci-novus10g]
steps:
- name: Checkout source
uses: actions/checkout@v2
with:
ref: ${{ env.BASE_BRANCH }}
# ref: ${{ github.head_ref }}
submodules: recursive
- name: Set python path
id: path
run: echo "::set-output name=pythonv::/home/otg/${{matrix.python-version}}/bin/python"
run: echo "::set-output name=pythonv::/home/github-runner/pyenv/.env/bin/python"
- name: Install dependencies
run: |
rm -rf .env
Expand All @@ -39,7 +35,28 @@ jobs:
${{steps.path.outputs.pythonv}} do.py init
- name: Run tests
run: |
${{steps.path.outputs.pythonv}} do.py test
TEST_USERNAME=${{secrets.TEST_USERNAME}} ${{steps.path.outputs.pythonv}} do.py test novus10g
publish_artifacts:
runs-on: [snappi-ixn-ci-novus10g]
needs: [test_novus_10g]
steps:
- name: Checkout source
uses: actions/checkout@v2
with:
ref: ${{ env.BASE_BRANCH }}
submodules: recursive
- name: Set python path
id: path
run: echo "::set-output name=pythonv::/home/github-runner/pyenv/.env/bin/python"
- name: Install dependencies
run: |
rm -rf .env
${{steps.path.outputs.pythonv}} do.py setup
${{steps.path.outputs.pythonv}} do.py init
- name: Build distribution
run: |
${{steps.path.outputs.pythonv}} do.py dist
- name: Get package version
id: get_version
run: |
Expand Down Expand Up @@ -74,16 +91,3 @@ jobs:
run: |
${{steps.path.outputs.pythonv}} do.py install_requests ${{steps.path.outputs.pythonv}}
${{steps.path.outputs.pythonv}} do.py check_release_flag ${{ steps.release.outputs.release_flag }} ${{ steps.get_version.outputs.version }}
cicd_snappitest:
runs-on: [self-hosted, Linux, Ubuntu, x64]
needs: cicd
steps:
- name: Trigger CI/CD snappi-tests
run: |
git clone https://github.com/open-traffic-generator/snappi-tests.git
mv version.txt snappi-tests
cd snappi-tests
git add version.txt
git commit --allow-empty -m "Trigger Snappi test from snappi-ixnetwork"
git remote set-url origin https://${{secrets.CI_TOKEN}}@github.com/open-traffic-generator/snappi-tests.git
git push origin main
64 changes: 39 additions & 25 deletions do.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,47 @@ def lint():
)


def test():
def test(card="novus100g"):
coverage_threshold = 67
# args = [
# '--location="https://10.39.71.97:443"',
# (
# '--ports="10.39.65.230;6;1 10.39.65.230;6;2 10.39.65.230;6;3'
# ' 10.39.65.230;6;4"'
# ),
# '--media="fiber"',
# "tests",
# '-m "not e2e and not l1_manual"',
# '--cov=./snappi_ixnetwork --cov-report term'
# ' --cov-report html:cov_report',
# ]
args = [
'--location="https://otg-novus100g.lbj.is.keysight.com:5000"',
(
'--ports="otg-novus100g.lbj.is.keysight.com;1;1'
" otg-novus100g.lbj.is.keysight.com;1;2"
" otg-novus100g.lbj.is.keysight.com;1;5"
' otg-novus100g.lbj.is.keysight.com;1;6"'
),
username = os.environ.get("TEST_USERNAME", "admin")
psd = os.environ.get("TEST_PASSWORD", "admin")

if card == "novus100g":
args = [
'--location="https://snappi-ixn-ci-novus100g.lbj.is.keysight.com:5000"',
(
'--ports="snappi-ixn-ci-novus100g.lbj.is.keysight.com;1;1'
" snappi-ixn-ci-novus100g.lbj.is.keysight.com;1;2"
" snappi-ixn-ci-novus100g.lbj.is.keysight.com;1;5"
' snappi-ixn-ci-novus100g.lbj.is.keysight.com;1;6"'
),
"--speed=speed_100_gbps",
]
elif card == "novus10g":
args = [
'--location="https://novus1-715849.ccu.is.keysight.com:443"',
(
'--ports="novus1-715849.ccu.is.keysight.com;1;1'
" novus1-715849.ccu.is.keysight.com;1;2"
" novus1-715849.ccu.is.keysight.com;1;5"
' novus1-715849.ccu.is.keysight.com;1;6"'
),
"--speed=speed_10_gbps",
]
else:
raise Exception("card %s is not supported for testing" % card)

args += [
"--ext=ixnetwork",
"--speed=speed_100_gbps",
"--username=" + username,
"--psd='" + psd + "'",
"tests",
'-m "not e2e and not l1_manual and not uhd"',
"--cov=./snappi_ixnetwork --cov-report term"
" --cov-report html:cov_report",
]
print(args)

run(
[
py() + " -m pip install pytest-cov",
Expand Down Expand Up @@ -244,11 +256,13 @@ def get_workflow_id():


def check_release_flag(release_flag=None, release_version=None):
if release_flag == '1':
if release_flag == "1":
with open("setup.py") as f:
out = f.read()
snappi_convergence = re.findall(r"\"snappi_convergence==(.+)\"",out)[0]
release_version = release_version.replace('v', "")
snappi_convergence = re.findall(
r"\"snappi_convergence==(.+)\"", out
)[0]
release_version = release_version.replace("v", "")
with open("version.txt", "w+") as f:
f.write("version: {}\n".format(release_version))
f.write("snappi_convergence: {}\n".format(snappi_convergence))
Expand Down
13 changes: 9 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# snappi Extension for IxNetwork

[![license](https://img.shields.io/badge/license-MIT-green.svg)](https://en.wikipedia.org/wiki/MIT_License)
[![Project Status: Active The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Build](https://github.com/open-traffic-generator/snappi-ixnetwork/workflows/Build/badge.svg)](https://github.com/open-traffic-generator/snappi-ixnetwork/actions)
[![pypi](https://img.shields.io/pypi/v/snappi_ixnetwork.svg)](https://pypi.org/project/snappi_ixnetwork)
[![python](https://img.shields.io/pypi/pyversions/snappi_ixnetwork.svg)](https://pypi.python.org/pypi/snappi_ixnetwork)
Expand Down Expand Up @@ -66,9 +66,13 @@ flw.packet.ethernet().vlan().ipv4().tcp()
# push configuration
api.set_config(config)
# start transmitting configured flows
ts = api.transmit_state()
ts.state = ts.START
api.set_transmit_state(ts)
control_state = api.control_state()
control_state.choice = control_state.TRAFFIC
control_state.traffic.choice = control_state.traffic.FLOW_TRANSMIT
control_state.traffic.flow_transmit.state = control_state.traffic.flow_transmit.START # noqa
res = api.set_control_state(control_state)
if len(res.warnings) > 0:
print("Warnings: {}".format(res.warnings))
# create a query for flow metrics
req = api.metrics_request()
req.flow.flow_names = [flw.name]
Expand All @@ -78,3 +82,4 @@ while True:
if all([m.frames_tx == 10000 == m.frames_rx for m in res.flow_metrics]):
break
```

5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import setuptools

pkg_name = "snappi_ixnetwork"
version = "0.9.1"
version = "1.13.0"

# read long description from readme.md
base_dir = os.path.abspath(os.path.dirname(__file__))
Expand Down Expand Up @@ -37,8 +37,7 @@
install_requires=["ixnetwork-restpy>=1.0.52"],
extras_require={
"testing": [
"snappi==0.9.1",
"snappi_convergence==0.4.1",
"snappi==1.13.0",
"pytest",
"mock",
"dpkt==1.9.4",
Expand Down
6 changes: 4 additions & 2 deletions snappi_ixnetwork/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def config(self):
imports.append(capture)
for capture_item in self._api.snappi_config.captures:
if capture_item.format == "pcap":
self._api.warning("pcap format is not supported for IxNetwork, setting capture format to pcapng")
self._api.warning(
"pcap format is not supported for IxNetwork, setting capture format to pcapng"
)
capture_item.format = "pcapng"
if capture_item.port_names is None:
continue
Expand Down Expand Up @@ -348,7 +350,7 @@ def results(self, request):
self._api._request("POST", url, payload)

path = "%s/capture" % self._api._ixnetwork.Globals.PersistencePath
#Todo: Revert dc to merged capture after fix is available in 9.20
# Todo: Revert dc to merged capture after fix is available in 9.20
url = "%s/files?absolute=%s&filename=%s" % (
self._api._ixnetwork.href,
path,
Expand Down
Loading

0 comments on commit d3c7322

Please sign in to comment.