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

PyPy3 tests break #32

Closed
icemac opened this issue Feb 1, 2024 · 19 comments · Fixed by #33
Closed

PyPy3 tests break #32

icemac opened this issue Feb 1, 2024 · 19 comments · Fixed by #33
Labels

Comments

@icemac
Copy link
Member

icemac commented Feb 1, 2024

PROBLEM REPORT

What I did:

Run the tests for PyPy3 on GHA.

What I expect to happen:

green tests

What actually happened:

one test fails, see https://github.com/zopefoundation/zdaemon/actions/runs/7738159321/job/21098442355

What version of Python and Zope/Addons I am using:

  • PyPy 3.9
  • The difference in the dependencies are:
    • cffi==1.15.1 -> 1.16.0
    • hpy==0.0.4 -> 0.9.0

Any ideas what is happening here?

@icemac icemac added the question label Feb 1, 2024
@icemac icemac changed the title PyPy tests break PyPy3 tests break Feb 1, 2024
@icemac
Copy link
Member Author

icemac commented Mar 11, 2024

@zopefoundation/developers – Sorry for the broad notification: I need help maintaining zdaemon.

Is someone actually using zdaemon on PyPy?
Would someone volunteer to look into the PyPy test failure? (It did not go away by waiting for some weeks.)

Otherwise I'll have to drop PyPy support to get the tests green again.

@malthe
Copy link

malthe commented Mar 11, 2024

Seems weird that this should break based on those dependency changes.

@d-maurer
Copy link
Contributor

d-maurer commented Mar 11, 2024 via email

@do3cc
Copy link
Member

do3cc commented Mar 11, 2024

This is not a race condition.
This testcase tests a function where zdaemon waits for the file x to exist.
This is a real bug, somewhere.
But I also have no solution to offer :-(

@jensens
Copy link
Member

jensens commented Mar 11, 2024

Looking at the test-code it does not make much sense.

  • The generated t.py in the test does an initial wait of 1sec - whats the reason?.
  • The system call OTOH return immediately after the zdaemon is executed.
  • Given now, for some reason, the system-call returns faster than the 1sec wait, the x-file does not exist.

I am not using nor have experience with PyPI, so I can not tell why.

I would try to sleep(2) in the test after the system call.

>>> write('t.py',
... '''
... import time
... time.sleep(1)
... open('x', 'w').close()
... time.sleep(99)
... ''')
>>> write('conf',
... '''
... <runner>
... program %s t.py
... start-test-program cat x
... </runner>
... ''' % sys.executable)
>>> import os
>>> system("./zdaemon -Cconf start")
. .
daemon process started, pid=21446
>>> os.path.exists('x')
True

@malthe
Copy link

malthe commented Mar 11, 2024

The reason seems to be that PyPy either starts too slow, or doesn't start properly at all – that would explain why the file x doesn't exist.

I think the test needs to check that the process has not exited early, or otherwise signaled an error.

@d-maurer
Copy link
Contributor

d-maurer commented Mar 12, 2024 via email

@do3cc
Copy link
Member

do3cc commented Mar 12, 2024

I shouldn't answer any more as I can't offer a solution, but I can't stop.

The test case wants to test the option start-test-program
which:

You can optionally supply a test program, via the ``start-test-program``
configuration option, that is called repeatedly until it returns a 0
exit status or until a time limit, ``start-timeout``, has been reached.

So this zdaemon config should make the daemon start command not return while the file x does not exist.

... <runner>
... program %s t.py
... start-test-program cat x
... </runner>

https://github.com/zopefoundation/zdaemon/blob/master/src/zdaemon/tests/tests.py#L285

There is already a sleep in the code. It runs cat x, if this fails, it sleeps 1 second and runs it again. Only if cat x does not fail any more, will it return from the 'zdaemon start` command.

This is also the reason for the sleep(1) in the daemon code before creating the file, this is on purpose so that it is likely the first cat x fails, and the loop actually gets tested.

You can optionally supply a test program, via the ``start-test-program``
configuration option, that is called repeatedly until it returns a 0
exit status or until a time limit, ``start-timeout``, has been reached.

@d-maurer
Copy link
Contributor

d-maurer commented Mar 12, 2024 via email

@d-maurer
Copy link
Contributor

d-maurer commented Mar 12, 2024 via email

@d-maurer
Copy link
Contributor

d-maurer commented Mar 12, 2024 via email

@do3cc
Copy link
Member

do3cc commented Mar 12, 2024

I have also tried to reproduce it. In my case, there is no failure however. I injected various faults into the code, but nothing created a similar problem. Also because the daemon restart part of the test does not fail any more. There the x file is already created. Locally, on ubuntu 20.04 in wsl on windows, the code works as expected. A manual "logging" to a temporary file shows that the test gets run three times and on the third time, the x file exists. The code waits for this.

@d-maurer
Copy link
Contributor

d-maurer commented Mar 13, 2024 via email

@do3cc
Copy link
Member

do3cc commented Mar 13, 2024

@d-maurer do you see a sensible way to transmit exception information from the test code to reach the logs?
I suspect we sometimes get an exception in the test code, the finally clause still empties the testing variable irrespective of the cause we hit the finally clause.

@d-maurer
Copy link
Contributor

d-maurer commented Mar 13, 2024 via email

@d-maurer
Copy link
Contributor

d-maurer commented Mar 13, 2024 via email

@do3cc
Copy link
Member

do3cc commented Mar 13, 2024

Are we stumbling over unknown PID from the cat command?
Disregard my previous message, it seems the transcript would solve this. I tested logging locally and the test methods log messages do not get shown. Likely because it is in the daemon that killed off stdout? That was the log target I defined.

@d-maurer
Copy link
Contributor

d-maurer commented Mar 13, 2024 via email

@d-maurer
Copy link
Contributor

d-maurer commented Mar 13, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants