Ticket #3750 (closed enhancement: fixed)

Opened 3 months ago

Last modified 2 months ago

Add support for RPM transaction scripts

Reported by: jtyr Owned by: mooffie
Priority: major Milestone: 4.8.19
Component: mc-vfs Version: master
Keywords: Cc:
Blocked By: #3751 Blocking:
Branch state: merged Votes for changeset: committed-master

Description

The RPM vfs is missing support transaction scripts.

Attachments

0001-Adding-support-for-RPM-transaction-scripts.patch (4.3 KB) - added by jtyr 3 months ago.
0001-Adding-support-for-RPM-transaction-scripts.patch
0002-Removing-PROG-files-and-improving-code-structure.patch (25.5 KB) - added by jtyr 3 months ago.
0002-Removing-PROG-files-and-improving-code-structure.patch

Change History

Changed 3 months ago by jtyr

0001-Adding-support-for-RPM-transaction-scripts.patch

comment:1 follow-up: ↓ 2 Changed 3 months ago by zaytsev

I would love to see this tested, but I'm not sure of how to hook the tester in. The way list function is constructed in this extfs helper is a bit peculiar :-/

(See README in tests/src/vfs/extfs/helpers-list.)

I'm leaning towards committing as is :-(

comment:2 in reply to: ↑ 1 Changed 3 months ago by mooffie

Replying to zaytsev:

I would love to see this tested, but I'm not sure of how to hook the tester in. The way list function is constructed in this extfs helper is a bit peculiar :-/


I gave that helper only a relatively-quick view but I suspect I know what you mean:

  1. The helper needs (I think) more than the one command (MC_TEST_EXTFS_LIST_CMD) the tester gives it. Fortunately, additional commands can be easily synthesized. I wrote a draft explaining it here.
  1. Another potential problem is calling the external program this way (just an example):

$RPM --list-contents a b c
$RPM --get-tags a b c

This should be changed to:

$RPM_LIST a b c
$RPM_GET_TAGS a b c

(This way we can override $RPM_LIST and $RPM_GET_TAGS separately.)

comment:3 follow-up: ↓ 4 Changed 3 months ago by jtyr

I will have a look into how to improve this.

comment:4 in reply to: ↑ 3 Changed 3 months ago by mooffie

Replying to jtyr:

I will have a look into how to improve this.


Just a sec! I didn't mean to say that a test should be written as precondition for committing your patch (I was about to clarify this, but you were quicker than me).

I think that if your patch looks safe enough then the maintainers should go ahead and commit it.

Of course, if you want to help us by trying to write a test then this would be greatly appreciated.

comment:5 Changed 3 months ago by zaytsev

@mooffie, you are right, but what I deem to be even more annoying is that rpm is triggered many times via mcrpmfs_printOneMetaInfo with different parameters and returns varying output according to the arguments.

It's not like you run the archiver once and parse its output, or something, such that the output can be simply replaced with cat'ing from the mock data file. Currently, I don't see a better solution other than mocking rpm -qp --qf from mcrpmfs_getRawOneTag with a hashtable, which is doable, but very irritating (and on top of that one would need to mock mcrpmfs_getAllNeededTags as well).

comment:6 Changed 3 months ago by zaytsev

I don't know if I'm being too softball to accept patches without tests, even for code that never had tests in the first place. Many projects I'm working with just flat out refuse to look into stuff if it isn't accompanied with tests, and I totally sympathize with that. However, it's difficult to be a hardliner in a situation where maintainers are severely underpowered and the coverage in general is a disaster... :-/

comment:7 Changed 3 months ago by jtyr

Another thing is that the current version of the tester doesn't allow to test the content of the files created in the vfs. That's quite important for the RPM helper.

Last edited 3 months ago by jtyr (previous) (diff)

comment:8 Changed 3 months ago by zaytsev

Another thing is that the current version of the tester doesn't allow to test the content of the files created in the vfs. That's quite important for the RPM helper.

