Separate test loading and introduce test state

This commit implements two very different things, but still very
much connected:

1) Separate test loading to the process that will be actually
running the test. This leads to a better separation of duties of
the process interacting with the user and the process that is
actually doing the (usually) heavy work.

2) Remove the pickling of the test instance and sending it back
and forth.

As an added bonus, it was noted during development, that both
processes load all necessary Python modules (including the test
module) when unmarshalling the pickled instance, resulting in
unecessary work. Actual data on performance improvements were not
collected though.

It has one change in behaviour (regression) though. Test timeout
now comes only from the test parameters. The reasoning is that
since there's now a better separation of roles and the fact that
the first process is not loading the test instance, it can not
look at the timeout defined there.

IMHO this is a sign of good design, since other types of test
(think of shell scripts) can not communicate their intended timeout.
Maybe a 'test.cfg' or something like that should be the solution to
that.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
Add Job's unique_id to test state

Signed-off-by: Cleber Rosa <crosa@redhat.com>
journal plugin: adapat to test state

Since other more standard plugins have moved to test state in a previous commit
the journal plugin should also follow that.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
journal plugin: make code more resilient

In some circurnstances, the journal may be accessed simultaneously by
multiple code paths. The database consistency should be enforced in any
case, and only initialized and populated when appropriate.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
avocado/core/output.py: implement progress notification via a throbber

It's now a known fact that long test runs are can lead to doubts with
regards to the actual test run status (is it frozen or really busy?).

To give users a better experience, the OutputManager now implements
a throbber for progress feedback.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
avocado/result.py: give an extra space for the progress throbber

Signed-off-by: Cleber Rosa <crosa@redhat.com>
avocado/job.py: implement test progress feedback via a throbber

If the test process is running, the trobber will give feedback about that
to the user.

This requires the process triggering and timeout handling to be completely
different than the previous implementation.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
avocado.core.exceptions: Introduce TestAbortError

Introduce a TestAbortError, used for when an avocado test
aborts.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado.job.py: Get early test state before action starts

Put state of the initialized test in the multiprocess Queue,
so we have a lot of accurate information that does not need
to be mocked, we only have to mock the failure reason and
time elapsed. With this, aborted tests can be handled more
gracefully.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado.job: Enable tests timeout

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado.job: Call throbber progress conditionally

Previously, the throbber update method was being called
unconditionally, making throbber progress to appear even
when human output was not enabled. Fix this by making
a proxy method that calls it only if there is a human
plugin enabled, in TestResultProxy.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado.job: Restore ability to fail tests upon timeout

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado.plugins.vm: Adapt to test seate

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado.result: Fix docstring

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
selftests: Fix all unittests to use test state

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
tests: Add abort test

This calls os.abort() as the test action, testing avocado
ability of handle this case correctly.

Signed-off-by: Ruda Moura <rmoura@redhat.com>
avocado.job: Log a better error message on abort

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
selftests/functional: Add abort error to suite of functional tests

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>