Commit Graph

87 Commits (79ed797badd039f1ba719f99a1ac2ebf8940798c)

Author SHA1 Message Date
Alex Willmer 5ad3d14ceb mitogen: Support PEP 451 ModuleSpec API, required for Python 3.12
importlib.machinery.ModuleSpec and find_spec() were introduced in Python 3.4
under PEP 451. They replace the find_module() API of PEP 302, which was
deprecated from Python 3.4. They were removed in Python 3.12 along with the
imp module.

This change adds support for the PEP 451 APIs. Mitogen should no longer import
imp on Python versions that support ModuleSpec. Tests have been added to cover
the new APIs.

CI jobs have been added to cover Python 3.x on macOS.

Refs #1033
Co-authored-by: Witold Baryluk <witold.baryluk@gmail.com>
8 months ago
Nerijus Baliūnas 4089e875a9 Add Python 3.11 support
Co-authored-by: Alex Willmer <alex@moreati.org.uk>
1 year ago
Alex Willmer 49c54386b3 tests: Only use subprocess32 package on Python 2.x
This is how the package documentation recommends and it's less likely to
interfere with new features in stdlib subprocess module.
1 year ago
Alex Willmer 6258365df6 tests: Handle square bracket IPv6 in `docker port` output
Fixes
```
======================================================================
ERROR: setUpClass (ssh_test.BannerTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vsts/work/1/s/tests/testlib.py", line 625, in setUpClass
    cls.dockerized_ssh = DockerizedSshDaemon(**daemon_args)
  File "/home/vsts/work/1/s/tests/testlib.py", line 553, in __init__
    self.start_container()
  File "/home/vsts/work/1/s/tests/testlib.py", line 533, in start_container
    self._get_container_port()
  File "/home/vsts/work/1/s/tests/testlib.py", line 510, in _get_container_port
    self.port = int(bport)
ValueError: invalid literal for int() with base 10: ':]:32770'
```
1 year ago
Alex Willmer 270c3a25de tests: Support Ubuntu 22.04 as test suite runner (controller)
To do so the test suite allows a weak cryptographic alogorithm (SHA1) to be
used, principally for CentOS 6 targets. This can be removed if/when support
for older (legacy) targets is dropped.

Only the test suite enables this known weak alogorithm. Mitogen as-shipped
doesn't enable or disable algorithms.
1 year ago
Alex Willmer 39dfd2dfe8 ci: Upgrade VM Images to macOS 11 and Ubuntu 20.04 2 years ago
Alex Willmer c32577295a tests: Check and/or suppress stderr of subprocesses, reduce shell=True uses 2 years ago
Alex Willmer 3dbb0e28ce tests: List leaked file descriptors 3 years ago
Alex Willmer 18c89de5a9 Remove unused module imports 3 years ago
Alex Willmer 0417d4d73a Replace os.system() with subprocess.check_call()
Non-zero return codes should raise an exception, not pass silently.
3 years ago
Alex Willmer 65809a6f0f mitogen: Handle Python 3.10 threading depreactions 3 years ago
Alex Willmer a8317c2393 tests: Remove unittest2, use stdlib unittest
unittest2 is incomplatible with Python 3.10
3 years ago
Alex Willmer 8276b81b7d ci: Account for pre-existing children in process leak checks 3 years ago
Alex Willmer da536e8ae1 Fix stdlib typos that would cause NameError or AttributeError exceptions 3 years ago
Alex Willmer 8cbbfaf3c1 testlib: Don't assume `docker port` output matches regex 3 years ago
Alex Willmer a8e8cf91cb tests: Rebuild Docker containers
A few changes are bundled in this
 - Ansible 2.10.x and Mitogen 0.3.x are used to build nearly all images
   (Ansile 2.3.x is retained for CentOS 5, because it uses Python 2.4).
 - Tox is used to install/run Ansible, replacing build_docker_images.py
 - A static inventory, identifying containers by name rather than ID.
 - debian-test image is renamed to debian9-test
 - debian9-test image is now based on debian:9
 - centos6-test image is now based on moreati/centos6-vault
   following the same scheme as centos5-test.
 - Images are now uploaded to Amazon Elastic Container Registry (ECR).
   See #809.
 - Debian recommended packages aren't installed (e.g. build-essential)
 - Python 2.x and Python 3.x are installed wherever available.
 - Python Virtualenv is installed wherever available.
