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

[master][SAI-PTF] API Logger - reformat arg values (#1696) #1700

Merged
Merged
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
6 changes: 5 additions & 1 deletion meta/templates/sai_adapter_utils.tt
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,14 @@ def invocation_logger(func):

args_dict = dict(zip(args_name, args))
args_dict.update(kwargs)
args_dict = { key:str(value) for (key,value) in args_dict.items()}
logging.info("sai_adapter_invoke func:[{}] args: [{}]".format(func.__name__, args_dict))

args_values = args_dict.values()
return func(*args, **kwargs)

retval = func(*args, **kwargs)
logging.info("sai_adapter_return func:[{}] retval:[{}]".format(func.__name__, repr(retval)))
return retval

return inner_logger
[%- END -%]
Expand Down
28 changes: 28 additions & 0 deletions ptf/utest/MockClient.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import logging
try:
from meta.sai_adapter import *
except ImportError:
from sai_thrift.sai_adapter import *

class MockSuccessClient():

def sai_thrift_remove_acl_table(self, var):
logging.info("sai_thrift_remove_acl_table invoked")
# e = sai_thrift_exception()
# e.status = -2
# raise e

return 0

def sai_thrift_create_switch(client,
Expand Down Expand Up @@ -88,4 +99,21 @@ def sai_thrift_create_switch(client,
qos_tc_and_color_to_mpls_exp_map=None,
failover_config_mode=None,
tunnel_objects_list=None):
logging.info("sai_thrift_create_switch invoked")
return 0


def sai_thrift_get_acl_table_attribute(client,
oid,
attr_list):
logging.info("sai_thrift_get_acl_table_attribute invoked")
attr_list = []
attribute1 = sai_thrift_attribute_t(id=SAI_ACL_TABLE_ATTR_ACL_STAGE)
attribute1.value = sai_thrift_attribute_value_t()
attribute = sai_thrift_attribute_t(id=SAI_ACL_TABLE_ATTR_ACL_STAGE, value=attribute1.value)
attr_list.append(attribute)


attr_lists = sai_thrift_attribute_list_t(attr_list=attr_list)
attr_lists.attr_list = attr_list
return attr_lists
2 changes: 2 additions & 0 deletions ptf/utest/TemplateTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def test_logger(self):
init_switch=True,
hardware_access_bus="11:11:11:11:11:11")
self.check_file_contains(LOG_FILE_PATH, 'hardware_access_bus')
sai_thrift_get_acl_table_attribute(self.client, acl_table_oid=1, acl_stage=1)
self.check_file_contains(LOG_FILE_PATH, 'SAI_ACL_TABLE_ATTR_ACL_STAGE')


def check_file_contains(self, file, content):
Expand Down