diff --git a/tests/tacacs/test_accounting.py b/tests/tacacs/test_accounting.py index c06c07bb63a..78c828f9970 100644 --- a/tests/tacacs/test_accounting.py +++ b/tests/tacacs/test_accounting.py @@ -101,13 +101,18 @@ def check_tacacs_server_no_other_user_log(ptfhost, tacacs_creds): def check_local_log_exist(duthost, tacacs_creds, command): """ + Remove all ansible command log with /D command, + which will match following format: + "ansible.legacy.command Invoked" + Find logs run by tacacs_rw_user from syslog: Find logs match following format: "INFO audisp-tacplus: Accounting: user: tacacs_rw_user,.*, command: .*command," Print matched logs with /P command. """ username = tacacs_creds['tacacs_rw_user'] - log_pattern = "/INFO audisp-tacplus.+Accounting: user: {0},.*, command: .*{1},/P" \ + log_pattern = "/ansible.legacy.command Invoked/D;\ + /INFO audisp-tacplus.+Accounting: user: {0},.*, command: .*{1},/P" \ .format(username, command) logs = wait_for_log(duthost, "/var/log/syslog", log_pattern) @@ -128,6 +133,9 @@ def check_local_log_exist(duthost, tacacs_creds, command): def check_local_no_other_user_log(duthost, tacacs_creds): """ Find logs not run by tacacs_rw_user from syslog: + Remove all ansible command log with /D command, + which will match following format: + "ansible.legacy.command Invoked" Remove all tacacs_rw_user's log with /D command, which will match following format: @@ -139,7 +147,9 @@ def check_local_no_other_user_log(duthost, tacacs_creds): Print matched logs with /P command, which are not run by tacacs_rw_user. """ username = tacacs_creds['tacacs_rw_user'] - log_pattern = "/INFO audisp-tacplus: Accounting: user: {0},/D;/INFO audisp-tacplus: Accounting: user:/P" \ + log_pattern = "/ansible.legacy.command Invoked/D;\ + /INFO audisp-tacplus: Accounting: user: {0},/D;\ + /INFO audisp-tacplus: Accounting: user:/P" \ .format(username) logs = wait_for_log(duthost, "/var/log/syslog", log_pattern)