Skip to content

Commit

Permalink
Bug fix and addressing review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
indraniBh committed Sep 12, 2024
1 parent f1b450e commit 9c27be2
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 62 deletions.
2 changes: 1 addition & 1 deletion do.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def lint():


def test(card="novus100g"):
coverage_threshold = 0
coverage_threshold = 67
username = os.environ.get("TEST_USERNAME", "admin")
psd = os.environ.get("TEST_PASSWORD", "admin")

Expand Down
8 changes: 2 additions & 6 deletions snappi_ixnetwork/protocolmetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class ProtocolMetrics(object):
# more than one page.

_SUPPORTED_PROTOCOLS_ = ["bgpv4", "bgpv6"]
_SKIP = True

_TOPO_STATS = {
"name": "name",
Expand All @@ -22,9 +21,6 @@ class ProtocolMetrics(object):
"bgpv4": [
("name", "Device Group", str),
("session_state", "Status", str),
# TODO session_flap_count can't be added now
# it needs to be added by creating new view.
# currently facing an issue in protocol view creation.
("session_flap_count", "Session Flap Count", int),
("routes_advertised", "Routes Advertised", int),
("routes_received", "Routes Rx", int),
Expand All @@ -42,7 +38,6 @@ class ProtocolMetrics(object):
"bgpv6": [
("name", "Device Group", str),
("session_state", "Status", str),
# TODO session_flap_count can't be added now
("session_flap_count", "Session Flap Count", int),
("routes_advertised", "Routes Advertised", int),
("routes_received", "Routes Rx", int),
Expand Down Expand Up @@ -193,7 +188,8 @@ def _port_names_from_devices(self):
if ethernets is None:
continue
for eth in ethernets:
port_list.append(eth.get("port_name"))
if eth.get("connection") is not None:
port_list.append(eth.get("connection").get("port_name"))
return port_list

def _do_drill_down(self, view, per_port, row_index, drill_option):
Expand Down
24 changes: 12 additions & 12 deletions tests/bgp/test_bgpv4_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,19 @@ def test_bgpv4_stats(api, b2b_raw_config, utils):
else:
assert getattr(bgp_res, enum) >= val

# req = api.metrics_request()
# req.bgpv4.peer_names = ["rx_bgp"]
# results = api.get_metrics(req)
req = api.metrics_request()
req.bgpv4.peer_names = ["rx_bgp"]
results = api.get_metrics(req)

# assert len(results.bgpv4_metrics) == 1
# assert results.bgpv4_metrics[0].name == "rx_bgp"
# for bgp_res in results.bgpv4_metrics:
# for i, enum in enumerate(enums):
# val = expected_results[bgp_res.name][i]
# if "session_state" in enum:
# assert getattr(bgp_res, enum) == val
# else:
# assert getattr(bgp_res, enum) >= val
assert len(results.bgpv4_metrics) == 1
assert results.bgpv4_metrics[0].name == "rx_bgp"
for bgp_res in results.bgpv4_metrics:
for i, enum in enumerate(enums):
val = expected_results[bgp_res.name][i]
if "session_state" in enum:
assert getattr(bgp_res, enum) == val
else:
assert getattr(bgp_res, enum) >= val

req = api.metrics_request()
req.bgpv4.column_names = ["session_state"]
Expand Down
36 changes: 18 additions & 18 deletions tests/test_device_connection.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
def test_device_lag_name(api, utils):
config = api.config()
p1 = config.ports.port(name="p1", location=utils.settings.ports[0])[-1]
config.options.port_options.location_preemption = True
lag1 = config.lags.lag(name="lag-1")[-1]
lp1 = lag1.ports.port(port_name=p1.name)[-1]
lag1.protocol.static.lag_id = 1
lp1.ethernet.name = "lp1-e"
lp1.ethernet.mac = "aa:aa:aa:aa:aa:aa"
d1 = config.devices.device(name="d1")[-1]
eth1 = d1.ethernets.ethernet()[-1]
eth1.connection.lag_name = lag1.name
eth1.name = "eth1"
eth1.mac = "00:01:00:00:00:02"
api.set_config(config)
assert (api._ixnetwork.Lag.find()[0].Name) == lag1.name


def test_port_name(api, utils):
config = api.config()
p1 = config.ports.port(name="p1", location=utils.settings.ports[0])[-1]
Expand Down Expand Up @@ -45,24 +63,6 @@ def test_device_connection(api, utils):
except Exception as err:
assert err.args[0] == 500

# TBD: Issue assinging ports to lag
# def test_device_lag_name(api, utils):
# config = api.config()
# p1 = config.ports.port(name="p1", location=utils.settings.ports[0])[-1]
# config.options.port_options.location_preemption = True
# lag1 = config.lags.lag(name="lag-1")[-1]
# lp1 = lag1.ports.port(port_name=p1.name)[-1]
# lag1.protocol.static.lag_id = 1
# lp1.ethernet.name = "lp1-e"
# lp1.ethernet.mac = "aa:aa:aa:aa:aa:aa"
# d1 = config.devices.device(name="d1")[-1]
# eth1 = d1.ethernets.ethernet()[-1]
# eth1.connection.lag_name = lag1.name
# eth1.name = "eth1"
# eth1.mac = "00:01:00:00:00:02"
# api.set_config(config)
# assert (api._ixnetwork.Lag.find()[0].Name) == lag1.name


def test_device_without_port_name(api, utils):
config = api.config()
Expand Down
12 changes: 6 additions & 6 deletions tests/traffic/test_device_bgp_ep.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ def test_bgpv6_routes(api, b2b_raw_config, utils):
req.bgpv6.peer_names = ["rx_bgp"]
results = api.get_metrics(req)

# assert len(results.bgpv6_metrics) == 1
# assert results.bgpv6_metrics[0].name == "rx_bgp"
# for bgp_res in results.bgpv6_metrics:
# for i, enum in enumerate(enums):
# val = expected_results[bgp_res.name][i]
# assert getattr(bgp_res, enum) == val
assert len(results.bgpv6_metrics) == 1
assert results.bgpv6_metrics[0].name == "rx_bgp"
for bgp_res in results.bgpv6_metrics:
for i, enum in enumerate(enums):
val = expected_results[bgp_res.name][i]
assert getattr(bgp_res, enum) == val

req = api.metrics_request()
req.bgpv6.column_names = ["session_state"]
Expand Down
11 changes: 0 additions & 11 deletions tests/traffic/test_stats_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ def test_stats_filter(api, b2b_raw_config, utils):
req = api.metrics_request()
req.port.port_names = [port_name]
port_results = api.get_metrics(req).port_metrics
# port_results = api.get_port_results(result.PortRequest(
# port_names=[port_name]))
validate_port_stats_based_on_port_name(port_results, port_name)

# Validation on Port statistics based on column names
Expand All @@ -63,9 +61,6 @@ def test_stats_filter(api, b2b_raw_config, utils):
req.port.column_names = ["name", column_name]
port_results = api.get_metrics(req).port_metrics

# port_results = api.get_port_results(result.PortRequest(
# column_names=['name',
# column_name]))
validate_port_stats_based_on_column_name(
port_results, column_name, f1_packets, f2_packets, f1_size, f2_size
)
Expand All @@ -77,9 +72,6 @@ def test_stats_filter(api, b2b_raw_config, utils):
req.flow.flow_names = [flow_name]
req.flow.metric_names = ["name"]
flow_results = api.get_metrics(req).flow_metrics
# flow_results = api.get_flow_results(result.FlowRequest(
# flow_names=[flow_name],
# column_names=['name']))
validate_flow_stats_based_on_flow_name(flow_results, flow_name)

# Validation on Flow statistics based on metric names
Expand All @@ -88,9 +80,6 @@ def test_stats_filter(api, b2b_raw_config, utils):
req = api.metrics_request()
req.flow.metric_names = ["name", column_name]
flow_results = api.get_metrics(req).flow_metrics
# flow_results = api.get_flow_results(result.FlowRequest(
# column_names=['name',
# column_name]))
validate_flow_stats_based_on_metric_name(
flow_results, metric_name, f1_packets, f2_packets, f1_size, f2_size
)
Expand Down
14 changes: 7 additions & 7 deletions tests/traffic/test_stats_filter_e2e.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
import time


@pytest.mark.e2e
def test_stats_filter_e2e(api, b2b_raw_config, utils):
"""
configure two flows f1 and f2
Expand Down Expand Up @@ -68,12 +68,12 @@ def test_stats_filter_e2e(api, b2b_raw_config, utils):
validate_flow_stats_based_on_flow_name(flow_results, flow_name)

# Validation on Flow statistics based on column names
# column_names = ["frames_tx_rate", "frames_rx_rate"]
# for column_name in column_names:
# req = api.metrics_request()
# req.flow.metric_names = ["name", column_name]
# flow_results = api.get_metrics(req).flow_metrics
# validate_flow_stats_based_on_column_name(flow_results, column_name)
column_names = ["frames_tx_rate", "frames_rx_rate"]
for column_name in column_names:
req = api.metrics_request()
req.flow.metric_names = ["name", column_name]
flow_results = api.get_metrics(req).flow_metrics
validate_flow_stats_based_on_column_name(flow_results, column_name)

utils.stop_traffic(api, b2b_raw_config)

Expand Down
1 change: 0 additions & 1 deletion tests/vxlan/test_vxlan_b2b.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest

@pytest.mark.skip("skip until migrated to snappi")
def test_vxlan_b2b(api, utils):
config = api.config()

Expand Down

0 comments on commit 9c27be2

Please sign in to comment.