An assignment is described by a YAML file that contains information on how to
build, run and test it. The testing process is divided into stages.
### Tests
A test is a pair of files, where the first one specifies an input and the other
one the expected output. Tests can be organized into groups for easier
organization and to facilitate more complex grading scenarios (e.g. "An
assignment passes only if it passes all tests in group X").
Tests are run by a special program called a *judge*, which compares the output
of the program to the expected output. By setting a judge, we can specify how
strict the testing is - for example, some assignments require the solution to
output exactly the same bytes as expected. Others permit any number of
whitespace characters between words of the output.
### Stages
A stage is a logical unit of the testing process. It specifies how to do a step
in the build process and how to test if the student's submission behaves
correctly. After the evaluation, the worker outputs a log for every processed
stage that contains information such as which tests passed and how many
resources were used.
A stage's configuration contains the following (this doesn't yet map exactly to
a particular configuration file format):
- **Name** - a unique string identifier of the stage
- **Build command** (optional) - used to prepare the submitted files for this
test stage
- **Test list** - specifies the tests (or test groups) to be run during this
stage
- **Test command** - used to run one specific test
- **Test input policy** - how to pass the test input to the program?
- **redirect** it to its standard input (default)
- pass the path to an input file as an **argument**
- **Judge** - which judge should be used to evaluate the solution's output?
Custom judges can be supplied with the assignment.
- **Limits** - how much memory, time, etc. can be used when evaluating a test
- **Error policy** (optional) - what should we do when a test fails?
- **interrupt** the evaluation (default)
- **continue** with another **test**
- **continue** with another **group**
- **jump** to another stage
- **Success policy** (optional) - what to do when all tests pass?
- **jump** to another stage (the next one by default)
- **end** the evaluation, even if there are still unprocessed stages
When jumping between stages, it's only possible to jump forward, so that no
stage is evaluated multiple times.
build, run and test it.
### Terminology
Following text requires knowledge of basic terminology used by ReCodEx. Please, check [separate page](https://github.com/ReCodEx/GlobalWiki/wiki/Terminology).
### Basics
Job is a set/list of tasks (it is generally a set, but order of tasks have some meaning). These tasks may have dependencies (arbitrary number), which needs to be observed. When isoeval processes job, it creates a task graph, where tasks are vertices and dependencies are edges (A -> B means that the task B is on the dependency list of task A) and creates it linear ordering. The graph must be acyclic (otherwise linear ordering will not exist) and the isoeval attempts to execute maximal number of tasks possible. Tasks without dependencies can be executed directly, other tasks are executed when all their dependencies have been successfully completed.
Tasks are executed sequentially -- by the linear ordering of the task graph. Parallel tasks (tasks, which are not directly dependent and thus their linear ordering may be arbitrary) are ordered by their priority (first) and by their order in the configuration file (second). Priority is important for specifying evaluation flow. See sample picture for better understanding.
_**TODO**_ insert picture
Each task has a unique ID (alphanum string like _compile_, _test01_, or _judge01_). These IDs are used to identify tasks (for dependency references, in the log, ...).
### Task
Task is an atomic piece of work executed by isoeval. There are two basic types of tasks (so far):
- **Execute external process** (optionally inside Isolate). Linux default will be mandatory in Isolate, this option is here because of Windows.
- **Perform internal operation**. External processes are meant for compilation, testing, or execution of external judges. Internal operations comprise commands, which are typically related to file/directory maintenance and other evaluation management stuff. Few important examples:
- Create/delete/move/check file/directory
- (un)zip/tar/gzip/bzip file(s)
- fetch a file from the file repository (either from worker cache or download it by HTTP GET or through SFTP).
Even though the internal operations may be handled by external executables (`mv`, `tar`, `pkzip`, `wget`, ...), it might be better to keep them inside the isoeval as it would simplify these operations and their portability among platforms. Furthermore, it is quite easy to implement them using common libraries (e.g., _zlib_, _curl_).
**External Tasks**
(some of the properties specified here may also apply for internal tasks -- needs to be determined later)
These tasks are typically executed in isolate (with given parameters) and the isoeval waits until they finish. The exit code determines, whether the task succeeded (0) or failed (anything else). A task may be marked as essential; in such case, failure will immediately cause termination of the whole job.
- **stdin** - can be configured to read from existing file or from /dev/null.
- **stdout** and **stderr** - can be individually redirected to a file or discarded. Optionally, a copy can be directed to selected log (for example common log for compilations). In any case, outputs of all tasks are saved in external files (inside log directory) and optionally included into the job output (see Directories).
- **limits** - task have time and memory limits; if these limits are exceeded, the task also fails. Additionally, a second memory/time limit may be provided (for the Isolate) -- then the first limits are "soft limits" (used only to determine, whether the task succeeded) and the second limits are hard limits (really kills the process).
The task results (exit code, time, and memory consumption) are save into parameter global structure (see Parameters And Results).
### Directories and Files
The isoeval job is restricted to operate on several subdirs; each path used in task configuration must start with identifier of one of these dirs and no '..' are allowed in paths.
- **input** - where the input files (source codes) are prepared
- **output** - anything that is moved/copied to this dir is taken as output of the job and sent back to frontend (where it is stored)
- **box** - empty dir which can be used for compilation/evaluation/... (an internal task for cleaning this box may exist). **Every test needs to have separate subfolder here to avoid sharing data between tests.**
- **log** - directory, where log files are and where outputs of all tasks are copied. Each task has a directory here with the same name with _stdout_ and _stderr_ files. Tasks cannot access **log** directory, except they can produce or redirect output to logs.
### Configuration
Configuration of the job which is passed to worker is generated from two parts:
- **template** - Common template for similar kinds of tasks. Contains allmost all instructions - when fetch, move, rename files, run commands, judges, ..., task dependencies and priorities. This template can be shared by more problem assignments or every problem (probably in compiller class) can have different one.
- **isoeval config** - includes data for instancioning the template, e.q. input file names, ...
Final configuration for worker is computer generated from those two configs.
### Parameters And Results
The job may have some input parameters (e.g., default config for Isolate, global parameters for the tested processes, ...). Similarly, the job has some structured results -- for each task (where applicable), it gathers exit code and consumed time and memory.
These parameters are stored in global, structured parameter space. I would suggest something that would map easily on JSON, for instance -- i.e., something that supports structures (named collections), arrays (ordered collections), and basic numeric and string values.
Input parameters have two sources, some defaults are present in the configuration of the worker, another set is provided in the configuration of the job. These sets are merged, job config has a priority.
Parameters are only read by the tasks (they can be used in task parameters). Some simple syntax needs to be used for evaluation of parameter expressions -- e.g., ("${params.tests[1].memoryLimit}"). _**TODO:** analysis required -- how complex expressions do we really need_
### Logs
There is one general (mandatory) log, where the job progress is logged. Each row corresponds to one task and it holds only the task name, task exit code (or some other indication whether the task ended OK or not), and optionally things like consumed memory and time.
Other logs (stored in log dir) can be created. They do not have to be declared in advance, but they are specified at each task (if its output is going to a log) and created once some task produces an output that goes to the log.