Exit status for runtask should be 1 if task outcome is FAILED?

Kamil Paral kparal at redhat.com
Wed Mar 25 12:51:29 UTC 2015


> That's exactly why I thought about runtask. To be more precise, we're
> currently working on rpmgrill. It ships it's own fetch-build script
> which is currently tied to Fedoras Koji.

Just a note, IIRC you don't need just all the rpms, but also the build log for certain subtests. That's currently not provided by our koji directive, and I'm not sure if we'll want to add it or not. In such cases, you might need to implement some bits on your own (e.g. fetching the build log).

> 
> IMHO rpmgrill shouldn't be concerned about where the builds come from.
> If I can use 'runtask' to fetch the builds, let rpmgrill handle the
> analysis and report back to bodhi or any other similar system that would
> be very beneficial. Furthermore that can run easily in a Jenkins and the
> exit status would provide a way for the CI to figure if the package is
> not shipping with nasty problems.

I see, so you want to use the exit status as a super-simple way to distinguishing pass/fail in Jenkins, instead of providing some more advanced structure that the CI understands (junit, etc). I think that's a valid request.

> > 1. We have other outcomes defined at the moment, like NEEDS_INSPECTION:
> > https://docs.qadevel.cloud.fedoraproject.org/libtaskotron/latest/library.html#libtaskotron.check.CheckDetail
> > What should happen in that case?
> Theoretically it'll be an exit code 1 as well. What I don't know
> tho is, if it's practical to change it to 1. Perhaps it would mean that
> currently all packages which are under test would basically 'fail'. You
> might have a better insight here what the consequences of that change
> would be.

I think NEEDS_INSPECTION would also be considered as failed, and the exit code would be a predefined value (e.g. 100), so that we can still distinguish execution errors from a task failure.

> 
> 
> > 2. Some tasks do not check just a single item. For example, depcheck and
> > upgradepath check everything that is currently proposed for stable or
> > testing updates. They can return a dozen test results. What should happen
> > when there are mixed results?
> I'd assume to default to the worst result. So if any one of them has a
> a FAILED state it means exit with 1. What I'm not sure about is if it's
> currently easy to accumulate the worst result case with the current
> code. Might be easier thought than done.

We had a long discussion with Josef about this, and our conclusion is that it should be the script author who is in business of deciding what the overall result is. The easiest way to implement this seems to be to let the author define one additional result in TAP (the very last result in TAP), according to any logic he or she needs, and we will consider this last result to be the decision of what exit code to return.

So, if you have just a single result in TAP, it's the one that is used for exit code decision. If you have multiple of them, the last one is used.

This means you will *have to* return at least a basic TAP from rpmgrill (there's a perl library for that), or from the wrapper around rpmgrill (e.g. converting its json to TAP). But TAP itself is extremely simple, so it shouldn't be a problem doing it even manually, i.e. in tests written in bash (we don't support this yet, but plan it in the future). This is the simplest TAP we can consume (I just discovered a bug here, but I'll fix it):

TAP version 13
1..1
not ok

And this is the simplest version that makes sense if you want to report to resultsdb:

TAP version 13
1..1
not ok
  ---
  item: htop-1.0.3-4.fc21
  outcome: FAILED
  type: koji_build
  ...


> 
> 
> > 3. At the moment, it's technically possible to leave out the 'resultsdb'
> > directive the from task recipe. I cannot imagine a use case for this,
> > because in development mode, this only reports to stdout, but it's
> > possible if you need it. If we wanted to inspect task outcomes, we need to
> > do it from TAP, therefore in the 'resultsdb' directive. It might be
> > confusing to people that if you commented out that directive, runtask
> > would stop returning "correct" return codes.
> IMHO that's the beauty of Taskotron being decoupled from the execution
> and the result reporting. My main idea was just using libtaskotron for
> task execution and perhaps in the future to report to other aggregation
> systems inside Red Hat (the equivalent to Bodhi).
> 
> So I thought from a developer point of view, it allows to run build
> analysers against your package in your CI using Taskotron without the
> need to report the results back into a results database.
> 
> I hope I'm not twisting the intention of the whole Taskotron idea.

I was always thinking either about running tests in in the full taskotron environment (with resultsdb etc), or locally without any special needs (mainly for test development). But if you want to use libtaskotron as a runner in a different CI environment and we can satisfy your needs, I think that's great. And it will make sharing tests between Taskotron and internal Red Hat CI systems easier. No objections there.

> 
> > One further thought, instead of implementing this by default, we can
> > also create a new directive or variable which will allow task creators
> > to set the exit code, according to TAP or any other logic they want.
> That sounds like a good idea as well. Based on that, what we could also
> do is, add an argument to runtask like:
> 
>     --make-fatal
> 
> which means if the result of the runtask is not PASSED or INFO it'll
> exit with 1. Less flexible than your idea, but perhaps less work
> involved.

I like it. By using this cmdline option, you would trigger the behavior I described earlier (using the last TAP result as an exit code for the runner).


So, in summary, for your rpmgrill in Jenkins use case, you would run it with --make-fatal and you would make sure that the last result in TAP (or the only result in TAP, if you have just one) reflects the exit code you want runtask to return (FAILED and NEEDS_INSPECTION means non-zero). Does that sound reasonable (to everyone)?



More information about the qa-devel mailing list