teemtee/fmf

implement programatic expansion of metadata - macros

Opened this issue · 2 comments

sopos commented

Example:
imagine this metadata:

/old-syntax:
        environment+:
            rsyslogSyntax: old
        /x509_name:
            extra-summary: CONDITIONAL_PHASES_BL=ossl rsyslogSyntax=old /rsyslog/Sanity/gnutls-openssl
/new-syntax:
        environment+:
            rsyslogSyntax: new
        /x509_name:
            extra-summary: CONDITIONAL_PHASES_BL=ossl rsyslogSyntax=new /rsyslog/Sanity/gnutls-openssl

to simplify it one could use something like:

%for syntax in [old, new]:
/%syntax%-syntax:
        environment+:
            rsyslogSyntax: %syntax%
        /x509_name:
            extra-summary: CONDITIONAL_PHASES_BL=ossl rsyslogSyntax=%syntax% /rsyslog/Sanity/gnutls-openssl
%rof

For more metadata worth simplification see https://github.com/RedHat-SP-Security/tests/blob/69e188bad1da05dbdbf21d102bcec25655ec9a3b/rsyslog/Sanity/gnutls-openssl/main.fmf#L57
The life metadata cannot be used directly due to nitrate TC mapping but it could be easily without it.

The fmf files would be pre-processed using a metalanguage and then processed as usual.

Hi @sopos ,
theoretically you are trying to implement something like multiplexing what is implemented in avocado project https://avocado-framework.readthedocs.io/en/latest/plugins/optional/multiplexer.html , so that generating matrix of combinations

But in generic it could be also implemented by my extension via python pytest, you can in python write test generator for pytest, so that you can do whatever you want and generate matrix as you wish with full python selmantics, so that powerfull instead of trying to add own semantic

Then fmf will collect data based on your generation. simply e.g. via @pytest.mark.parametrize(....)
#136

So that your macro extension is something between this avocado multiplexer and dynamic python tests from my PoV.

sopos commented

another real use case (from rhel6 :) :
There is a dual component rsyslog and rsyslog7. The test normally require rsyslog* packages. However if the rsyslog7 is going to be tested all such requires should be basicaly replaces with rsyslog7*.
Currently, this can be achieved by implementing to all the tests following adjust:

adjust:
  - require-:
      - rsyslog
    require+:
      - rsyslog7
    when: component = rsyslog7

plus for all the required sub-packages.

An elegant solution might be to use the macro language:

set rsyslog=rsyslog7
require:
  - ${rsyslog}
  - ${rsyslog}-gnutls

So the only require thing would be to replace all the requirement rsyslog with ${rsyslog}.

Another solution might be to use templates.