Skip to content

Commit

Permalink
Fix portstat case (#6148)
Browse files Browse the repository at this point in the history
Becuase desigin change for "portstat -c -t filename", so change portstat test
1. Orignal design: After running “portstat -c -t  filename”, status file will be created on the folder of /tmp/portstat-{uid}/{uid}-{filename}
2. New design: After running “portstat -c -t  filename”, status file will be created on the folder of /tmp/cache/portstat/{uid}-{filename}

Change-Id: Ia122a08b9a55a26fe6a299d74d2df1f1949c7ca3
  • Loading branch information
JibinBao authored and wangxin committed Sep 28, 2022
1 parent cfa807f commit 76b004b
Showing 1 changed file with 10 additions and 10 deletions.
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

0 comments on commit 76b004b

Please sign in to comment.