You are right about that, but already being able to test the list function is God send. Most extfs helpers work by parsing the output from external tools to generate listings, like various archivers, and it's breaking all the time due to changes in the archivers, mc, non-robust parser code, bug fixes that introduce new bugs, etc.

Changed 3 months ago by jtyr

0002-Removing-PROG-files-and-improving-code-structure.patch

comment:9 Changed 3 months ago by mooffie

I'm studying the rpm helper now. I think I'm about to change my mind: testing it may not be hard. Stay tuned.

@jtyr: You're mixing formatting with code-modifications in your patch. That's a big no-no. We won't be able to see what you've changed. Besides, you'd better hold off your work a bit till I study the testability issue.

comment:10 Changed 3 months ago by mooffie

  • Blocked By 3751 added

(Of course, if #3751 is rejected this one gets unblocked.)

comment:11 Changed 2 months ago by mooffie

Ok, we're ready to roll.

comment:12 Changed 2 months ago by mooffie

  • Status changed from new to accepted
  • Owner set to mooffie
  • Branch state changed from no branch to on review
  • Milestone changed from Future Releases to 4.8.19

I've created a branch for @jtyr's 1st patch:

branch: 3750_extfs_rpm_trans_scripts
Initial changeset:4310b066e23b1e88256ab9beaeb06711a144147b

It contains two commits: one to implement the feature, one to "fix" the now outdated test.

(@Yury: Is it ok to separate the two? This won't cause trouble to git bisect when both the break and the fix are inside a merged branch, right?)

comment:13 Changed 2 months ago by mooffie

  • Votes for changeset set to mooffie

Andrew / Yury:

@jtyr's 2nd patch implements another feature (see next comment) but it's far from ready, so I suggest we deal with it separately (maybe in another ticket; we don't even know @jtyr will return to address the issues).

So, vote for the branch as-is. I'm adding my vote.

comment:14 Changed 2 months ago by mooffie

@jtyr:

As for your 2nd patch:

It's a mixed bag. It's not easy to review it because the actual changes are buried among "formatting". So we can't accept this patch as-is.

The patch gets rid of INFO/SCRIPT/$(tag)PROG in favor of shebang lines in the corresponding INFO/SCRIPT/$(tag) files. This in itself sounds fine (I'm not an rpm user, though). A shebang line has limitations (max two tokens), but perhaps you intend these lines to be informative only. If you're still interested in this, please create a patch dealing with this alone. Maybe we'd better do this in a separate ticket.

BTW, instead of doing code formatting you can improve the code. I.e., instead of:

INFO/SCRIPTS/PREIN) 
    echo -n "#!" >"$2" 
    mcrpmfs_getRawOneTag "%{RPMTAG_PREINPROG}\n" >>"$2" 
    mcrpmfs_getRawOneTag "%{RPMTAG_PREIN}\n" >>"$2" 
    exit 0 
    ;; 
INFO/SCRIPTS/POSTIN) 
    echo -n "#!" >"$2" 
    mcrpmfs_getRawOneTag "%{RPMTAG_POSTINPROG}\n" >>"$2" 
    mcrpmfs_getRawOneTag "%{RPMTAG_POSTIN}\n" >>"$2" 
    exit 0 
    ;; 
... repeating ...

maybe do something along of:

INFO/SCRIPTS/{PREIN,POSTIN,...}) 
    write_script_file "$1" "$2"

comment:15 follow-up: ↓ 19 Changed 2 months ago by jtyr

I'm fine if you merge only the first patch for now and I will bring the additional changes in a separate ticket later on.

comment:16 follow-up: ↓ 22 Changed 2 months ago by zaytsev

(@Yury: Is it ok to separate the two? This won't cause trouble to git bisect when both the break and the fix are inside a merged branch, right?)

That's a very controversial topic; tldr: in my personal opinion it's still worth separating the fix & the test, even if it makes bisecting a bit more difficult.

The reason for it is that I like it when while fixing a regression one commits the test first to show the reviewer / let the CI check that the test actually fails with the regression present! How many tests I have seen that claimed to test for a regression, but actually didn't :-/ because they were just wishful thinking added past fixing the regression... or else when implementing a new feature, it's nice when the tests are adjusted separately from the code implementing the changes. Whether they should come first or last is a philosophical question; as I favor TDD when appropriate, I tend to commit the tests first, but I don't get upset when one checks in some new stuff, and then adjusts the tests, in the end it amounts to the same. It's only regression tests that I'd really like to see first.

Now, as you said, this doesn't make git bisect all too happy if as your criterion you just let all of the tests run, instead of picking a particular one, because bisection is not branch-aware.

However, if one does have a relatively clean history (as we are trying to keep), one can always bisect at merge commit level and then when a particular feature branch has been identified, go one level deeper with a trick like:

# bisect feature branches
git bisect start master good

for rev in $(git rev-list good..master --merges --first-parent); do
    git rev-list $rev^2 --not $rev^
done | xargs git bisect skip

git bisect run

# go deeper
...

I also remember some talk about adding --first-parent to git bisect, but I don't think it actually materialized in the end. And, of course, none of that matters if your test is specific enough...

comment:17 Changed 2 months ago by zaytsev

It's a mixed bag. It's not easy to review it because the actual changes are buried among "formatting". So we can't accept this patch as-is.

Just a tip that I often use to clean up whitespace soup contributions: apply the patch and then regenerate it by running

git diff -b [ or even -w ] --ignore-blank-lines

Now, you can reapply whitespace fixes separately if/when needed. Have to be careful though... but better than nothing.

comment:18 Changed 2 months ago by zaytsev

  • Votes for changeset changed from mooffie to mooffie zaytsev
  • Branch state changed from on review to approved

comment:19 in reply to: ↑ 15 Changed 2 months ago by mooffie

Replying to jtyr:

I'm fine if you merge only the first patch for now and I will bring the additional changes in a separate ticket later on.


Great! I'll be closing this ticket then.

Replying to zaytsev:

[...] as I favor TDD when appropriate, I tend to commit the tests first, but I don't get upset when [...] It's only regression tests that I'd really like to see first. [...] one can always bisect at merge commit level [...]


Interesting! Thank you for all this info.

comment:20 Changed 2 months ago by mooffie

  • Status changed from accepted to testing
  • Votes for changeset changed from mooffie zaytsev to committed-master
  • Resolution set to fixed
  • Branch state changed from approved to merged

comment:21 Changed 2 months ago by mooffie

  • Status changed from testing to closed

comment:22 in reply to: ↑ 16 Changed 2 months ago by ossi

Replying to zaytsev:

(@Yury: Is it ok to separate the two? This won't cause trouble to git bisect when both the break and the fix are inside a merged branch, right?)

That's a very controversial topic; tldr: in my personal opinion it's still worth separating the fix & the test, even if it makes bisecting a bit more difficult.

this is a false dichotomy. the canonical way is adding the test first, but marking it as an expected failure (XFAIL).

comment:23 follow-up: ↓ 25 Changed 2 months ago by zaytsev

... only, unfortunately, many harnesses, including the custom one in question here, do not support marking tests as expected failures.

comment:24 Changed 2 months ago by ossi

i suspected that this might be the case. it would still be the right thing to do, and should be acknowledged as the first option. one can still debate the pros and cons of suboptimal approaches after establishing that the preferable one is not feasible.

Last edited 2 months ago by ossi (previous) (diff)

comment:25 in reply to: ↑ 23 Changed 2 months ago by mooffie

Replying to ossi:

the canonical way is adding the test first, but marking it as an expected failure (XFAIL).


Good idea! I'll bear that in mind.

Replying to zaytsev:

... unfortunately [the tester does] not support marking tests as expected failures.


I've learned quite a bit since then (and still do). This will be addressed sometime soon I hope. (I'm currently preoccupied with some other corner of MC, which is why you don't hear from me.)

Note: See TracTickets for help on using tickets.