0

I am doing multi-host testing in Beaker, where one recipe is waiting for a command in another recipe to complete. I want to vary the behaviour based on whether the command in the other recipe succeeded or failed.

Is there any way I can communicate the exit status of a command from one recipe to another?

(Based on a mailing list discussion from March 2014.)

DanC
  • 1,844
  • 13
  • 12

1 Answers1

1

Beaker doesn't provide any mechanism for passing arbitrary data between recipes in a recipe set. There is only rhts-sync-set/rhts-sync-block for synchronization.

However you can still (ab)use those to achieve what you want. The trick is to use two separate sync states. Let's call them CMD_SUCCEEDED and CMD_FAILED (use more specific names if you want).

The first recipe sets CMD_SUCCEEDED if the command succeeded or CMD_FAILED if the command failed.

do_something_important
if [ $? -eq 0 ] ; then
    rhts-sync-set -s CMD_SUCCEEDED
else
    rhts-sync-set -s CMD_FAILED
fi

Then your other recipe can wait on either state (by passing two -s options) and then test which one was reached (by passing --timeout 0):

rhts-sync-block -s CMD_SUCCEEDED -s CMD_FAILED $CLIENTS
if rhts-sync-block -s CMD_SUCCEEDED --timeout 0 $CLIENTS ; then
    # command succeeded
else
    # command failed
fi

(This idea was originally suggested by Nick Coghlan.)

DanC
  • 1,844
  • 13
  • 12