From: Plamen Dimitrov Date: Tue, 19 Nov 2019 08:58:24 +0000 (+0200) Subject: Add validation for running arnied process for the unset_cnf function X-Git-Tag: v1.6.3~3 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=d944615552171b4ae011d603f1c3ca2aee679a61;p=pyi2ncommon Add validation for running arnied process for the unset_cnf function This is the least developed arnied cnfvar function mostly because we rarely had to unset any pre-existing cnfvar. Independently of use cases, this function is required to validate the arnied process is running in a similar manner to the more developed get/set functions. --- diff --git a/src/arnied_wrapper.py b/src/arnied_wrapper.py index b00f135..1c29c18 100644 --- a/src/arnied_wrapper.py +++ b/src/arnied_wrapper.py @@ -523,15 +523,18 @@ def wait_for_generate(timeout=300, vm=None): wait_for_run('generate_offline', timeout=timeout, retries=1, vm=vm) -def unset_cnf(varname="", instance="", vm=None): +def unset_cnf(varname="", instance="", timeout=30, vm=None): """ Remove configuration from arnied. :param str varname: "varname" field of the CNF_VAR to unset :param int instance: "instance" of that variable to unset + :param int timeout: arnied run verification timeout :param vm: vm to run on if running on a guest instead of the host :type vm: VM object or None """ + verify_running(timeout=timeout, vm=vm) + cmd = "get_cnf %s %s | set_cnf -x" % (varname, instance) run_cmd(cmd=cmd, vm=vm) diff --git a/test/test_arnied_wrapper.py b/test/test_arnied_wrapper.py index e5095b4..f831887 100755 --- a/test/test_arnied_wrapper.py +++ b/test/test_arnied_wrapper.py @@ -44,6 +44,7 @@ class DummyCmdOutputMapping(object): {"cmd": 'get_cnf PROVIDER 1', "stdout": b"PRODIVER 1, 'autotest'", "returncode": 0}, {"cmd": 'tell-connd --online P1', "stdout": b"", "returncode": 0}, + {"cmd": "pgrep -l -x arnied", "stdout": b"", "returncode": 0}, {"cmd": 'get_cnf VIRSCAN_UPDATE_CRON | set_cnf -x', "stdout": b"", "returncode": 0}, {"cmd": '/usr/intranator/bin/arnied_helper --is-scheduled-or-running GENERATE', "stdout": b"", "returncode": 1}, {"cmd": '/usr/intranator/bin/arnied_helper --wait-for-program-end GENERATE --wait-for-program-timeout 300', "stdout": b"", "returncode": 1}, @@ -109,9 +110,9 @@ class ArniedWrapperTest(unittest.TestCase): # arnied_wrapper.go_online(1) def test_disable_virscan(self): - DummyCmdOutputMapping.asserted_cmds = self.cmd_db[5:12] + DummyCmdOutputMapping.asserted_cmds = self.cmd_db[5:13] arnied_wrapper.disable_virscan() def test_email_transfer(self): - DummyCmdOutputMapping.asserted_cmds = self.cmd_db[12:13] + DummyCmdOutputMapping.asserted_cmds = self.cmd_db[13:14] arnied_wrapper.email_transfer()