Bug 910757

Summary: New function rlAssertBinaryOrigin
Product: [Fedora] Fedora Reporter: Petr Šplíchal <psplicha>
Component: beakerlibAssignee: Martin Kyral <mkyral>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: high    
Version: rawhideCC: ohudlick, pmuller, psplicha
Target Milestone: ---Keywords: FutureFeature, Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: beakerlib-1.7-1.fc19 Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-05-22 03:20:17 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
proposed patch
none
tests for the new functionality
none
proposed patch
none
tests for the new functionality
none
proposed patch
none
proposed patch
none
proposed patch none

Description Petr Šplíchal 2013-02-13 13:47:11 UTC
Description of problem:

Let's implement a new function rlAssertBinaryOrigin() which would
be used for checking that given binary is provided by one of given
packages. The function should support the following syntax:

    rlAssertBinaryOrigin binary [package [package...]]

If no package would be provided on the command line environment
variable PACKAGES would be used to get the list of rpms which
should own the binary file. The implementation itself should be
roughly as this:

    rlRun "rpm -q $PACKAGES | grep $(rpm -qf $(which $PYTHON))"

This new functionality will be useful when testing binaries
packaged in Software Collections [1] to make sure the binary under
test is what is actually expected to be tested.

[1] http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/Software_Collections_Guide/index.html

Comment 1 Petr Šplíchal 2013-02-13 14:20:58 UTC
Please, make sure this works with alternatives as well.

Comment 2 Martin Kyral 2013-02-15 15:49:58 UTC
Created attachment 697868 [details]
proposed patch

the patch solves also BZ#772622

Comment 3 Martin Kyral 2013-02-19 09:32:06 UTC
Created attachment 699387 [details]
tests for the new functionality

Comment 4 Martin Kyral 2013-02-19 15:28:41 UTC
Created attachment 699498 [details]
proposed patch

Comment 5 Martin Kyral 2013-02-19 15:29:08 UTC
Created attachment 699499 [details]
tests for the new functionality

Comment 6 Martin Kyral 2013-02-19 15:30:22 UTC
Fixed rlAssertBinaryOrigin so it returns the actual status code

Comment 7 Martin Kyral 2013-02-21 14:07:13 UTC
Created attachment 700562 [details]
proposed patch

Merged the src and test patches, only binary is mandatory argument for rlAssertBinaryOrigin

Comment 8 Lukáš Zachar 2013-02-22 10:44:35 UTC
Tested patch from the comment #7 applied on beakerlib-1.6-1.el6eso.noarch:
Works both for "normal" and alternatives handled binaries.
If not package name is supplied, the content of the PACKAGES environment variable is used.

The documentation needs a little fix, Martin has been already notified.

Comment 9 Martin Kyral 2013-02-26 11:00:02 UTC
Created attachment 702794 [details]
proposed patch

Documentation fixes

Comment 10 Lukáš Zachar 2013-02-26 13:28:39 UTC
Both the functionality and the documentation is good from my POV.

Comment 11 Petr Šplíchal 2013-03-01 08:31:28 UTC
This has not been yet committed to the git repo, moving to ASSIGNED.
https://fedorahosted.org/beakerlib/wiki/CodingStyle#BugzillaStates
Petr, could you have a look at this? It's blocking parametrization.

Comment 12 Petr Šplíchal 2013-03-01 09:12:00 UTC
I've looked briefly through the sources, it looks generally fine.
I'm just not sure about the following line:

    BINARY=$(ls -l $(which $CMD) | awk '{ print $NF }')

What about using readlink here instead? Last thing: It's probably
better to use rlLogInfo/rlLogError when reporting additional
information rather than simply: echo "$CMD: command not found".

Comment 13 Lukáš Zachar 2013-03-01 09:17:33 UTC
(In reply to comment #10)
> Both the functionality and the documentation is good from my POV.

Taking back the 'functionality' part. It *doesn't* work when there are more levels of symlimks.
E.g. /usr/bin/XXX -> /etc/alternatives/XXX-provider -> /etc/alternatives/XXX-provider-internal -> /usr/share/provider/bin/XXX

In that scenario the proposed patch doesn't find the final destination and tries to assert a symlink - which fails. 

Is there any reason why readlink command cannot be used? It would work correctly that way.

Comment 14 Martin Kyral 2013-03-04 13:42:36 UTC
Created attachment 704988 [details]
proposed patch

* using readlink
* minor fixes

Comment 15 Petr Šplíchal 2013-03-04 18:01:39 UTC
Thanks for the patch, Martin. Pushed to git:
http://git.fedorahosted.org/cgit/beakerlib.git/commit/?id=f4163cb

Comment 16 Fedora Update System 2013-04-30 15:11:30 UTC
beakerlib-1.7-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/beakerlib-1.7-1.fc19

Comment 17 Fedora Update System 2013-04-30 20:05:07 UTC
Package beakerlib-1.7-1.fc19:
* should fix your issue,
* was pushed to the Fedora 19 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing beakerlib-1.7-1.fc19'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-7067/beakerlib-1.7-1.fc19
then log in and leave karma (feedback).

Comment 18 Fedora Update System 2013-05-22 03:20:17 UTC
beakerlib-1.7-1.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.