Skip to contentSkip to conversation

Added functionality to the preprocessor to run scripts

PATCH Michael Goldish 3 participants 3 messages Jun 3, 2009 1 message not in the archive KVM

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 23 lines · ----- "Avi Kivity

Review

Quoted 13 lines · David Huff

This patch will run pre and post scripts defined in config file with the parameter pre_command and post_command post_command.

Also exports all the prameters in preprocess for passing arguments to the script.

(quoted diff) +6 -0
+   #execute any pre_commands
+    pre_command = params.get("pre_command")
+    if pre_command:
+        # export environment vars
+        for k in params.keys():
+            kvm_log.info("Adding KVM_TEST_%s to Environment" %

(k))

Review

Quoted 5 lines
(quoted diff) +5 -0
+            os.putenv("KVM_TEST_%s" % (k), str(params[k]))
+        # execute command
+        kvm_log.info("Executing command '%s'..." % pre_command)
+        timeout = int(params.get("pre_commmand_timeout", "600"))
+        (status, pid, output) = kvm_utils.run_bg("cd %s; %s" %

(test.bindir, pre_command),

Quoted 1 line

+ None,

kvm_log.debug, "(pre_command) ", timeout=timeout)

Quoted 8 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+        if status != 0:
+            kvm_utils.safe_kill(pid, signal.SIGTERM)
+            raise error.TestError, "Custom processing pre_command

failed"

Quoted 1 line

kvm_utils.run_bg should throw an exception instead of returning status.

- What if we're interested in the status for some reason? Its value may indicate what went wrong with the child process.
- If we throw an exception we should add a parameter that controls whether an exception should be thrown (something like "ignore_status") because in some cases we don't want to throw an exception.
- A run_bg call has 3 possible outcomes: success (status == 0), failure (status != 0) and timeout (process still running). If we throw an exception upon failure, what do we do upon timeout? Sometimes it's good (qemu should keep running unless something went wrong) and sometimes bad (pre_command should probably not time out). So we end up needing an ignore_timeout parameter as well.
- What if we want the test to fail with an informative test-specific exception such as "something failed after migration"?

Quoted 1 line

But if status != 0, will there actually be a pid to kill?

If the timeout expires and the process is still running, status is None.

Quoted 7 lines
Signature · 6 lines
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
Quoted 41 lines · Michael Goldish
Quoted 38 lines · ----- "Avi Kivity
Quoted 8 lines · David Huff

This patch will run pre and post scripts defined in config file with the parameter pre_command and post_command post_command.

Also exports all the prameters in preprocess for passing arguments to the script.

Review

Quoted 6 lines
(quoted diff) +6 -0
+   #execute any pre_commands
+    pre_command = params.get("pre_command")
+    if pre_command:
+        # export environment vars
+        for k in params.keys():
+            kvm_log.info("Adding KVM_TEST_%s to Environment" %

(k))

Review

Quoted 6 lines
(quoted diff) +5 -0
+            os.putenv("KVM_TEST_%s" % (k), str(params[k]))
+        # execute command
+        kvm_log.info("Executing command '%s'..." % pre_command)
+        timeout = int(params.get("pre_commmand_timeout", "600"))
+        (status, pid, output) = kvm_utils.run_bg("cd %s; %s" %

(test.bindir, pre_command),

Quoted 2 lines

+ None,

kvm_log.debug, "(pre_command) ", timeout=timeout)

Review

Quoted 4 lines
(quoted diff) +3 -0
+        if status != 0:
+            kvm_utils.safe_kill(pid, signal.SIGTERM)
+            raise error.TestError, "Custom processing pre_command

failed"

Quoted 2 lines
Quoted 7 lines
Quoted 3 lines

kvm_utils.run_bg should throw an exception instead of returning status.

- What if we're interested in the status for some reason? Its value may indicate what went wrong with the child process.

Put it in the exception string.

Quoted 4 lines

- If we throw an exception we should add a parameter that controls whether an exception should be thrown (something like "ignore_status") because in some cases we don't want to throw an exception.

I'll complain every time I see it. If you don't care if the command succeeds or not, why run it in the first place?

Quoted 7 lines

- A run_bg call has 3 possible outcomes: success (status == 0), failure (status != 0) and timeout (process still running). If we throw an exception upon failure, what do we do upon timeout? Sometimes it's good (qemu should keep running unless something went wrong) and sometimes bad (pre_command should probably not time out). So we end up needing an ignore_timeout parameter as well.

A run_bg() call should return an object with a .join() method, or throw an exception. At some point you must call the join() method, which throws an exception or returns None.

Quoted 3 lines

- What if we want the test to fail with an informative test-specific exception such as "something failed after migration"?

Chained exceptions can provide detailed information.

Quoted 5 lines
Quoted 2 lines

But if status != 0, will there actually be a pid to kill?

If the timeout expires and the process is still running, status is None.

functions which can return with three possible outcomes are difficult to use.

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
#3 lore raw
In reply to Michael Goldish
Quoted 25 lines · Michael Goldish
Quoted 23 lines · ----- "Avi Kivity

Review

Quoted 13 lines · David Huff

This patch will run pre and post scripts defined in config file with the parameter pre_command and post_command post_command.

Also exports all the prameters in preprocess for passing arguments to the script.

(quoted diff) +6 -0
+   #execute any pre_commands
+    pre_command = params.get("pre_command")
+    if pre_command:
+        # export environment vars
+        for k in params.keys():
+            kvm_log.info("Adding KVM_TEST_%s to Environment" %

(k))

Review

Quoted 5 lines
(quoted diff) +5 -0
+            os.putenv("KVM_TEST_%s" % (k), str(params[k]))
+        # execute command
+        kvm_log.info("Executing command '%s'..." % pre_command)
+        timeout = int(params.get("pre_commmand_timeout", "600"))
+        (status, pid, output) = kvm_utils.run_bg("cd %s; %s" %

(test.bindir, pre_command),

Quoted 1 line

+ None,

kvm_log.debug, "(pre_command) ", timeout=timeout)

Quoted 8 lines
Quoted 8 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+        if status != 0:
+            kvm_utils.safe_kill(pid, signal.SIGTERM)
+            raise error.TestError, "Custom processing pre_command

failed"

Quoted 1 line

kvm_utils.run_bg should throw an exception instead of returning status.

utils.system or utils.run will throw a error.CmdError exception on exit code !=0. The representation and the printed format of CmdErrors contain the exit code, the full string of the command and stuff like that.

And yes, I agree in general that we should throw exceptions when command fails. If the failure is not bad enough to stop the whole test, we can catch the exception and increment failure counters or something to keep record of the failures.

Quoted 29 lines

- What if we're interested in the status for some reason? Its value may indicate what went wrong with the child process.
- If we throw an exception we should add a parameter that controls whether an exception should be thrown (something like "ignore_status") because in some cases we don't want to throw an exception.
- A run_bg call has 3 possible outcomes: success (status == 0), failure (status != 0) and timeout (process still running). If we throw an exception upon failure, what do we do upon timeout? Sometimes it's good (qemu should keep running unless something went wrong) and sometimes bad (pre_command should probably not time out). So we end up needing an ignore_timeout parameter as well.
- What if we want the test to fail with an informative test-specific exception such as "something failed after migration"?

Quoted 1 line

But if status != 0, will there actually be a pid to kill?

If the timeout expires and the process is still running, status is None.

Quoted 7 lines
Signature · 6 lines
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 3 lines
Lucas Meneghel Rodrigues
Software Engineer (QE)
Red Hat - Emerging Technologies