Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trying to correct tests #565

Open
wants to merge 25 commits into
base: conformance_compatible_latest
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
${{steps.path.outputs.pythonv}} do.py init
- name: Run tests
run: |
${{steps.path.outputs.pythonv}} do.py test
TEST_USERNAME=${{secrets.TEST_USERNAME}} TEST_PASSWORD='${{secrets.TEST_PASSWORD}}' ${{steps.path.outputs.pythonv}} do.py test
- name: Get package version
id: get_version
run: |
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
${{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]
runs-on: [snappi-ixn-ci-novus100g]
needs: cicd
steps:
- name: Trigger CI/CD snappi-tests
Expand Down
14 changes: 11 additions & 3 deletions do.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def lint():

def test():
coverage_threshold = 67
username = os.environ.get("TEST_USERNAME", "admin")
psd = os.environ.get("TEST_PASSWORD", "admin")
args = [
'--location="https://snappi-ixn-ci-novus100g.lbj.is.keysight.com:5000"',
(
Expand All @@ -45,13 +47,17 @@ def test():
" snappi-ixn-ci-novus100g.lbj.is.keysight.com;1;5"
' snappi-ixn-ci-novus100g.lbj.is.keysight.com;1;6"'
),
"--username=" + username,
"--psd='" + psd + "'",
"--ext=ixnetwork",
"--speed=speed_100_gbps",
"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 @@ -232,11 +238,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
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
92 changes: 40 additions & 52 deletions snappi_ixnetwork/device/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from snappi_ixnetwork.logger import get_ixnet_logger

__all__ = ['Base', 'MultiValue', 'PostCalculated']

__all__ = ["Base", "MultiValue", "PostCalculated"]


class MultiValue(object):
Expand All @@ -25,9 +24,7 @@ def value(self):
value = None
if self._key == "connectedTo":
value = self._ref_obj.get("xpath")
self.logger.debug("Post Calculated %s - %s" % (
self._key, value
))
self.logger.debug("Post Calculated %s - %s" % (self._key, value))
return value


Expand Down Expand Up @@ -57,7 +54,7 @@ def create_node_elemet(self, ixn_obj, node_name, name=None):
- We are setting name as multivalue for farther processing
- It will return that newly created dict
"""
self.logger.debug("Creating node for %s" %node_name)
self.logger.debug("Creating node for %s" % node_name)
node = self.create_node(ixn_obj, node_name)
return self.add_element(node, name)

Expand All @@ -75,14 +72,10 @@ def multivalue(self, value, enum=None):
return MultiValue(value)

def as_multivalue(self, snappi_obj, name, enum=None):
return self.multivalue(
snappi_obj.get(name), enum
)
return self.multivalue(snappi_obj.get(name), enum)

def post_calculated(self, key, ref_ixnobj=None, ixnobj=None):
return PostCalculated(
key, ref_ixnobj, ixnobj
)
return PostCalculated(key, ref_ixnobj, ixnobj)

def get_name(self, object):
name = object.get("name")
Expand All @@ -106,20 +99,21 @@ def configure_multivalues(self, snappi_obj, ixn_obj, attr_map):
# We need to specify product default if model not specify
default_value = ixn_map.get("default_value")
if default_value is None:
raise NameError("Please specify default_value for ",
snappi_attr)
raise NameError(
"Please specify default_value for ", snappi_attr
)
value = default_value
if enum_map is not None and value is not None:
value = enum_map[value]
self.logger.debug("ixn_attr %s with enum value %s" % (
ixn_attr, value
))
self.logger.debug(
"ixn_attr %s with enum value %s" % (ixn_attr, value)
)
else:
ixn_attr = ixn_map
value = snappi_obj.get(snappi_attr)
self.logger.debug("ixn_attr %s with value %s" % (
ixn_attr, value
))
self.logger.debug(
"ixn_attr %s with value %s" % (ixn_attr, value)
)
ixn_obj[ixn_attr] = self.multivalue(value)

def configure_multivalues_with_choice(self, snappi_obj, ixn_obj, attr_map):
Expand All @@ -130,9 +124,7 @@ def configure_multivalues_with_choice(self, snappi_obj, ixn_obj, attr_map):
value = snappi_obj.get(snappi_attr).get("value")
if snappi_attr == "gateway_mac":
ixn_obj["resolveGateway"] = self.multivalue(False)
self.logger.debug("ixn_attr %s with value %s" % (
ixn_attr, value
))
self.logger.debug("ixn_attr %s with value %s" % (ixn_attr, value))
ixn_obj[ixn_attr] = self.multivalue(value)

def get_symmetric_nodes(self, parent_list, node_name):
Expand Down Expand Up @@ -198,18 +190,19 @@ def get_values(self, attr_name, enum_map=None, default=None):
value = node.get(attr_name)
if value is None:
if default is None:
raise NameError("Please specify default_value for ",
attr_name)
raise NameError(
"Please specify default_value for ", attr_name
)
value = default
if enum_map is not None:
value = enum_map[value]
values.append(value)
return values

def get_multivalues(self, attr_name, enum_map=None, default=None):
return self._base.multivalue(self.get_values(
attr_name, enum_map=enum_map, default=default
))
return self._base.multivalue(
self.get_values(attr_name, enum_map=enum_map, default=default)
)

def config_values(self, ixn_obj, attr_map):
for snappi_attr, ixn_map in attr_map.items():
Expand All @@ -219,9 +212,9 @@ def config_values(self, ixn_obj, attr_map):
raise NameError("ixn_attr is missing within ", ixn_map)
enum_map = ixn_map.get("enum_map")
values = self.get_multivalues(
snappi_attr, enum_map=enum_map, default=ixn_map.get(
"default_value"
)
snappi_attr,
enum_map=enum_map,
default=ixn_map.get("default_value"),
)
else:
ixn_attr = ixn_map
Expand All @@ -241,23 +234,18 @@ def get_tab(self, tab_name):
if tab_node is None and dummy_value is not None:
tab_nodes[idx] = dummy_value

return NodesInfo(
self._max_len,
self._active_list,
tab_nodes
)
return NodesInfo(self._max_len, self._active_list, tab_nodes)

def get_symmetric_nodes(self, node_name):
return self._base.get_symmetric_nodes(
self._symmetric_nodes, node_name
)
return self._base.get_symmetric_nodes(self._symmetric_nodes, node_name)

def get_group_nodes(self, tab_name):
"""We will pass a attribute names which is array in type
Fill with other nodes and active_list as False
It will raise error if all elements are not same length
Finally return list of NodesInfo
It will use some IxNetwork tab which do not have enable/disable features"""
It will use some IxNetwork tab which do not have enable/disable features
"""
dummy_tab = None
for node in self._symmetric_nodes:
dummy_tab = node.get(tab_name)
Expand All @@ -279,28 +267,28 @@ def get_group_nodes(self, tab_name):
tab_lengths.append(len(tab))
active_list.append(True)
if len(set(tab_lengths)) > 1:
raise Exception("All the attributes %s should have same lengths" % tab_name)
raise Exception(
"All the attributes %s should have same lengths" % tab_name
)
for idx in range(tab_lengths[-1]):
if len(group_nodes) <= idx:
group_nodes.append([tab[idx]])
else:
group_nodes[idx].append(tab[idx])

return active_list, [NodesInfo(
1, # use dummy one
self._active_list,
group_node
) for group_node in group_nodes]
return active_list, [
NodesInfo(1, self._active_list, group_node) # use dummy one
for group_node in group_nodes
]

def get_active_group_nodes(self, tab_name):
"""It will cover get_group_nodes
At the same time it will raise error if None node
because IxNetwork do not have active field for those"""
active_list, node_info_list = self.get_group_nodes(
tab_name
)
active_list, node_info_list = self.get_group_nodes(tab_name)
if len(set(active_list)) > 1:
raise Exception("All the attributes %s should configure with equal length"
% tab_name)
raise Exception(
"All the attributes %s should configure with equal length"
% tab_name
)
return node_info_list

Loading