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

question: what is the plugin avoiding by only creating and registering the plugin class on the master node with xdist on? #22

Open
pharmon-duo opened this issue Apr 22, 2021 · 1 comment
Labels
question Further information is requested

Comments

@pharmon-duo
Copy link

hey fruch!

i've been evaluating this plugin with a pet project. it works great when i'm not using xdist. but when i run my tests with -n=2, i get this error:

_ ERROR at setup of TestPhones.test_changing_phone_type_hides_then_shows_number_input_field _
[gw1] linux -- Python 3.8.5 /opt/venv/bin/python3.8
request = <SubRequest 'git_data' for <Function test_verify_report_export_does_not_exist>>
    @pytest.fixture(scope="session", autouse=True)
    def git_data(request):
        """
        Append git information into results session
        """
        git_info = dict()
        cmds = (
            ("git_commit_oneline", "git log --oneline  -1 --no-decorate"),
            ("git_commit_sha", "git rev-parse HEAD"),
            ("git_commit_sha_short", "git rev-parse --short HEAD"),
            ("git_branch", "git rev-parse --abbrev-ref HEAD"),
            ("git_repo", "git config --get remote.origin.url"),
        )
        for key, command in cmds:
            try:
                git_info[key] = (
                    subprocess.check_output(command, shell=True, stderr=subprocess.DEVNULL)
                    .decode("utf-8")
                    .strip()
                )
            except subprocess.CalledProcessError:
                pass
        elk = request.config.pluginmanager.get_plugin("elk-reporter-runtime")
>       elk.session_data.update(**git_info)
E       AttributeError: 'NoneType' object has no attribute 'session_data'
../venv/lib/python3.8/site-packages/pytest_elk_reporter.py:470: AttributeError

what i think is happening is this test is running on a worker node which means that in pytest-elk-reporter's pytest_configure hook, the ElkReporter plugin is not being created or registered with the pluginmanager.

if i remove this line:

if not hasattr(config, "slaveinput"):

so that the ElkReporter plugin is created and registered regardless of node, the error goes away. looking at the data from error-free runs i don't see anything that would suggest the data quality suffered.

this leaves me wondering: what behavior is pytest-elk-reporter trying to avoid by only creating and registering the plugin if the test is isn't running on a worker node?

@pharmon-duo pharmon-duo changed the title what is undesirable about initializing and registering the ElkReporter on a worker node? question: what is the plugin avoiding by only creating and registering the plugin class on the master node with xdist on? Apr 22, 2021
@fruch
Copy link
Owner

fruch commented Jun 23, 2021

Can you reproduce this issue in a unit test ?

The reason we don want to run on slaves is to avoid multiple reports bring sent out, we care only on reports being sent on master

@fruch fruch added the question Further information is requested label Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants