This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 1292957 - beakerlib task status is None or NEW if metadata file exists
beakerlib task status is None or NEW if metadata file exists
Status: CLOSED CURRENTRELEASE
Product: Restraint
Classification: Community
Component: general (Show other bugs)
0.1.21
All Linux
medium Severity medium
: 0.1.23
: ---
Assigned To: Bill Peck
tools-bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-12-18 15:24 EST by Jeff Bastian
Modified: 2016-04-20 20:24 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-02-18 15:03:48 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jeff Bastian 2015-12-18 15:24:52 EST
Description of problem:
If the restraint metadata file exists for a task which uses pure beakerlib, then the task will be left in the result=None state when running under restraint-client (or NEW if running with restraint in Beaker).

This git repo can be used to demo the bug:
  git://fedorapeople.org/~jbastian/beaker-tasks.git
  https://fedorapeople.org/cgit/jbastian/public_git/beaker-tasks.git/

The tasks are really simple.  For /general/misc/pass:
    rlJournalStart
        rlPhaseStartTest
            rlPass "passing comment"
        rlPhaseEnd
    rlJournalEnd

Change rlPass to rlFail for /general/misc/fail


The 1.0 tags (general-misc-pass-v1.1 and general-misc-fail-v1.0) and do not have a metadata file, so the tasks finish with a result={PASS|FAIL} state.  The 1.1 tags have the metadata file added, so the tasks are left in result=None (or NEW if running in Beaker).

~]# cat passfail.xml
<job>
  <recipeSet>
    <recipe>
      <task name="/general/misc/pass" role="STANDALONE">
        <fetch url="git://fedorapeople.org/~jbastian/beaker-tasks.git?general-misc-pass-v1.0#general/misc/pass"/>
      </task>
      <task name="/general/misc/pass" role="STANDALONE">
        <fetch url="git://fedorapeople.org/~jbastian/beaker-tasks.git?general-misc-pass-v1.1#general/misc/pass"/>
      </task>
      <task name="/general/misc/fail" role="STANDALONE">
        <fetch url="git://fedorapeople.org/~jbastian/beaker-tasks.git?general-misc-fail-v1.0#general/misc/fail"/>
      </task>
      <task name="/general/misc/fail" role="STANDALONE">
        <fetch url="git://fedorapeople.org/~jbastian/beaker-tasks.git?general-misc-fail-v1.1#general/misc/fail"/>
      </task>
    </recipe>
  </recipeSet>
</job>

~]# restraint --host=1=localhost:8081 --job=passfail.xml
Using ./passfail.01 for job run
Connecting to http://localhost:8081/run for recipe id:1
*  T:   1 [/general/misc/pass                              ] Running
*  T:   1 [/general/misc/pass                              ] Completed: PASS
*  T:   2 [/general/misc/pass                              ] Running
*  T:   2 [/general/misc/pass                              ] Completed
*  T:   3 [/general/misc/fail                              ] Running
*  T:   3 [/general/misc/fail                              ] Completed: FAIL
*  T:   4 [/general/misc/fail                              ] Running
*  T:   4 [/general/misc/fail                              ] Completed
One or more tasks failed [restraint-error-quark, 10]

~]# grep -o 'task.*result=\".*\"' passfail.01/job.xml |
        awk '{print $2,$4,$5,$6}'
name="/general/misc/pass" id="1" status="Completed" result="PASS"
name="/general/misc/pass" id="2" status="Completed" result="None"
name="/general/misc/fail" id="3" status="Completed" result="FAIL"
name="/general/misc/fail" id="4" status="Completed" result="None"


Version-Release number of selected component (if applicable):
restraint-0.1.21-3.el7

How reproducible:
always

Steps to Reproduce:
1. create the above passfail.xml file
2. restraint --host=1=localhost --job=passfail.xml
3. Note: to run it again:
     rm -fr /mnt/tests/fedorapeople.org/~jbastian/beaker-tasks.git
     see bug 1252679

Actual results:
tasks 2 and 4 have result="None"

Expected results:
tasks 2 and 4 have result="PASS" and result="FAIL" respectively

Additional info:
Comment 1 Jeff Bastian 2015-12-18 15:28:53 EST
One band-aid fix is to add a call to rstrnt-report-result explicitly at the end of runtest.sh, e.g.:

    # if running under the restraint harness, report results 
    [ -n "$RSTRNT_TASKID" ] && rstrnt-report-result $TEST PASS 0

However, this should not be necessary since the plugin /usr/share/restraint/plugins/task_run.d/15_beakerlib should be doing this.
Comment 2 Jeff Bastian 2015-12-18 15:33:02 EST
The rlReport command in Beakerlib runs $BEAKERLIB_COMMAND_REPORT_RESULT which is set to rstrnt-report-result by the 15_beakerlib plugin as mentioned in comment 1.  However, I see from /usr/share/beakerlib/testing.sh that it only runs the command if the $TESTID variable is set:

    # report the result only if TESTID is set
    if [ -n "$TESTID" ] ; then
        $BEAKERLIB_COMMAND_REPORT_RESULT "$testname" "$result" "$logfile" "$score" \
            || rlLogError "rlReport: Failed to report the result"
    fi

So... I wonder if restraint is not setting or exporting $TESTID if the metadata file exists?
Comment 3 Jeff Bastian 2015-12-18 15:42:02 EST
I think I see the problem: if the metadata file exists, then restraint turns off rhts_compat mode.  From src/task.c [0]:

      metadata_file = g_build_filename (task->path, "metadata", NULL);
      testinfo_file = g_build_filename (task->path, "testinfo.desc", NULL);
      if (file_exists (metadata_file)) {
          task->rhts_compat = FALSE;

A bit later, when it sets up the environment variables to run a task, it checks if it's running in rhts_compat mode or not, and if so, it exports a few extra variables, including $TESTID.  From srv/env.c [1]:

    if (task->rhts_compat == TRUE) {
        ...
        array_add (env, NULL, "TESTID", task->task_id);
        ...
    }
    ...
    array_add (env, prefix, "TASKID", task->task_id);

Thus, TESTID is only set in compat mode.


[0] https://git.beaker-project.org/cgit/restraint/tree/src/task.c?h=restraint-0.1.21-4#n647
[1] https://git.beaker-project.org/cgit/restraint/tree/src/env.c?h=restraint-0.1.21-4#n80
Comment 4 Jeff Bastian 2015-12-18 17:33:49 EST
This patch *should* fix it:
  http://gerrit.beaker-project.org/4547 

However, I'm unable to build restraint-0.1.22 right now to test it.  It keeps failing when building the 3rd party libraries:

...
gcc  -o restraintd server.o recipe.o task.o fetch.o fetch_git.o fetch_http.o param.o role.o metadata.o process.o message.o dependency.o utils.o config.o errors.o xml.o env.o -Wl,-Bstatic -Wl,-\( -L/home/rpmbuild/rpmbuild/BUILD/restraint-0.1.22/third-party/tree/lib -lxml2 -lsoup-2.4 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -larchive -lssh -lssh_threads   -lgmodule-2.0 -llzma -lbz2 -lz -lffi -lssl -lcrypto -lselinux -Wl,-\) -Wl,-Bdynamic -lm -pthread -lrt -lresolv -ldl -lutil 
/home/rpmbuild/rpmbuild/BUILD/restraint-0.1.22/third-party/tree/lib/libarchive.a(archive_read_support_filter_lzop.o): In function `lzop_filter_read':
/home/rpmbuild/rpmbuild/BUILD/restraint-0.1.22/third-party/libarchive-3.1.2/libarchive/archive_read_support_filter_lzop.c:434: undefined reference to `lzo1x_decompress_safe'
collect2: error: ld returned 1 exit status
make: *** [restraintd] Error 1
error: Bad exit status from /var/tmp/rpm-tmp.I4l4r5 (%build)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.I4l4r5 (%build)

Note You need to log in before you can comment on or make changes to this bug.