Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering Specific Variants with --mux-filter-only Includes Unrelated Variants #6084

Open
Moghees244 opened this issue Dec 24, 2024 · 6 comments
Assignees
Labels

Comments

@Moghees244
Copy link

Bug Description
Filtering specific variants using --mux-filter-only does not work as expected. When attempting to filter for a single variant (e.g., /run/qemu-guests/kali), additional unrelated variants are also included in the output.


Steps to reproduce

  1. Create a test_params.yaml file with the following structure:
    !mux
    qemu:
        remote_host: "127.0.0.1"
        remote_ssh_port: "2222"
        user: "root"
    
    qemu-guests: !mux
        kali:
            remote_host: "127.0.0.1"
            remote_ssh_port: "2223"
            user: "root"
            domain_name: "kali"
    
        ewaol:
            remote_host: "127.0.0.1"
            remote_ssh_port: "2224"
            user: "root"
            domain_name: "ewaol"
  2. Run the following commands to generate and filter variants:
    • avocado variants --mux-yaml test_params.yaml --mux-filter-only /run/qemu-guests
    • avocado variants --mux-yaml test_params.yaml --mux-filter-only /run/qemu-guests/kali

Expected behavior
The command avocado variants --mux-yaml test_params.yaml --mux-filter-only /run/qemu-guests/kali should return only the kali variant and exclude other unrelated variants like ewaol.


Current behavior
The command returns multiple variants instead of only the specified one. Example output:

Multiplex variants (2):
Variant run-qemu-3ec6:    /run/qemu
Variant run-qemu-guests-kali-68b9:    /run/qemu-guests/kali

System information

  • OS: Output of lsb_release -a:
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 22.04.4 LTS
    Release:        22.04
    Codename:       jammy
    
  • Avocado version: Output of avocado -v:
    Avocado 108.0  
    
  • Avocado installation method:
    git clone https://github.com/avocado-framework/avocado
    pip install avocado-framework
    

@Moghees244 Moghees244 added the bug label Dec 24, 2024
@mr-avocado mr-avocado bot moved this to Triage in Default project Dec 24, 2024
@richtja
Copy link
Contributor

richtja commented Jan 2, 2025

Hi @Moghees244 in your example the Variant run-qemu-3ec6: /run/qemu variant is used, because is not part of the multiplexation. If you want to get only Variant run-qemu-guests-kali-68b9: /run/qemu-guests/kali you need to update your example like this:

-!mux
-qemu:
+qemu: !mux
     remote_host: "127.0.0.1"
     remote_ssh_port: "2222"
     user: "root"

@Moghees244
Copy link
Author

Hi @richtja . There's still this issue:

qemu: !mux
    remote_host: "127.0.0.1"
    remote_ssh_port: "2222"
    user: "root"

qemu-guests: !mux
    kali:
        remote_host: "127.0.0.1"
        remote_ssh_port: "2223"
        user: "root"
        domain_name: "kali"

    ewaol:
        remote_host: "127.0.0.1"
        remote_ssh_port: "2224"
        user: "root"
        domain_name: "ewaol"
avocado variants --mux-yaml params.yaml --mux-filter-only /run/qemu-guests/kali
Multiplex variants (1):
Variant run-qemu-qemu-guests-kali-9a12:    /run/qemu, /run/qemu-guests/kali


avocado run test.py --mux-yaml params.yaml --mux-filter-only /run/qemu-guests/kali
JOB ID     : 21939080dd834ef05c4445bd832b321ac80a5833
JOB LOG    : /root/avocado/job-results/job-2025-01-03T12.17-2193908/job.log
 (1/2) test.py:TestKVMGuestsAccess.test_guest_ip_addr;run-qemu-qemu-guests-kali-9a12: STARTED
 (2/2) test.py:TestKVMGuestsAccess.test_guest_ssh_connection;run-qemu-qemu-guests-kali-9a12: STARTED
 (1/2) test.py:TestKVMGuestsAccess.test_guest_ip_addr;run-qemu-qemu-guests-kali-9a12: ERROR: Multiple  leaves contain the key 'remote_host'; ['/run/qemu=>127.0.0.1', '/run/qemu-guests/kali=>127.0.0.1'] (0.02 s)
 (2/2) test.py:TestKVMGuestsAccess.test_guest_ssh_connection;run-qemu-qemu-guests-kali-9a12: ERROR: Multiple  leaves contain the key 'remote_host'; ['/run/qemu=>127.0.0.1', '/run/qemu-guests/kali=>127.0.0.1'] (0.02 s)
RESULTS    : PASS 0 | ERROR 2 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /root/avocado/job-results/job-2025-01-03T12.17-2193908/results.html
JOB TIME   : 1.60 s

@richtja richtja moved this from Triage to Short Term (Current Q) Backlog in Default project Jan 8, 2025
@richtja richtja added this to the 110 - Codename TBD milestone Jan 8, 2025
@harvey0100 harvey0100 self-assigned this Jan 10, 2025
@harvey0100
Copy link
Contributor

Hi @Moghees244 can you please send the reproducer of this issue of your test.py, when using examples/tests/params.py it seems to be working correctly.

@Moghees244
Copy link
Author

I will share the file but if you simply check the output of this command:

avocado variants --mux-yaml params.yaml --mux-filter-only /run/qemu-guests/kali

it returns : Variant run-qemu-qemu-guests-kali-9a12: /run/qemu, /run/qemu-guests/kali

/run/qemu must not be in the response

@Moghees244
Copy link
Author

Just pasting it here:

from avocado import Test
from avocado.utils import ssh

class SshDmesgTest(Test):
    """
    Execute ssh connection to the host , execute dmesg command and verify the output contains no errors.
    """
    def setUp(self):
        """
        Setup variables and open SSH session.
        """
        self.remote_host = self.params.get('remote_host', default='127.0.0.1')
        self.user = self.params.get('user', default='root')
        self.remote_ssh_port = self.params.get('remote_ssh_port', default='2222')
        self.password = 'abc123'

        # Open SSH session
        self.session = ssh.Session(self.remote_host, self.remote_ssh_port, user=self.user, password=self.password)

    def testDmesgCommand(self):
        """
        Test the presence of any error message in dmesg output.
        """
        result = self.session.cmd('dmesg')
        # Check if the command was successful
        self.assertEqual(result.exit_status, 0, "Command failed")
        # Parse the output for a specific string
        self.log.info("Command output: %s", result.stdout_text)
        self.assertNotIn(result.stdout_text ,"No error found in dmesg output")

    def tearDown(self):
        """
        Close the SSH session.
        """
        if self.session:
            self.session.quit()

@richtja richtja moved this from Short Term (Current Q) Backlog to In progress in Default project Jan 13, 2025
@clebergnu
Copy link
Contributor

Hi @Moghees244,

I'd say the main point about your issue is an incorrect set of expectations with the YAML you're using and the expectations you have.

First, the hierarchy built out of the YAML structure is one that allows for an organization of parameters in a namespace.

Second, the "filter only" approach is about filtering the resulting variants, not the namespaces, and AFAICT it's working as expected. So your comment saying that "/run/qemu must not be in the response" is not accurate.

Consider the following YAML instead:

qemu:
    remote_host: "127.0.0.1"
    remote_ssh_port: "2222"
    user: "root"

    guests: !mux
        kali:
            domain_name: "kali"
            remote_ssh_port: "2223"

        ewaol:
            domain_name: "ewaol"
            remote_ssh_port: "2224"

When getting parameters from a test, you could using different namespaces if the names of parameters where the same, but different in meaning, say from /run/qemu to /run/qemu/guests/kali. Say:

user = self.params.get('user', path='/run/qemu', default='root')

Again, the path is unnecessary in this example, because user has the same meaning across the hierarchy. Thus, you can get parameters without specifying the paths that should be searched for them.

I'm saying all that because it should be clear that /run/qemu is not about a variant (but about a path), and does not have a connection with the "filter only" feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In progress
Development

No branches or pull requests

4 participants