4 years ago
Alex Willmer 4b39013ef4 tests: Compatiblity shim for threading.Thread.is_alive()
On Python >= 3.8 thread.isAlive() is deprecated (removed in Python 3.9.
On Python <= 2.5 thread.is_alive() isn't present (added in Python 2.6).
4 years ago
Steven Robertson f274ff8cfd mitogen_test_distro appeared to not be used which broke centos7 trying to run doas not in debian container, so fixing that 5 years ago
David Wilson d6329f3446 Merge devel/290 @ 79b979ec8544ef5d8620c64068d4a42fabf50415 5 years ago
David Wilson 8f99ebdf6f tests: hide memory-mapped files from lsof output
Seems to be no saner way to do this.
5 years ago
David Wilson 57012e0f72 Add mitogen.core.now() and use it everywhere; closes #614. 5 years ago
David Wilson 8bac1cf368 issue #482: another Py3 fix 5 years ago
David Wilson 83a86a2ce1 issue #482: tests: fail DockerMixin tests if stray processes exist 5 years ago
David Wilson c0d87c0aa1 testlib: use lsof +E for much clearer leaked FD output 5 years ago
David Wilson f4cee16526 parent: zombie reaping v3
Improvements:

- Refactored off Process, separately testable without a connection
- Don't delay Broker shutdown indefinitely for detached children
5 years ago
David Wilson 212f6a3529 tests: stop dumping Docker help output in the log. 5 years ago
David Wilson 19b259a45f issue #549: skip Docker tests if Docker is unavailable 5 years ago
David Wilson 108015aa22 ansible: gracefully handle failure to connect to MuxProcess
It's possible to hit an ugly exception during early CTRL+C
5 years ago
David Wilson 0e6de532de [stream-refactor] fix testlib assertion format string 5 years ago
David Wilson bd80d4b0af [stream-refactor] avoid os.wait3() for Py2.4. 5 years ago
David Wilson 300f8b2ff9 ansible: fixturize creation of MuxProcess
This relies on the previous commit resetting global variables.

Update clean_shutdown() to handle duplicate calls, due to tests
repeatedly installing it.
5 years ago
David Wilson 9c38093aa7 issue #482: tests: check for zombie process after test. 5 years ago
David Wilson bf77d4ab1d testlib: have LogCapturer.raw() return unicode on 2.x. 5 years ago
David Wilson f6d26c5acb testlib: disable lsof warnings due to Docker crap 5 years ago
David Wilson 2f29f3e8e6 tests: rearrange test modules again, they're used in multiple places
They're back on sys.path.
6 years ago
David Wilson c1db0d3858 issue #590: move example modules to module_finder/, fix/add tests 6 years ago
David Wilson 18b984a0b4 issue #535: activate Corker on 2.4 in master too. 6 years ago
David Wilson 0aa4c9d8fc issue #542: .ci: move some tests to Azure and enable Mac job. 6 years ago
David Wilson 9f10695ee2 issue #477: Popen.terminate() polyfill for Py2.4. 6 years ago
David Wilson 83aff538b3 issue #477: testlib: Py2.4 did not have BaseException. 6 years ago
David Wilson 4388e794ce issue #477: Py2.4: enumerate() may return stopped threads. 6 years ago
David Wilson 2ead451277 issue #477: Python 2.4 lacked str.partition. 6 years ago
David Wilson 2ec19f2374 issue #477: Python 2.4 lacked Thread.name. 6 years ago
David Wilson 2f016b5c7b issue #477: Python 2.4 lacked context managers. 6 years ago
David Wilson 9da6e6a9a8 tests: don't call Router.shutdown() twice.
Due to 497234e7 / issue #456.
6 years ago
David Wilson 3206d59c87 issue #426: teach DockerMixin to allow selecting interpreter 6 years ago
David Wilson 4b61e5af02 tests: run FD and thread checks on every test case.
Trying to hunt down weirdness on Azure.
6 years ago
David Wilson 27a4001f4f tests: handle NameError when faulthandler is not installed. 6 years ago
David Wilson e01c8f2891 issue #406: 3.x syntax fixes. 6 years ago
David Wilson 3da4b1a420 tests: verify only main/watcher threads exist at teardown 6 years ago