Skip to content

Instantly share code, notes, and snippets.

@Akasurde
Created August 6, 2024 17:37
Show Gist options
  • Save Akasurde/9c827ce2e7d8d97e00014aaeafca6785 to your computer and use it in GitHub Desktop.
Save Akasurde/9c827ce2e7d8d97e00014aaeafca6785 to your computer and use it in GitHub Desktop.
event_source_kafka.log
# pytest tests/integration/event_source_kafka/ -vvv -s
================================== test session starts ==================================
platform linux -- Python 3.9.18, pytest-8.3.2, pluggy-1.5.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /root/event-driven-ansible
configfile: pyproject.toml
plugins: timeout-2.3.1, asyncio-0.23.8
asyncio: mode=strict
collected 5 items
tests/integration/event_source_kafka/test_kafka_source.py::test_kafka_source_plaintext /root/event-driven-ansible/tests/integration/event_source_kafka
.........+......+.....+.........+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*............+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*...............+....+...........+.+......+.....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.......+............+......+..........+.....+.......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*......+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*..+..........+.....+.......+.....+...+.+...........+....+......+.....+..........+............+..+.............+...+...+......+...+...........+......+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-----
Certificate request self-signature ok
subject=C = US, ST = MA, L = Boston, O = ANSIBLE, OU = TEST, CN = broker
Certificate was added to keystore
Certificate reply was installed in keystore
Certificate was added to keystore
/root/event-driven-ansible/tests/integration/event_source_kafka
WARN[0000] /root/event-driven-ansible/tests/integration/event_source_kafka/docker-compose.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion
[+] Running 16/16
✔ zookeeper Pulled 10.0s
✔ 16b78ed2e822 Pull complete 2.3s
✔ e7233e20a08e Pull complete 8.4s
✔ 9b9cbc4e490c Pull complete 8.5s
✔ f7352f1ba78a Pull complete 8.5s
✔ e06c925589f1 Pull complete 8.7s
✔ 3a498372ace6 Pull complete 8.7s
✔ 2ea0fca7e4a4 Pull complete 8.7s
✔ c33c6c0781fc Pull complete 8.7s
✔ 5d9855bac5a8 Pull complete 9.3s
✔ 083e1d04595f Pull complete 9.3s
✔ broker Pulled 10.0s
✔ wait_for Pulled 10.0s
✔ 131f1a26eef0 Pull complete 2.2s
✔ 45f1197956c6 Pull complete 9.3s
✔ 1dcef6fb6396 Pull complete 9.3s
[+] Running 4/4
✔ Network event_source_kafka_default Created 0.1s
✔ Container event_source_kafka-zookeeper-1 Started 0.6s
✔ Container event_source_kafka-broker-1 Healthy 11.0s
✔ Container event_source_kafka-wait_for-1 Started 11.2s
Running command: ansible-rulebook -i /root/event-driven-ansible/tests/integration/default_inventory.yml --rulebook /root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_plaintext.yml
FAILED
tests/integration/event_source_kafka/test_kafka_source.py::test_kafka_source_with_headers Running command: ansible-rulebook -i /root/event-driven-ansible/tests/integration/default_inventory.yml --rulebook /root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_headers.yml
FAILED
tests/integration/event_source_kafka/test_kafka_source.py::test_kafka_source_ssl Running command: ansible-rulebook -i /root/event-driven-ansible/tests/integration/default_inventory.yml --rulebook /root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_ssl.yml
FAILED
tests/integration/event_source_kafka/test_kafka_source.py::test_kafka_source_sasl_plaintext Running command: ansible-rulebook -i /root/event-driven-ansible/tests/integration/default_inventory.yml --rulebook /root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_sasl_plaintext.yml
FAILED
tests/integration/event_source_kafka/test_kafka_source.py::test_kafka_source_sasl_ssl Running command: ansible-rulebook -i /root/event-driven-ansible/tests/integration/default_inventory.yml --rulebook /root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_sasl_ssl.yml
FAILEDWARN[0000] /root/event-driven-ansible/tests/integration/event_source_kafka/docker-compose.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion
[+] Running 4/4
✔ Container event_source_kafka-wait_for-1 Removed 0.0s
✔ Container event_source_kafka-broker-1 Removed 2.3s
✔ Container event_source_kafka-zookeeper-1 Removed 0.4s
✔ Network event_source_kafka_default Removed 0.2s
======================================= FAILURES ========================================
______________________________ test_kafka_source_plaintext ______________________________
kafka_certs = CompletedProcess(args=['/root/event-driven-ansible/tests/integration/event_source_kafka/certs-create.sh'], returncode=0)
kafka_broker = CompletedProcess(args=['docker-compose', 'up', '-d'], returncode=0)
kafka_producer = <kafka.producer.kafka.KafkaProducer object at 0x7fecc7953b20>
def test_kafka_source_plaintext(kafka_certs, kafka_broker, kafka_producer):
ruleset = os.path.join(
TESTS_PATH, "event_source_kafka", "test_kafka_rules_plaintext.yml"
)
msgs = [
json.dumps({"name": "Produced for PLAINTEXT consumers"}).encode("ascii"),
"stop".encode("ascii"),
]
for msg in msgs:
kafka_producer.send(topic="kafka-events-plaintext", value=msg)
> result = CLIRunner(rules=ruleset).run()
tests/integration/event_source_kafka/test_kafka_source.py:47:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/integration/utils.py:60: in run
return subprocess.run(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
input = None, capture_output = True, timeout = 10.0, check = True
popenargs = (['ansible-rulebook', '-i', '/root/event-driven-ansible/tests/integration/default_inventory.yml', '--rulebook', '/root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_plaintext.yml'],)
kwargs = {'cwd': '/root/event-driven-ansible/tests/integration', 'env': {'ANSIBLE_DEV_HOME': '/root/ansible', 'BASH_FUNC_which%%': '() { ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@\n}', 'BEAKER': 'https://beaker.engineering.redhat.com/', 'BEAKER_HUB_URL': 'https://beaker.engineering.redhat.com/', ...}, 'stderr': -1, 'stdout': -1}
process = <Popen: returncode: 1 args: ['ansible-rulebook', '-i', '/root/event-driven-a...>
stdout = b''
stderr = b'\n** 2024-08-06 13:33:22.647203 [util] *******************************************\nThe minimum supported Java version is 17. Found version: 11.0.24\n********************************************************************************\n'
retcode = 1
def run(*popenargs,
input=None, capture_output=False, timeout=None, check=False, **kwargs):
"""Run command with arguments and return a CompletedProcess instance.
The returned instance will have attributes args, returncode, stdout and
stderr. By default, stdout and stderr are not captured, and those attributes
will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them.
If check is True and the exit code was non-zero, it raises a
CalledProcessError. The CalledProcessError object will have the return code
in the returncode attribute, and output & stderr attributes if those streams
were captured.
If timeout is given, and the process takes too long, a TimeoutExpired
exception will be raised.
There is an optional argument "input", allowing you to
pass bytes or a string to the subprocess's stdin. If you use this argument
you may not also use the Popen constructor's "stdin" argument, as
it will be used internally.
By default, all communication is in bytes, and therefore any "input" should
be bytes, and the stdout and stderr will be bytes. If in text mode, any
"input" should be a string, and stdout and stderr will be strings decoded
according to locale encoding, or by "encoding" if set. Text mode is
triggered by setting any of text, encoding, errors or universal_newlines.
The other arguments are the same as for the Popen constructor.
"""
if input is not None:
if kwargs.get('stdin') is not None:
raise ValueError('stdin and input arguments may not both be used.')
kwargs['stdin'] = PIPE
if capture_output:
if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
raise ValueError('stdout and stderr arguments may not be used '
'with capture_output.')
kwargs['stdout'] = PIPE
kwargs['stderr'] = PIPE
with Popen(*popenargs, **kwargs) as process:
try:
stdout, stderr = process.communicate(input, timeout=timeout)
except TimeoutExpired as exc:
process.kill()
if _mswindows:
# Windows accumulates the output in a single blocking
# read() call run on child threads, with the timeout
# being done in a join() on those threads. communicate()
# _after_ kill() is required to collect that and add it
# to the exception.
exc.stdout, exc.stderr = process.communicate()
else:
# POSIX _communicate already populated the output so
# far into the TimeoutExpired exception.
process.wait()
raise
except: # Including KeyboardInterrupt, communicate handled that.
process.kill()
# We don't call process.wait() as .__exit__ does that for us.
raise
retcode = process.poll()
if check and retcode:
> raise CalledProcessError(retcode, process.args,
output=stdout, stderr=stderr)
E subprocess.CalledProcessError: Command '['ansible-rulebook', '-i', '/root/event-driven-ansible/tests/integration/default_inventory.yml', '--rulebook', '/root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_plaintext.yml']' returned non-zero exit status 1.
/usr/lib64/python3.9/subprocess.py:528: CalledProcessError
____________________________ test_kafka_source_with_headers _____________________________
kafka_certs = CompletedProcess(args=['/root/event-driven-ansible/tests/integration/event_source_kafka/certs-create.sh'], returncode=0)
kafka_broker = CompletedProcess(args=['docker-compose', 'up', '-d'], returncode=0)
kafka_producer = <kafka.producer.kafka.KafkaProducer object at 0x7fecc7953b20>
def test_kafka_source_with_headers(kafka_certs, kafka_broker, kafka_producer):
ruleset = os.path.join(
TESTS_PATH, "event_source_kafka", "test_kafka_rules_headers.yml"
)
msgs = [
json.dumps({"name": "Produced for PLAINTEXT consumers"}).encode("ascii"),
"stop".encode("ascii"),
]
headers = [
(key, value.encode("ascii"))
for key, value in json.loads('{"foo": "bar"}').items()
]
for msg in msgs:
kafka_producer.send(topic="kafka-events-plaintext", value=msg, headers=headers)
> result = CLIRunner(rules=ruleset).run()
tests/integration/event_source_kafka/test_kafka_source.py:70:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/integration/utils.py:60: in run
return subprocess.run(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
input = None, capture_output = True, timeout = 10.0, check = True
popenargs = (['ansible-rulebook', '-i', '/root/event-driven-ansible/tests/integration/default_inventory.yml', '--rulebook', '/root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_headers.yml'],)
kwargs = {'cwd': '/root/event-driven-ansible/tests/integration', 'env': {'ANSIBLE_DEV_HOME': '/root/ansible', 'BASH_FUNC_which%%': '() { ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@\n}', 'BEAKER': 'https://beaker.engineering.redhat.com/', 'BEAKER_HUB_URL': 'https://beaker.engineering.redhat.com/', ...}, 'stderr': -1, 'stdout': -1}
process = <Popen: returncode: 1 args: ['ansible-rulebook', '-i', '/root/event-driven-a...>
stdout = b''
stderr = b'\n** 2024-08-06 13:33:23.079974 [util] *******************************************\nThe minimum supported Java version is 17. Found version: 11.0.24\n********************************************************************************\n'
retcode = 1
def run(*popenargs,
input=None, capture_output=False, timeout=None, check=False, **kwargs):
"""Run command with arguments and return a CompletedProcess instance.
The returned instance will have attributes args, returncode, stdout and
stderr. By default, stdout and stderr are not captured, and those attributes
will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them.
If check is True and the exit code was non-zero, it raises a
CalledProcessError. The CalledProcessError object will have the return code
in the returncode attribute, and output & stderr attributes if those streams
were captured.
If timeout is given, and the process takes too long, a TimeoutExpired
exception will be raised.
There is an optional argument "input", allowing you to
pass bytes or a string to the subprocess's stdin. If you use this argument
you may not also use the Popen constructor's "stdin" argument, as
it will be used internally.
By default, all communication is in bytes, and therefore any "input" should
be bytes, and the stdout and stderr will be bytes. If in text mode, any
"input" should be a string, and stdout and stderr will be strings decoded
according to locale encoding, or by "encoding" if set. Text mode is
triggered by setting any of text, encoding, errors or universal_newlines.
The other arguments are the same as for the Popen constructor.
"""
if input is not None:
if kwargs.get('stdin') is not None:
raise ValueError('stdin and input arguments may not both be used.')
kwargs['stdin'] = PIPE
if capture_output:
if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
raise ValueError('stdout and stderr arguments may not be used '
'with capture_output.')
kwargs['stdout'] = PIPE
kwargs['stderr'] = PIPE
with Popen(*popenargs, **kwargs) as process:
try:
stdout, stderr = process.communicate(input, timeout=timeout)
except TimeoutExpired as exc:
process.kill()
if _mswindows:
# Windows accumulates the output in a single blocking
# read() call run on child threads, with the timeout
# being done in a join() on those threads. communicate()
# _after_ kill() is required to collect that and add it
# to the exception.
exc.stdout, exc.stderr = process.communicate()
else:
# POSIX _communicate already populated the output so
# far into the TimeoutExpired exception.
process.wait()
raise
except: # Including KeyboardInterrupt, communicate handled that.
process.kill()
# We don't call process.wait() as .__exit__ does that for us.
raise
retcode = process.poll()
if check and retcode:
> raise CalledProcessError(retcode, process.args,
output=stdout, stderr=stderr)
E subprocess.CalledProcessError: Command '['ansible-rulebook', '-i', '/root/event-driven-ansible/tests/integration/default_inventory.yml', '--rulebook', '/root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_headers.yml']' returned non-zero exit status 1.
/usr/lib64/python3.9/subprocess.py:528: CalledProcessError
_________________________________ test_kafka_source_ssl _________________________________
kafka_certs = CompletedProcess(args=['/root/event-driven-ansible/tests/integration/event_source_kafka/certs-create.sh'], returncode=0)
kafka_broker = CompletedProcess(args=['docker-compose', 'up', '-d'], returncode=0)
kafka_producer = <kafka.producer.kafka.KafkaProducer object at 0x7fecc7953b20>
def test_kafka_source_ssl(kafka_certs, kafka_broker, kafka_producer):
ruleset = os.path.join(TESTS_PATH, "event_source_kafka", "test_kafka_rules_ssl.yml")
msgs = [
json.dumps({"name": "Produced for SSL consumers"}).encode("ascii"),
"stop".encode("ascii"),
]
for msg in msgs:
kafka_producer.send(topic="kafka-events-ssl", value=msg)
> result = CLIRunner(rules=ruleset).run()
tests/integration/event_source_kafka/test_kafka_source.py:86:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/integration/utils.py:60: in run
return subprocess.run(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
input = None, capture_output = True, timeout = 10.0, check = True
popenargs = (['ansible-rulebook', '-i', '/root/event-driven-ansible/tests/integration/default_inventory.yml', '--rulebook', '/root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_ssl.yml'],)
kwargs = {'cwd': '/root/event-driven-ansible/tests/integration', 'env': {'ANSIBLE_DEV_HOME': '/root/ansible', 'BASH_FUNC_which%%': '() { ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@\n}', 'BEAKER': 'https://beaker.engineering.redhat.com/', 'BEAKER_HUB_URL': 'https://beaker.engineering.redhat.com/', ...}, 'stderr': -1, 'stdout': -1}
process = <Popen: returncode: 1 args: ['ansible-rulebook', '-i', '/root/event-driven-a...>
stdout = b''
stderr = b'\n** 2024-08-06 13:33:23.535753 [util] *******************************************\nThe minimum supported Java version is 17. Found version: 11.0.24\n********************************************************************************\n'
retcode = 1
def run(*popenargs,
input=None, capture_output=False, timeout=None, check=False, **kwargs):
"""Run command with arguments and return a CompletedProcess instance.
The returned instance will have attributes args, returncode, stdout and
stderr. By default, stdout and stderr are not captured, and those attributes
will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them.
If check is True and the exit code was non-zero, it raises a
CalledProcessError. The CalledProcessError object will have the return code
in the returncode attribute, and output & stderr attributes if those streams
were captured.
If timeout is given, and the process takes too long, a TimeoutExpired
exception will be raised.
There is an optional argument "input", allowing you to
pass bytes or a string to the subprocess's stdin. If you use this argument
you may not also use the Popen constructor's "stdin" argument, as
it will be used internally.
By default, all communication is in bytes, and therefore any "input" should
be bytes, and the stdout and stderr will be bytes. If in text mode, any
"input" should be a string, and stdout and stderr will be strings decoded
according to locale encoding, or by "encoding" if set. Text mode is
triggered by setting any of text, encoding, errors or universal_newlines.
The other arguments are the same as for the Popen constructor.
"""
if input is not None:
if kwargs.get('stdin') is not None:
raise ValueError('stdin and input arguments may not both be used.')
kwargs['stdin'] = PIPE
if capture_output:
if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
raise ValueError('stdout and stderr arguments may not be used '
'with capture_output.')
kwargs['stdout'] = PIPE
kwargs['stderr'] = PIPE
with Popen(*popenargs, **kwargs) as process:
try:
stdout, stderr = process.communicate(input, timeout=timeout)
except TimeoutExpired as exc:
process.kill()
if _mswindows:
# Windows accumulates the output in a single blocking
# read() call run on child threads, with the timeout
# being done in a join() on those threads. communicate()
# _after_ kill() is required to collect that and add it
# to the exception.
exc.stdout, exc.stderr = process.communicate()
else:
# POSIX _communicate already populated the output so
# far into the TimeoutExpired exception.
process.wait()
raise
except: # Including KeyboardInterrupt, communicate handled that.
process.kill()
# We don't call process.wait() as .__exit__ does that for us.
raise
retcode = process.poll()
if check and retcode:
> raise CalledProcessError(retcode, process.args,
output=stdout, stderr=stderr)
E subprocess.CalledProcessError: Command '['ansible-rulebook', '-i', '/root/event-driven-ansible/tests/integration/default_inventory.yml', '--rulebook', '/root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_ssl.yml']' returned non-zero exit status 1.
/usr/lib64/python3.9/subprocess.py:528: CalledProcessError
----------------------------------- Captured log call -----------------------------------
WARNING kafka.cluster:cluster.py:293 Topic kafka-events-ssl is not available during auto-create initialization
___________________________ test_kafka_source_sasl_plaintext ____________________________
kafka_certs = CompletedProcess(args=['/root/event-driven-ansible/tests/integration/event_source_kafka/certs-create.sh'], returncode=0)
kafka_broker = CompletedProcess(args=['docker-compose', 'up', '-d'], returncode=0)
kafka_producer = <kafka.producer.kafka.KafkaProducer object at 0x7fecc7953b20>
def test_kafka_source_sasl_plaintext(kafka_certs, kafka_broker, kafka_producer):
ruleset = os.path.join(
TESTS_PATH, "event_source_kafka", "test_kafka_rules_sasl_plaintext.yml"
)
msgs = [
json.dumps({"name": "Produced for SASL_PLAINTEXT consumers"}).encode("ascii"),
"stop".encode("ascii"),
]
for msg in msgs:
kafka_producer.send(topic="kafka-events-sasl-plaintext", value=msg)
> result = CLIRunner(rules=ruleset).run()
tests/integration/event_source_kafka/test_kafka_source.py:104:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/integration/utils.py:60: in run
return subprocess.run(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
input = None, capture_output = True, timeout = 10.0, check = True
popenargs = (['ansible-rulebook', '-i', '/root/event-driven-ansible/tests/integration/default_inventory.yml', '--rulebook', '/root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_sasl_plaintext.yml'],)
kwargs = {'cwd': '/root/event-driven-ansible/tests/integration', 'env': {'ANSIBLE_DEV_HOME': '/root/ansible', 'BASH_FUNC_which%%': '() { ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@\n}', 'BEAKER': 'https://beaker.engineering.redhat.com/', 'BEAKER_HUB_URL': 'https://beaker.engineering.redhat.com/', ...}, 'stderr': -1, 'stdout': -1}
process = <Popen: returncode: 1 args: ['ansible-rulebook', '-i', '/root/event-driven-a...>
stdout = b''
stderr = b'\n** 2024-08-06 13:33:23.991163 [util] *******************************************\nThe minimum supported Java version is 17. Found version: 11.0.24\n********************************************************************************\n'
retcode = 1
def run(*popenargs,
input=None, capture_output=False, timeout=None, check=False, **kwargs):
"""Run command with arguments and return a CompletedProcess instance.
The returned instance will have attributes args, returncode, stdout and
stderr. By default, stdout and stderr are not captured, and those attributes
will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them.
If check is True and the exit code was non-zero, it raises a
CalledProcessError. The CalledProcessError object will have the return code
in the returncode attribute, and output & stderr attributes if those streams
were captured.
If timeout is given, and the process takes too long, a TimeoutExpired
exception will be raised.
There is an optional argument "input", allowing you to
pass bytes or a string to the subprocess's stdin. If you use this argument
you may not also use the Popen constructor's "stdin" argument, as
it will be used internally.
By default, all communication is in bytes, and therefore any "input" should
be bytes, and the stdout and stderr will be bytes. If in text mode, any
"input" should be a string, and stdout and stderr will be strings decoded
according to locale encoding, or by "encoding" if set. Text mode is
triggered by setting any of text, encoding, errors or universal_newlines.
The other arguments are the same as for the Popen constructor.
"""
if input is not None:
if kwargs.get('stdin') is not None:
raise ValueError('stdin and input arguments may not both be used.')
kwargs['stdin'] = PIPE
if capture_output:
if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
raise ValueError('stdout and stderr arguments may not be used '
'with capture_output.')
kwargs['stdout'] = PIPE
kwargs['stderr'] = PIPE
with Popen(*popenargs, **kwargs) as process:
try:
stdout, stderr = process.communicate(input, timeout=timeout)
except TimeoutExpired as exc:
process.kill()
if _mswindows:
# Windows accumulates the output in a single blocking
# read() call run on child threads, with the timeout
# being done in a join() on those threads. communicate()
# _after_ kill() is required to collect that and add it
# to the exception.
exc.stdout, exc.stderr = process.communicate()
else:
# POSIX _communicate already populated the output so
# far into the TimeoutExpired exception.
process.wait()
raise
except: # Including KeyboardInterrupt, communicate handled that.
process.kill()
# We don't call process.wait() as .__exit__ does that for us.
raise
retcode = process.poll()
if check and retcode:
> raise CalledProcessError(retcode, process.args,
output=stdout, stderr=stderr)
E subprocess.CalledProcessError: Command '['ansible-rulebook', '-i', '/root/event-driven-ansible/tests/integration/default_inventory.yml', '--rulebook', '/root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_sasl_plaintext.yml']' returned non-zero exit status 1.
/usr/lib64/python3.9/subprocess.py:528: CalledProcessError
----------------------------------- Captured log call -----------------------------------
WARNING kafka.cluster:cluster.py:293 Topic kafka-events-sasl-plaintext is not available during auto-create initialization
______________________________ test_kafka_source_sasl_ssl _______________________________
kafka_certs = CompletedProcess(args=['/root/event-driven-ansible/tests/integration/event_source_kafka/certs-create.sh'], returncode=0)
kafka_broker = CompletedProcess(args=['docker-compose', 'up', '-d'], returncode=0)
kafka_producer = <kafka.producer.kafka.KafkaProducer object at 0x7fecc7953b20>
def test_kafka_source_sasl_ssl(kafka_certs, kafka_broker, kafka_producer):
ruleset = os.path.join(
TESTS_PATH, "event_source_kafka", "test_kafka_rules_sasl_ssl.yml"
)
msgs = [
json.dumps({"name": "Produced for SASL_SSL consumers"}).encode("ascii"),
"stop".encode("ascii"),
]
for msg in msgs:
kafka_producer.send(topic="kafka-events-sasl-ssl", value=msg)
> result = CLIRunner(rules=ruleset).run()
tests/integration/event_source_kafka/test_kafka_source.py:124:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/integration/utils.py:60: in run
return subprocess.run(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
input = None, capture_output = True, timeout = 10.0, check = True
popenargs = (['ansible-rulebook', '-i', '/root/event-driven-ansible/tests/integration/default_inventory.yml', '--rulebook', '/root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_sasl_ssl.yml'],)
kwargs = {'cwd': '/root/event-driven-ansible/tests/integration', 'env': {'ANSIBLE_DEV_HOME': '/root/ansible', 'BASH_FUNC_which%%': '() { ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@\n}', 'BEAKER': 'https://beaker.engineering.redhat.com/', 'BEAKER_HUB_URL': 'https://beaker.engineering.redhat.com/', ...}, 'stderr': -1, 'stdout': -1}
process = <Popen: returncode: 1 args: ['ansible-rulebook', '-i', '/root/event-driven-a...>
stdout = b''
stderr = b'\n** 2024-08-06 13:33:24.452789 [util] *******************************************\nThe minimum supported Java version is 17. Found version: 11.0.24\n********************************************************************************\n'
retcode = 1
def run(*popenargs,
input=None, capture_output=False, timeout=None, check=False, **kwargs):
"""Run command with arguments and return a CompletedProcess instance.
The returned instance will have attributes args, returncode, stdout and
stderr. By default, stdout and stderr are not captured, and those attributes
will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them.
If check is True and the exit code was non-zero, it raises a
CalledProcessError. The CalledProcessError object will have the return code
in the returncode attribute, and output & stderr attributes if those streams
were captured.
If timeout is given, and the process takes too long, a TimeoutExpired
exception will be raised.
There is an optional argument "input", allowing you to
pass bytes or a string to the subprocess's stdin. If you use this argument
you may not also use the Popen constructor's "stdin" argument, as
it will be used internally.
By default, all communication is in bytes, and therefore any "input" should
be bytes, and the stdout and stderr will be bytes. If in text mode, any
"input" should be a string, and stdout and stderr will be strings decoded
according to locale encoding, or by "encoding" if set. Text mode is
triggered by setting any of text, encoding, errors or universal_newlines.
The other arguments are the same as for the Popen constructor.
"""
if input is not None:
if kwargs.get('stdin') is not None:
raise ValueError('stdin and input arguments may not both be used.')
kwargs['stdin'] = PIPE
if capture_output:
if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
raise ValueError('stdout and stderr arguments may not be used '
'with capture_output.')
kwargs['stdout'] = PIPE
kwargs['stderr'] = PIPE
with Popen(*popenargs, **kwargs) as process:
try:
stdout, stderr = process.communicate(input, timeout=timeout)
except TimeoutExpired as exc:
process.kill()
if _mswindows:
# Windows accumulates the output in a single blocking
# read() call run on child threads, with the timeout
# being done in a join() on those threads. communicate()
# _after_ kill() is required to collect that and add it
# to the exception.
exc.stdout, exc.stderr = process.communicate()
else:
# POSIX _communicate already populated the output so
# far into the TimeoutExpired exception.
process.wait()
raise
except: # Including KeyboardInterrupt, communicate handled that.
process.kill()
# We don't call process.wait() as .__exit__ does that for us.
raise
retcode = process.poll()
if check and retcode:
> raise CalledProcessError(retcode, process.args,
output=stdout, stderr=stderr)
E subprocess.CalledProcessError: Command '['ansible-rulebook', '-i', '/root/event-driven-ansible/tests/integration/default_inventory.yml', '--rulebook', '/root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_sasl_ssl.yml']' returned non-zero exit status 1.
/usr/lib64/python3.9/subprocess.py:528: CalledProcessError
----------------------------------- Captured log call -----------------------------------
WARNING kafka.cluster:cluster.py:293 Topic kafka-events-sasl-ssl is not available during auto-create initialization
--------------------------------- Captured log teardown ---------------------------------
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
ERROR kafka.conn:conn.py:1107 <BrokerConnection node_id=1 host=localhost:9092 <connected> [IPv4 ('127.0.0.1', 9092)]>: Error receiving network data closing socket
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/kafka/conn.py", line 1090, in _recv
data = self._sock.recv(self.config['sock_chunk_bytes'])
ConnectionResetError: [Errno 104] Connection reset by peer
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
ERROR kafka.conn:conn.py:1096 <BrokerConnection node_id=1 host=localhost:9092 <connected> [IPv6 ('::1', 9092, 0, 0)]>: socket disconnected
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
ERROR kafka.conn:conn.py:1096 <BrokerConnection node_id=1 host=localhost:9092 <connected> [IPv4 ('127.0.0.1', 9092)]>: socket disconnected
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
ERROR kafka.conn:conn.py:1096 <BrokerConnection node_id=1 host=localhost:9092 <connected> [IPv6 ('::1', 9092, 0, 0)]>: socket disconnected
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
ERROR kafka.conn:conn.py:1107 <BrokerConnection node_id=1 host=localhost:9092 <connected> [IPv4 ('127.0.0.1', 9092)]>: Error receiving network data closing socket
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/kafka/conn.py", line 1090, in _recv
data = self._sock.recv(self.config['sock_chunk_bytes'])
ConnectionResetError: [Errno 104] Connection reset by peer
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
ERROR kafka.conn:conn.py:1096 <BrokerConnection node_id=1 host=localhost:9092 <connected> [IPv6 ('::1', 9092, 0, 0)]>: socket disconnected
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
ERROR kafka.conn:conn.py:1096 <BrokerConnection node_id=1 host=localhost:9092 <connected> [IPv4 ('127.0.0.1', 9092)]>: socket disconnected
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
ERROR kafka.conn:conn.py:1096 <BrokerConnection node_id=1 host=localhost:9092 <connected> [IPv6 ('::1', 9092, 0, 0)]>: socket disconnected
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
ERROR kafka.conn:conn.py:1096 <BrokerConnection node_id=1 host=localhost:9092 <connected> [IPv4 ('127.0.0.1', 9092)]>: socket disconnected
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
ERROR kafka.conn:conn.py:1096 <BrokerConnection node_id=1 host=localhost:9092 <connected> [IPv6 ('::1', 9092, 0, 0)]>: socket disconnected
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
ERROR kafka.conn:conn.py:1096 <BrokerConnection node_id=1 host=localhost:9092 <connected> [IPv4 ('127.0.0.1', 9092)]>: socket disconnected
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
ERROR kafka.conn:conn.py:1096 <BrokerConnection node_id=1 host=localhost:9092 <connected> [IPv6 ('::1', 9092, 0, 0)]>: socket disconnected
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
ERROR kafka.conn:conn.py:1107 <BrokerConnection node_id=1 host=localhost:9092 <connected> [IPv4 ('127.0.0.1', 9092)]>: Error receiving network data closing socket
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/kafka/conn.py", line 1090, in _recv
data = self._sock.recv(self.config['sock_chunk_bytes'])
ConnectionResetError: [Errno 104] Connection reset by peer
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
ERROR kafka.conn:conn.py:1096 <BrokerConnection node_id=1 host=localhost:9092 <connected> [IPv6 ('::1', 9092, 0, 0)]>: socket disconnected
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
ERROR kafka.conn:conn.py:418 Connect attempt to <BrokerConnection node_id=1 host=localhost:9092 <connecting> [IPv4 ('127.0.0.1', 9092)]> returned error 111. Disconnecting.
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
ERROR kafka.conn:conn.py:418 Connect attempt to <BrokerConnection node_id=1 host=localhost:9092 <connecting> [IPv6 ('::1', 9092, 0, 0)]> returned error 111. Disconnecting.
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
ERROR kafka.conn:conn.py:418 Connect attempt to <BrokerConnection node_id=1 host=localhost:9092 <connecting> [IPv4 ('127.0.0.1', 9092)]> returned error 111. Disconnecting.
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
ERROR kafka.conn:conn.py:418 Connect attempt to <BrokerConnection node_id=1 host=localhost:9092 <connecting> [IPv6 ('::1', 9092, 0, 0)]> returned error 111. Disconnecting.
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
ERROR kafka.conn:conn.py:418 Connect attempt to <BrokerConnection node_id=1 host=localhost:9092 <connecting> [IPv4 ('127.0.0.1', 9092)]> returned error 111. Disconnecting.
WARNING kafka.client:client_async.py:331 Node 1 connection failed -- refreshing metadata
================================ short test summary info ================================
FAILED tests/integration/event_source_kafka/test_kafka_source.py::test_kafka_source_plaintext - subprocess.CalledProcessError: Command '['ansible-rulebook', '-i', '/root/event-driven-ansible/tests/integration/default_inventory.yml', '--rulebook', '/root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_plaintext.yml']' returned non-zero exit status 1.
FAILED tests/integration/event_source_kafka/test_kafka_source.py::test_kafka_source_with_headers - subprocess.CalledProcessError: Command '['ansible-rulebook', '-i', '/root/event-driven-ansible/tests/integration/default_inventory.yml', '--rulebook', '/root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_headers.yml']' returned non-zero exit status 1.
FAILED tests/integration/event_source_kafka/test_kafka_source.py::test_kafka_source_ssl - subprocess.CalledProcessError: Command '['ansible-rulebook', '-i', '/root/event-driven-ansible/tests/integration/default_inventory.yml', '--rulebook', '/root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_ssl.yml']' returned non-zero exit status 1.
FAILED tests/integration/event_source_kafka/test_kafka_source.py::test_kafka_source_sasl_plaintext - subprocess.CalledProcessError: Command '['ansible-rulebook', '-i', '/root/event-driven-ansible/tests/integration/default_inventory.yml', '--rulebook', '/root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_sasl_plaintext.yml']' returned non-zero exit status 1.
FAILED tests/integration/event_source_kafka/test_kafka_source.py::test_kafka_source_sasl_ssl - subprocess.CalledProcessError: Command '['ansible-rulebook', '-i', '/root/event-driven-ansible/tests/integration/default_inventory.yml', '--rulebook', '/root/event-driven-ansible/tests/integration/event_source_kafka/test_kafka_rules_sasl_ssl.yml']' returned non-zero exit status 1.
================================== 5 failed in 29.70s ===================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment