-
Notifications
You must be signed in to change notification settings - Fork 452
Validators in scripting languages
The validator script_validator allows you to write validation logic in your language of choice (Python, PHP, Perl, Java, bash). script_validator takes two additional command-line arguments:
--init_script "scriptname arg1 ... argn"
--compare_script "scriptname arg1 ... argn"
--init_script
specifies a script to check the validity of a result.
The script is passed parameters (see below) that identify the result.
The script's exit code is:
- zero if the result is valid
- 3 (
VAL_RESULT_TRANSIENT_ERROR
insched/validate_util2.h
) if a transient error occurred (for example, a file open failed because of an NFS mount failure). In this case the validation will tried again in a few hours. - Any other nonzero value indicates an error, and the result is marked as invalid.
--compare_script
specifies a script to compare two results.
The script's exit code is
- zero if the results match
- 3 (
VAL_RESULT_TRANSIENT_ERROR
insched/validate_util2.h
) if a transient error occurred. - Any other nonzero value if the results don't match.
The scripts must be put in your project's bin/ directory.
For applications that don't use replication, the compare script need not be given. For applications that don't need output file syntax checking, the init script need not be given.
arg1 ... argn
represent cmdline args to be passed to the scripts.
The options for the init script are:
files
:
list of paths of output files of the result
result_id
: the result ID.
runtime
: the job runtime in seconds
The options for the compare script include the above, and also:
files2
:
list of paths of output files of the 2nd result.
result_id2
: ID of the 2nd result.
runtime2
: runtime of the 2nd result, in seconds.
For both scripts,
arg1 ... argn
can be omitted,
in which case only the output file paths are passed to the script.
As an example, the following PHP script, used as a compare script, requires that results match exactly:
#!/usr/bin/env php
<?php
$f1 = $argv[1];
$f2 = $argv[2];
if (md5_file($f1) != md5_file($f2)) {
fwrite(STDERR, "$f1 and $f2 don't match\n");
exit(1);
}
?>
The corresponding entry in config.xml would look like
<daemon>
<cmd>script_validator --app uppercase --compare_script compare.php</cmd>
...
</daemon>