* [PATCH] KVM test: Ensure multiple pre/post commands can run
@ 2010-02-05 11:16 Lucas Meneghel Rodrigues
0 siblings, 0 replies; 4+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-02-05 11:16 UTC (permalink / raw)
To: autotest; +Cc: kvm
The way tests are currently defined, running unattended
install + hugepages will allways skip unattended install
setup step (coincidentally the tests on our test farm
were working because previous executions of the unattended
install script ran, leaving the environment prepared for
unattended install).
So, make sure pre_commands on default tests.cfg file are
additive, and the preprocessor splits the pre_command
string, and executes pre/post commands in sequence.
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
client/tests/kvm/kvm_preprocessing.py | 29 ++++++++++++++++-------------
client/tests/kvm/tests_base.cfg.sample | 4 ++--
2 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py
index 8a0c151..2e35d9f 100644
--- a/client/tests/kvm/kvm_preprocessing.py
+++ b/client/tests/kvm/kvm_preprocessing.py
@@ -126,7 +126,7 @@ def postprocess_vm(test, params, env, name):
vm.destroy(gracefully = params.get("kill_vm_gracefully") == "yes")
-def process_command(test, params, env, command, command_timeout,
+def process_command(test, params, env, commands, command_timeout,
command_noncritical):
"""
Pre- or post- custom commands to be executed before/after a test is run
@@ -134,22 +134,23 @@ def process_command(test, params, env, command, command_timeout,
@param test: An Autotest test object.
@param params: A dict containing all VM and image parameters.
@param env: The environment (a dict-like object).
- @param command: Command to be run.
+ @param commands: List of commands to be run.
@param command_timeout: Timeout for command execution.
@param command_noncritical: If True test will not fail if command fails.
"""
# Export environment vars
for k in params.keys():
os.putenv("KVM_TEST_%s" % k, str(params[k]))
- # Execute command
- try:
- utils.system("cd %s; %s" % (test.bindir, command))
- except error.CmdError, e:
- logging.warn("Custom processing command '%s' failed, output is: %s",
- command, str(e))
- if not command_noncritical:
- raise error.TestError("Custom processing command failed: %s" %
- str(e))
+ # Execute commands
+ for command in commands:
+ try:
+ utils.system("cd %s; %s" % (test.bindir, command))
+ except error.CmdError, e:
+ logging.warn("Custom processing command '%s' failed, output is: %s",
+ command, str(e))
+ if not command_noncritical:
+ raise error.TestError("Custom processing command failed: %s" %
+ str(e))
def process(test, params, env, image_func, vm_func):
@@ -220,7 +221,8 @@ def preprocess(test, params, env):
# Execute any pre_commands
if params.get("pre_command"):
- process_command(test, params, env, params.get("pre_command"),
+ pre_commands = params.get("pre_command").spit()
+ process_command(test, params, env, pre_commands,
int(params.get("pre_command_timeout", "600")),
params.get("pre_command_noncritical") == "yes")
@@ -296,7 +298,8 @@ def postprocess(test, params, env):
# Execute any post_commands
if params.get("post_command"):
- process_command(test, params, env, params.get("post_command"),
+ post_commands = params.get("post_command").split()
+ process_command(test, params, env, post_commands,
int(params.get("post_command_timeout", "600")),
params.get("post_command_noncritical") == "yes")
diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
index 91daf48..8f88f3b 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -66,7 +66,7 @@ variants:
kill_vm_gracefully = yes
kill_vm_on_error = yes
force_create_image = yes
- pre_command = scripts/unattended.py
+ pre_command += " scripts/unattended.py"
floppy = "images/floppy.img"
extra_params += " -boot d"
nic_mode = user
@@ -953,7 +953,7 @@ variants:
variants:
- @smallpages:
- hugepages:
- pre_command = "/usr/bin/python scripts/hugepage.py /mnt/kvm_hugepage"
+ pre_command += " scripts/hugepage.py"
extra_params += " -mem-path /mnt/kvm_hugepage"
--
1.6.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM test: Ensure multiple pre/post commands can run
[not found] <1712820999.1156341265565305970.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
@ 2010-02-07 17:59 ` Michael Goldish
2010-02-08 1:11 ` Lucas Meneghel Rodrigues
0 siblings, 1 reply; 4+ messages in thread
From: Michael Goldish @ 2010-02-07 17:59 UTC (permalink / raw)
To: Lucas Meneghel Rodrigues; +Cc: kvm, autotest
----- "Lucas Meneghel Rodrigues" <lmr@redhat.com> wrote:
> The way tests are currently defined, running unattended
> install + hugepages will allways skip unattended install
> setup step (coincidentally the tests on our test farm
> were working because previous executions of the unattended
> install script ran, leaving the environment prepared for
> unattended install).
>
> So, make sure pre_commands on default tests.cfg file are
> additive, and the preprocessor splits the pre_command
> string, and executes pre/post commands in sequence.
>
> Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
Why not just append ';' to each command?
For example:
pre_command = "scripts/unattended.py;"
...
pre_command += " scripts/hugepage.py;"
(the quotes can be omitted)
IMO this is simpler.
Also, by using "".split() you're not allowing commands that
contain spaces.
> ---
> client/tests/kvm/kvm_preprocessing.py | 29
> ++++++++++++++++-------------
> client/tests/kvm/tests_base.cfg.sample | 4 ++--
> 2 files changed, 18 insertions(+), 15 deletions(-)
>
> diff --git a/client/tests/kvm/kvm_preprocessing.py
> b/client/tests/kvm/kvm_preprocessing.py
> index 8a0c151..2e35d9f 100644
> --- a/client/tests/kvm/kvm_preprocessing.py
> +++ b/client/tests/kvm/kvm_preprocessing.py
> @@ -126,7 +126,7 @@ def postprocess_vm(test, params, env, name):
> vm.destroy(gracefully = params.get("kill_vm_gracefully") ==
> "yes")
>
>
> -def process_command(test, params, env, command, command_timeout,
> +def process_command(test, params, env, commands, command_timeout,
> command_noncritical):
> """
> Pre- or post- custom commands to be executed before/after a test
> is run
> @@ -134,22 +134,23 @@ def process_command(test, params, env, command,
> command_timeout,
> @param test: An Autotest test object.
> @param params: A dict containing all VM and image parameters.
> @param env: The environment (a dict-like object).
> - @param command: Command to be run.
> + @param commands: List of commands to be run.
> @param command_timeout: Timeout for command execution.
> @param command_noncritical: If True test will not fail if command
> fails.
> """
> # Export environment vars
> for k in params.keys():
> os.putenv("KVM_TEST_%s" % k, str(params[k]))
> - # Execute command
> - try:
> - utils.system("cd %s; %s" % (test.bindir, command))
> - except error.CmdError, e:
> - logging.warn("Custom processing command '%s' failed, output
> is: %s",
> - command, str(e))
> - if not command_noncritical:
> - raise error.TestError("Custom processing command failed:
> %s" %
> - str(e))
> + # Execute commands
> + for command in commands:
> + try:
> + utils.system("cd %s; %s" % (test.bindir, command))
> + except error.CmdError, e:
> + logging.warn("Custom processing command '%s' failed,
> output is: %s",
> + command, str(e))
> + if not command_noncritical:
> + raise error.TestError("Custom processing command
> failed: %s" %
> + str(e))
>
>
> def process(test, params, env, image_func, vm_func):
> @@ -220,7 +221,8 @@ def preprocess(test, params, env):
>
> # Execute any pre_commands
> if params.get("pre_command"):
> - process_command(test, params, env,
> params.get("pre_command"),
> + pre_commands = params.get("pre_command").spit()
> + process_command(test, params, env, pre_commands,
> int(params.get("pre_command_timeout",
> "600")),
> params.get("pre_command_noncritical") ==
> "yes")
>
> @@ -296,7 +298,8 @@ def postprocess(test, params, env):
>
> # Execute any post_commands
> if params.get("post_command"):
> - process_command(test, params, env,
> params.get("post_command"),
> + post_commands = params.get("post_command").split()
> + process_command(test, params, env, post_commands,
> int(params.get("post_command_timeout",
> "600")),
> params.get("post_command_noncritical") ==
> "yes")
>
> diff --git a/client/tests/kvm/tests_base.cfg.sample
> b/client/tests/kvm/tests_base.cfg.sample
> index 91daf48..8f88f3b 100644
> --- a/client/tests/kvm/tests_base.cfg.sample
> +++ b/client/tests/kvm/tests_base.cfg.sample
> @@ -66,7 +66,7 @@ variants:
> kill_vm_gracefully = yes
> kill_vm_on_error = yes
> force_create_image = yes
> - pre_command = scripts/unattended.py
> + pre_command += " scripts/unattended.py"
> floppy = "images/floppy.img"
> extra_params += " -boot d"
> nic_mode = user
> @@ -953,7 +953,7 @@ variants:
> variants:
> - @smallpages:
> - hugepages:
> - pre_command = "/usr/bin/python scripts/hugepage.py
> /mnt/kvm_hugepage"
> + pre_command += " scripts/hugepage.py"
> extra_params += " -mem-path /mnt/kvm_hugepage"
>
>
> --
> 1.6.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM test: Ensure multiple pre/post commands can run
2010-02-07 17:59 ` [PATCH] KVM test: Ensure multiple pre/post commands can run Michael Goldish
@ 2010-02-08 1:11 ` Lucas Meneghel Rodrigues
2010-02-09 12:58 ` [Autotest] " Lucas Meneghel Rodrigues
0 siblings, 1 reply; 4+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-02-08 1:11 UTC (permalink / raw)
To: Michael Goldish; +Cc: kvm, autotest
On Sun, 2010-02-07 at 12:59 -0500, Michael Goldish wrote:
> ----- "Lucas Meneghel Rodrigues" <lmr@redhat.com> wrote:
>
> > The way tests are currently defined, running unattended
> > install + hugepages will allways skip unattended install
> > setup step (coincidentally the tests on our test farm
> > were working because previous executions of the unattended
> > install script ran, leaving the environment prepared for
> > unattended install).
> >
> > So, make sure pre_commands on default tests.cfg file are
> > additive, and the preprocessor splits the pre_command
> > string, and executes pre/post commands in sequence.
> >
> > Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
>
> Why not just append ';' to each command?
>
> For example:
>
> pre_command = "scripts/unattended.py;"
> ...
> pre_command += " scripts/hugepage.py;"
>
> (the quotes can be omitted)
>
> IMO this is simpler.
Yes, agreed. Will revert the patch and fix this.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Autotest] [PATCH] KVM test: Ensure multiple pre/post commands can run
2010-02-08 1:11 ` Lucas Meneghel Rodrigues
@ 2010-02-09 12:58 ` Lucas Meneghel Rodrigues
0 siblings, 0 replies; 4+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-02-09 12:58 UTC (permalink / raw)
To: Michael Goldish; +Cc: autotest, kvm
FYI, reverted:
http://autotest.kernel.org/changeset/4227
On Sun, Feb 7, 2010 at 11:11 PM, Lucas Meneghel Rodrigues
<lmr@redhat.com> wrote:
> On Sun, 2010-02-07 at 12:59 -0500, Michael Goldish wrote:
>> ----- "Lucas Meneghel Rodrigues" <lmr@redhat.com> wrote:
>>
>> > The way tests are currently defined, running unattended
>> > install + hugepages will allways skip unattended install
>> > setup step (coincidentally the tests on our test farm
>> > were working because previous executions of the unattended
>> > install script ran, leaving the environment prepared for
>> > unattended install).
>> >
>> > So, make sure pre_commands on default tests.cfg file are
>> > additive, and the preprocessor splits the pre_command
>> > string, and executes pre/post commands in sequence.
>> >
>> > Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
>>
>> Why not just append ';' to each command?
>>
>> For example:
>>
>> pre_command = "scripts/unattended.py;"
>> ...
>> pre_command += " scripts/hugepage.py;"
>>
>> (the quotes can be omitted)
>>
>> IMO this is simpler.
>
> Yes, agreed. Will revert the patch and fix this.
>
> _______________________________________________
> Autotest mailing list
> Autotest@test.kernel.org
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>
--
Lucas
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-02-09 12:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1712820999.1156341265565305970.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2010-02-07 17:59 ` [PATCH] KVM test: Ensure multiple pre/post commands can run Michael Goldish
2010-02-08 1:11 ` Lucas Meneghel Rodrigues
2010-02-09 12:58 ` [Autotest] " Lucas Meneghel Rodrigues
2010-02-05 11:16 Lucas Meneghel Rodrigues
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox