Controller: add more comprehensive explanation about proc_id and bg_id

Signed-off-by: Jan Tluka <jtluka@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Common: Move DEFAULT_TIMEOUT to NetTestCommand

The DEFAULT_TIMEOUT variable will be used from different modules so make this
variable available in common code.

Signed-off-by: Jan Tluka <jtluka@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Common: add variable to store the time when a command started

Signed-off-by: Jan Tluka <jtluka@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Slave: add get_remaining_time method

This patch adds get_remaining_time() method to NetTestSlave. It's used to make
a query from the controller to check if a command running in background has
timeouted.

Signed-off-by: Jan Tluka <jtluka@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Controller: fix the handling of background process timeouts

This patch fixes an incorrect key 'bg_id' to 'proc_id' for handling wait
command.

Futher it changes how the commands running in background are handled when
wait command is called. When a user calls wait command the controller first
queries the remaining time of the associated bg process. If it has not
timeouted yet the alarm is set to trigger on time calculated from the returned
value of get_remaining_time(). If the bg process already timeouted the alarm is set to two seconds just to give some time to reach the try/exception block.
Not 100% clean but works reliably than before.

Tested by following recipe:

<lnstrecipe>
        <network>
                <host id="m1">
                        <interfaces>
                                <eth id="x" label="netA"/>
                        </interfaces>
                </host>
        </network>

        <task>
                <run host="m1" command="sleep 5" timeout="2"/>
                <run host="m1" command="sleep 5" timeout="2" bg_id="1"/>
                <wait host="m1" bg_id="1"/>
                <run host="m1" command="sleep 5" timeout="6" bg_id="2"/>
                <wait host="m1" bg_id="2"/>
                <run host="m1" command="sleep 5" timeout="2" bg_id="3"/>
                <run host="m1" command="sleep 5" timeout="2" bg_id="4"/>
                <wait host="m1" bg_id="3"/>
                <wait host="m1" bg_id="4"/>
        </task>
</lnstrecipe>

Signed-off-by: Jan Tluka <jtluka@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Merge branch 'enhance_background_process_handling'

From: Jan Tluka <jtluka@redhat.com>

This patchset fixes a bug in background process handling that results in
issue https://github.com/jpirko/lnst/issues/67