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

Fix portstat case #21

Closed
wants to merge 1 commit into from
Closed
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
20 changes: 10 additions & 10 deletions tests/portstat/test_portstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,14 @@ def test_portstat_delete_all(duthosts, enum_rand_one_per_hwsku_frontend_hostname
logger.info('Verify that the file names are in the /tmp directory')
uid = duthost.command('id -u')['stdout'].strip()
for stats_file in stats_files:
pytest_assert(duthost.stat(path='/tmp/portstat-{uid}/{uid}-{filename}'\
.format(uid=uid, filename=stats_file))['stat']['exists'])
pytest_assert(get_tmp_portstat_file_existing_status(duthost, uid, stats_file))

logger.info('Run the command to be tested "{}"'.format(command))
duthost.command(command)

logger.info('Verify that the file names are not in the /tmp directory')
for stats_file in stats_files:
pytest_assert(not duthost.stat(path='/tmp/portstat-{uid}/{uid}-{filename}'\
.format(uid=uid, filename=stats_file))['stat']['exists'])
pytest_assert(not get_tmp_portstat_file_existing_status(duthost, uid, stats_file))


@pytest.mark.parametrize('command',
Expand All @@ -100,21 +98,23 @@ def test_portstat_delete_tag(duthosts, enum_rand_one_per_hwsku_frontend_hostname
logger.info('Verify that the file names are in the /tmp directory')
uid = duthost.command('id -u')['stdout'].strip()
for stats_file in stats_files:
pytest_assert(duthost.stat(path='/tmp/portstat-{uid}/{uid}-{filename}'\
.format(uid=uid, filename=stats_file))['stat']['exists'])
pytest_assert(get_tmp_portstat_file_existing_status(duthost, uid, stats_file))

full_delete_command = command + ' ' + file_to_delete
logger.info('Run the command to be tested "{}"'.format(full_delete_command))
duthost.command(full_delete_command)

logger.info('Verify that the deleted file name is not in the directory')
pytest_assert(not duthost.stat(path='/tmp/portstat-{uid}/{uid}-{filename}'\
.format(uid=uid, filename=file_to_delete))['stat']['exists'])
pytest_assert(not get_tmp_portstat_file_existing_status(duthost, uid, file_to_delete))

logger.info('Verify that the remaining file names are in the directory')
for stats_file in files_not_deleted:
pytest_assert(duthost.stat(path='/tmp/portstat-{uid}/{uid}-{filename}'\
.format(uid=uid, filename=stats_file))['stat']['exists'])
pytest_assert(get_tmp_portstat_file_existing_status(duthost, uid, stats_file))


def get_tmp_portstat_file_existing_status(duthost, uid, stats_file):
return duthost.stat(path='/tmp/cache/portstat/{uid}-{filename}'.format(
uid=uid, filename=stats_file))['stat']['exists']


@pytest.mark.parametrize('command', ['portstat -a', 'portstat --all'])
Expand Down