Add validation for running arnied process for the unset_cnf function
authorPlamen Dimitrov <pdimitrov@pevogam.com>
Tue, 19 Nov 2019 08:58:24 +0000 (10:58 +0200)
committerPlamen Dimitrov <pdimitrov@pevogam.com>
Tue, 19 Nov 2019 09:03:55 +0000 (11:03 +0200)
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.

src/arnied_wrapper.py
test/test_arnied_wrapper.py

index b00f135..1c29c18 100644 (file)
@@ -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)
 
index e5095b4..f831887 100755 (executable)
@@ -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()