Merge commit '5908936' into release-v0.3.26
commit
fd1d45568a
@ -0,0 +1,91 @@
|
||||
- name: integration/become/doas.yml - unqualified
|
||||
hosts: test-targets:&linux_containers
|
||||
gather_facts: false
|
||||
become_method: doas # noqa: schema[playbook]
|
||||
vars:
|
||||
ansible_become_password: has_sudo_nopw_password
|
||||
tasks:
|
||||
# Vanilla Ansible doas requires pipelining=false
|
||||
# https://github.com/ansible-collections/community.general/issues/9977
|
||||
- include_tasks: ../_mitogen_only.yml
|
||||
|
||||
- name: Test doas -> default target user
|
||||
become: true
|
||||
command: whoami
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
register: doas_default_user
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- doas_default_user.stdout == 'root'
|
||||
fail_msg:
|
||||
doas_default_user={{ doas_default_user }}
|
||||
|
||||
- name: Test doas -> mitogen__user1
|
||||
become: true
|
||||
become_user: mitogen__user1
|
||||
command: whoami
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
register: doas_mitogen__user1
|
||||
when:
|
||||
- become_unpriv_available
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- doas_mitogen__user1.stdout == 'mitogen__user1'
|
||||
fail_msg:
|
||||
doas_mitogen__user1={{ doas_mitogen__user1 }}
|
||||
when:
|
||||
- become_unpriv_available
|
||||
tags:
|
||||
- doas
|
||||
- issue_1309
|
||||
- mitogen_only
|
||||
|
||||
- name: integration/become/doas.yml - FQCN
|
||||
hosts: test-targets:&linux_containers
|
||||
gather_facts: false
|
||||
become_method: community.general.doas
|
||||
vars:
|
||||
ansible_become_password: has_sudo_nopw_password
|
||||
tasks:
|
||||
# Vanilla Ansible doas requires pipelining=false
|
||||
# https://github.com/ansible-collections/community.general/issues/9977
|
||||
- include_tasks: ../_mitogen_only.yml
|
||||
|
||||
- name: Test community.general.doas -> default target user
|
||||
become: true
|
||||
command: whoami
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
register: fq_doas_default_user
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- fq_doas_default_user.stdout == 'root'
|
||||
fail_msg:
|
||||
fq_doas_default_user={{ fq_doas_default_user }}
|
||||
|
||||
- name: Test community.general.doas -> mitogen__user1
|
||||
become: true
|
||||
become_user: mitogen__user1
|
||||
command: whoami
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
register: fq_doas_mitogen__user1
|
||||
when:
|
||||
- become_unpriv_available
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- fq_doas_mitogen__user1.stdout == 'mitogen__user1'
|
||||
fail_msg:
|
||||
fq_doas_mitogen__user1={{ fq_doas_mitogen__user1 }}
|
||||
when:
|
||||
- become_unpriv_available
|
||||
tags:
|
||||
- doas
|
||||
- issue_1309
|
||||
- mitogen_only
|
||||
@ -0,0 +1,32 @@
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
import mitogen.core
|
||||
|
||||
import testlib
|
||||
|
||||
class BlockingIOTest(testlib.TestCase):
|
||||
def setUp(self):
|
||||
super(BlockingIOTest, self).setUp()
|
||||
self.fp = tempfile.TemporaryFile()
|
||||
self.fd = self.fp.fileno()
|
||||
|
||||
def tearDown(self):
|
||||
self.fp.close()
|
||||
super(BlockingIOTest, self).tearDown()
|
||||
|
||||
def test_get_blocking(self):
|
||||
if hasattr(os, 'get_blocking'):
|
||||
self.assertEqual(
|
||||
os.get_blocking(self.fd), mitogen.core.get_blocking(self.fd),
|
||||
)
|
||||
self.assertTrue(mitogen.core.get_blocking(self.fd) is True)
|
||||
|
||||
def test_set_blocking(self):
|
||||
mitogen.core.set_blocking(self.fd, False)
|
||||
if hasattr(os, 'get_blocking'):
|
||||
self.assertEqual(
|
||||
os.get_blocking(self.fd), mitogen.core.get_blocking(self.fd),
|
||||
)
|
||||
self.assertTrue(mitogen.core.get_blocking(self.fd) is False)
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
import fcntl
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def shout_stdout(size):
|
||||
sys.stdout.write('A' * size)
|
||||
return 'success'
|
||||
|
||||
|
||||
def file_is_blocking(fobj):
|
||||
return not (fcntl.fcntl(fobj.fileno(), fcntl.F_GETFL) & os.O_NONBLOCK)
|
||||
|
||||
|
||||
def stdio_is_blocking():
|
||||
return [file_is_blocking(f) for f in [sys.stdin, sys.stdout, sys.stderr]]
|
||||
@ -0,0 +1,35 @@
|
||||
import os
|
||||
|
||||
import mitogen.core
|
||||
|
||||
import testlib
|
||||
|
||||
class PipeTest(testlib.TestCase):
|
||||
def test_pipe_blocking_unspecified(self):
|
||||
"Test that unspecified blocking arg (None) behaves same as os.pipe()"
|
||||
os_rfd, os_wfd = os.pipe()
|
||||
mi_rfp, mi_wfp = mitogen.core.pipe()
|
||||
|
||||
self.assertEqual(mitogen.core.get_blocking(os_rfd),
|
||||
mitogen.core.get_blocking(mi_rfp.fileno()))
|
||||
self.assertEqual(mitogen.core.get_blocking(os_wfd),
|
||||
mitogen.core.get_blocking(mi_wfp.fileno()))
|
||||
mi_rfp.close()
|
||||
mi_wfp.close()
|
||||
os.close(os_rfd)
|
||||
os.close(os_wfd)
|
||||
|
||||
def test_pipe_blocking_true(self):
|
||||
mi_rfp, mi_wfp = mitogen.core.pipe(blocking=True)
|
||||
self.assertTrue(mitogen.core.get_blocking(mi_rfp.fileno()))
|
||||
self.assertTrue(mitogen.core.get_blocking(mi_wfp.fileno()))
|
||||
mi_rfp.close()
|
||||
mi_wfp.close()
|
||||
|
||||
def test_pipe_blocking_false(self):
|
||||
mi_rfp, mi_wfp = mitogen.core.pipe(blocking=False)
|
||||
self.assertFalse(mitogen.core.get_blocking(mi_rfp.fileno()))
|
||||
self.assertFalse(mitogen.core.get_blocking(mi_wfp.fileno()))
|
||||
mi_rfp.close()
|
||||
mi_wfp.close()
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
import socket
|
||||
|
||||
import mitogen.core
|
||||
|
||||
import testlib
|
||||
|
||||
class SocketPairTest(testlib.TestCase):
|
||||
def test_socketpair_blocking_unspecified(self):
|
||||
"Test that unspecified blocking arg (None) batches socket.socketpair()"
|
||||
sk_fp1, sk_fp2 = socket.socketpair()
|
||||
mi_fp1, mi_fp2 = mitogen.core.socketpair()
|
||||
|
||||
self.assertEqual(mitogen.core.get_blocking(sk_fp1.fileno()),
|
||||
mitogen.core.get_blocking(mi_fp1.fileno()))
|
||||
self.assertEqual(mitogen.core.get_blocking(sk_fp2.fileno()),
|
||||
mitogen.core.get_blocking(mi_fp2.fileno()))
|
||||
mi_fp1.close()
|
||||
mi_fp2.close()
|
||||
sk_fp1.close()
|
||||
sk_fp2.close()
|
||||
|
||||
def test_socketpair_blocking_true(self):
|
||||
mi_fp1, mi_fp2 = mitogen.core.socketpair(blocking=True)
|
||||
self.assertTrue(mitogen.core.get_blocking(mi_fp1.fileno()))
|
||||
self.assertTrue(mitogen.core.get_blocking(mi_fp2.fileno()))
|
||||
mi_fp1.close()
|
||||
mi_fp2.close()
|
||||
|
||||
def test_socketpair_blocking_false(self):
|
||||
mi_fp1, mi_fp2 = mitogen.core.socketpair(blocking=False)
|
||||
self.assertFalse(mitogen.core.get_blocking(mi_fp1.fileno()))
|
||||
self.assertFalse(mitogen.core.get_blocking(mi_fp2.fileno()))
|
||||
mi_fp1.close()
|
||||
mi_fp2.close()
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
import testlib
|
||||
|
||||
import stdio_checks
|
||||
|
||||
|
||||
class StdIOTest(testlib.RouterMixin, testlib.TestCase):
|
||||
"""
|
||||
Test that stdin, stdout, and stderr conform to common expectations,
|
||||
such as blocking IO.
|
||||
"""
|
||||
def test_can_write_stdout_1_mib(self):
|
||||
"""
|
||||
Writing to stdout should not raise EAGAIN. Regression test for
|
||||
https://github.com/mitogen-hq/mitogen/issues/712.
|
||||
"""
|
||||
size = 1 * 2**20
|
||||
context = self.router.local()
|
||||
result = context.call(stdio_checks.shout_stdout, size)
|
||||
self.assertEqual('success', result)
|
||||
|
||||
def test_stdio_is_blocking(self):
|
||||
context = self.router.local()
|
||||
stdin_blocking, stdout_blocking, stderr_blocking = context.call(
|
||||
stdio_checks.stdio_is_blocking,
|
||||
)
|
||||
self.assertTrue(stdin_blocking)
|
||||
self.assertTrue(stdout_blocking)
|
||||
self.assertTrue(stderr_blocking)
|
||||
Loading…
Reference in New Issue