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

[test/features] Add test for show features command #1546

Merged
merged 7 commits into from
Apr 17, 2020
Merged
Changes from 1 commit
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
37 changes: 37 additions & 0 deletions tests/test_features.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import pytest
import logging
pra-moh marked this conversation as resolved.
Show resolved Hide resolved

logger = logging.getLogger(__name__)
pra-moh marked this conversation as resolved.
Show resolved Hide resolved

def get_dict_stdout(cmd_out):
"""Extract dictionary from show features command output
"""
result = ""
out_dict = {}
cmd = cmd_out[2:]
for x in cmd:
result = x.encode('UTF-8')
r = result.split()
out_dict[r[0]] = r[1]
return out_dict

def get_status_redisout(status_out):
"""Extract status value for feature in redis
"""
status_list = status_out[1:]
status = ""
for s in status_list:
status = s.encode('UTF-8')
return status

def test_show_features(duthost):
"""Verify show features command output against CONFIG_DB
"""
features_stdout = duthost.shell('show features', module_ignore_errors=True)['stdout_lines']
pra-moh marked this conversation as resolved.
Show resolved Hide resolved
features_dict = get_dict_stdout(features_stdout)
for k,v in features_dict.items():
feature = str(k)
status_out = duthost.shell('/usr/bin/redis-cli -n 4 hgetall "FEATURE|{}"'.format(feature), module_ignore_errors=False)['stdout_lines']
redis_value = get_status_redisout(status_out)
if str(redis_value) == str(v):
assert True, "{} is {} which matches with config_db".format(k,v)
pra-moh marked this conversation as resolved.
Show resolved Hide resolved